|
| 1 | +# Documentation Guidelines |
| 2 | + |
| 3 | +This directory contains the conceptual documentation for the MCP C# SDK, built using [DocFX](https://dotnetfoundation.github.io/docfx/). |
| 4 | + |
| 5 | +## Referencing API Types |
| 6 | + |
| 7 | +When referencing types from the MCP C# SDK API in markdown documentation, **always use DocFX xref syntax** instead of direct URLs to API documentation pages. This ensures that: |
| 8 | + |
| 9 | +1. Links remain valid even when API documentation structure changes |
| 10 | +2. DocFX can validate that referenced types exist during build |
| 11 | +3. Links work correctly in offline documentation |
| 12 | +4. DocFX generates proper warnings if referenced types are obsolete or missing |
| 13 | + |
| 14 | +### xref Syntax |
| 15 | + |
| 16 | +Use the `<xref:>` tag to reference types, methods, and properties: |
| 17 | + |
| 18 | +```markdown |
| 19 | +<!-- Reference a type --> |
| 20 | +<xref:ModelContextProtocol.Client.McpClient> |
| 21 | + |
| 22 | +<!-- Reference a method (use * for overloads) --> |
| 23 | +<xref:ModelContextProtocol.McpSession.SendNotificationAsync*> |
| 24 | + |
| 25 | +<!-- Reference a specific property --> |
| 26 | +<xref:ModelContextProtocol.Client.McpClient.ServerCapabilities> |
| 27 | + |
| 28 | +<!-- Reference a property on a different type --> |
| 29 | +<xref:ModelContextProtocol.Protocol.ServerCapabilities.Logging> |
| 30 | + |
| 31 | +<!-- Reference types from external libraries --> |
| 32 | +<xref:System.Progress`1> |
| 33 | +<xref:Microsoft.Extensions.Logging.ILogger> |
| 34 | +``` |
| 35 | + |
| 36 | +### Common Types to Reference |
| 37 | + |
| 38 | +When updating documentation, use these type names instead of obsolete interfaces: |
| 39 | + |
| 40 | +| Obsolete Interface | Current Type | xref | |
| 41 | +|--------------------|--------------|------| |
| 42 | +| `IMcpEndpoint` | `McpSession` | `<xref:ModelContextProtocol.McpSession>` | |
| 43 | +| `IMcpClient` | `McpClient` | `<xref:ModelContextProtocol.Client.McpClient>` | |
| 44 | +| `IMcpServer` | `McpServer` | `<xref:ModelContextProtocol.Server.McpServer>` | |
| 45 | + |
| 46 | +Note: `IMcpServerBuilder` is NOT obsolete and should still be referenced. |
| 47 | + |
| 48 | +### Building Documentation |
| 49 | + |
| 50 | +To build the documentation locally and verify xref links: |
| 51 | + |
| 52 | +```bash |
| 53 | +make generate-docs |
| 54 | +``` |
| 55 | + |
| 56 | +This will: |
| 57 | +1. Clean previous builds |
| 58 | +2. Build the project |
| 59 | +3. Generate API documentation |
| 60 | +4. Build the DocFX site to `artifacts/_site` |
| 61 | + |
| 62 | +To serve the documentation locally: |
| 63 | + |
| 64 | +```bash |
| 65 | +make serve-docs |
| 66 | +``` |
| 67 | + |
| 68 | +Then navigate to `http://localhost:8080` to view the documentation. |
| 69 | + |
| 70 | +## External Links |
| 71 | + |
| 72 | +For links to external documentation (e.g., Microsoft Learn, MCP specification), regular markdown links are acceptable: |
| 73 | + |
| 74 | +```markdown |
| 75 | +[Model Context Protocol](https://modelcontextprotocol.io/) |
| 76 | +[ILogger](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.ilogger) |
| 77 | +``` |
0 commit comments