AddMcpServer Method
Definition
- Assemblies
- Codebelt.Extensions.Swashbuckle.AspNetCore.ModelContextProtocol.dll
AddMcpServer(SwaggerGenOptions, Action<McpDocumentOptions>)
Adds a McpDocumentFilter to the DocumentFilterDescriptors so that the MCP endpoint(s) appear in the generated OpenAPI document.
public static void AddMcpServer(this SwaggerGenOptions options, Action<McpDocumentOptions> setup = null)
Parameters
optionsSwaggerGenOptionsThe SwaggerGenOptions to extend.
setupAction<McpDocumentOptions>The McpDocumentOptions that may be configured.
AddMcpServer(SwaggerGenOptions, string, Action<McpDocumentOptions>)
Adds a McpDocumentFilter that applies only to the named OpenAPI document.
public static void AddMcpServer(this SwaggerGenOptions options, string documentName, Action<McpDocumentOptions> setup)
Parameters
optionsSwaggerGenOptionsThe SwaggerGenOptions to extend.
documentNamestringThe name passed to
SwaggerDocfor the OpenAPI document that should include the MCP endpoints.setupAction<McpDocumentOptions>The McpDocumentOptions that may be configured.
Remarks
Call this overload once for each document that needs a distinct MCP version or transport configuration.
The existing overload without documentName continues to apply its configuration to every document.
Exceptions
- ArgumentNullException
optionsisnull.- ArgumentException
documentNameisnull, empty, or consists only of white-space characters.