Table of Contents

AddMcpServer Method

Definition

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

options SwaggerGenOptions

The SwaggerGenOptions to extend.

setup Action<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

options SwaggerGenOptions

The SwaggerGenOptions to extend.

documentName string

The name passed to SwaggerDoc for the OpenAPI document that should include the MCP endpoints.

setup Action<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

options is null.

ArgumentException

documentName is null, empty, or consists only of white-space characters.