Class McpDocumentOptions
- Assembly
- Codebelt.Extensions.Swashbuckle.AspNetCore.ModelContextProtocol.dll
Provides programmatic configuration for the McpDocumentFilter class.
public class McpDocumentOptions : IParameterObject
- Inheritance
-
McpDocumentOptions
- Implements
Examples
Use McpDocumentOptions to customize how the MCP filter documents your server in the OpenAPI specification. Instantiate and configure options, then pass them to the filter or use with the convenience extension method.
using Codebelt.Extensions.Swashbuckle.AspNetCore.ModelContextProtocol;
using Microsoft.Extensions.DependencyInjection;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace YourApp.Configuration;
/// <summary>
/// Example showing how to configure McpDocumentOptions.
/// </summary>
public class McpDocumentOptionsExample
{
public void ConfigureSwagger(IServiceCollection services)
{
services.AddSwaggerGen(options =>
{
// Create and customize McpDocumentOptions directly
var mcpOptions = new McpDocumentOptions
{
Pattern = "/api/mcp",
TagName = "Machine Intelligence",
IncludeTools = true,
EnableLegacySse = true
};
// Register the filter with custom options
options.DocumentFilterDescriptors.Add(
new FilterDescriptor
{
Type = typeof(McpDocumentFilter),
Arguments = new object[] { mcpOptions }
}
);
});
}
}
Each property of McpDocumentOptions controls how MCP endpoints appear in the OpenAPI document:
- Pattern: The HTTP route for MCP requests (default:
/mcp). - TagName: The OpenAPI tag grouping MCP operations (default:
MCP). - IncludeTools: Enables automatic tool discovery and documentation (default:
true). - EnableLegacySse: Includes legacy HTTP+SSE transport endpoints (default:
false).
Constructors
McpDocumentOptions()
Initializes a new instance of the McpDocumentOptions class.
public McpDocumentOptions()
Remarks
The following table shows the initial property values for an instance of McpDocumentOptions.
| Property | Initial value |
|---|---|
| Pattern | /mcp |
| TagName | MCP |
| IncludeTools | true |
| EnableLegacySse | false |
Properties
EnableLegacySse
Gets or sets a value indicating whether the legacy SSE transport endpoints
({Pattern}/sse and {Pattern}/message) should also be documented.
public bool EnableLegacySse { get; set; }
Property Value
- bool
Defaults to
false.
IncludeTools
Gets or sets a value indicating whether individual MCP tools should be documented as named examples on the POST {Pattern} request body.
public bool IncludeTools { get; set; }
Property Value
- bool
Defaults to
true.
Pattern
Gets or sets the route pattern prefix that was passed to MapMcp.
public string Pattern { get; set; }
Property Value
- string
Defaults to
/mcp.
TagName
Gets or sets the OpenAPI tag name used to group the MCP endpoints.
public string TagName { get; set; }
Property Value
- string
Defaults to
MCP.