Class McpServerOptions
- Namespace
- ModelContextProtocol.Server
- Assembly
- ModelContextProtocol.Core.dll
Provides configuration options for the MCP server.
public sealed class McpServerOptions
- Inheritance
-
McpServerOptions
- Inherited Members
Properties
Capabilities
Gets or sets server capabilities to advertise to the client.
public ServerCapabilities? Capabilities { get; set; }
Property Value
Remarks
These determine which features will be available when a client connects. Capabilities can include "tools", "prompts", "resources", "logging", and other protocol-specific functionality.
Filters
Gets the filter collections for MCP server handlers.
public McpServerFilters Filters { get; }
Property Value
Remarks
This property provides access to filter collections that can be used to modify the behavior of various MCP server handlers. Filters are applied in reverse order, so the last filter added will be the outermost (first to execute).
Handlers
Gets or sets the container of handlers used by the server for processing protocol messages.
public McpServerHandlers Handlers { get; set; }
Property Value
InitializationTimeout
Gets or sets a timeout used for the client-server initialization handshake sequence.
public TimeSpan InitializationTimeout { get; set; }
Property Value
Remarks
This timeout determines how long the server will wait for client responses during the initialization protocol handshake. If the client doesn't respond within this timeframe, the initialization process will be aborted.
KnownClientInfo
Gets or sets preexisting knowledge about the client including its name and version to help support stateless Streamable HTTP servers that encode this knowledge in the mcp-session-id header.
public Implementation? KnownClientInfo { get; set; }
Property Value
Remarks
When not specified, this information is sourced from the client's initialize request.
PromptCollection
Gets or sets a collection of prompts that will be served by the server.
public McpServerPrimitiveCollection<McpServerPrompt>? PromptCollection { get; set; }
Property Value
Remarks
The PromptCollection contains the predefined prompts that clients can request from the server. This collection works in conjunction with ListPromptsHandler and GetPromptHandler when those are provided:
- For PromptsList requests: The server returns all prompts from this collection plus any additional prompts provided by the ListPromptsHandler if it's set.
- For PromptsGet requests: The server first checks this collection for the requested prompt. If not found, it will invoke the GetPromptHandler as a fallback if one is set.
ProtocolVersion
Gets or sets the protocol version supported by this server, using a date-based versioning scheme.
public string? ProtocolVersion { get; set; }
Property Value
Remarks
The protocol version defines which features and message formats this server supports. This uses a date-based versioning scheme in the format "YYYY-MM-DD". If null, the server will advertize to the client the version requested by the client if that version is known to be supported, and otherwise will advertize the latest version supported by the server.
ResourceCollection
Gets or sets a collection of resources served by the server.
public McpServerResourceCollection? ResourceCollection { get; set; }
Property Value
Remarks
Resources specified via ResourceCollection augment the ListResourcesHandler, ListResourceTemplatesHandler and ReadResourceHandler handlers, if provided. Resources with template expressions in their URI templates are considered resource templates and are listed via ListResourceTemplate, whereas resources without template parameters are considered static resources and are listed with ListResources.
ReadResource requests will first check the ResourceCollection for the exact resource being requested. If no match is found, they'll proceed to try to match the resource against each resource template in ResourceCollection. If no match is still found, the request will fall back to any handler registered for ReadResourceHandler.
ScopeRequests
Gets or sets whether to create a new service provider scope for each handled request.
public bool ScopeRequests { get; set; }
Property Value
Remarks
The default is true. When true, each invocation of a request handler will be invoked within a new service scope.
ServerInfo
Gets or sets information about this server implementation, including its name and version.
public Implementation? ServerInfo { get; set; }
Property Value
Remarks
This information is sent to the client during initialization to identify the server. It's displayed in client logs and can be used for debugging and compatibility checks.
ServerInstructions
Gets or sets optional server instructions to send to clients.
public string? ServerInstructions { get; set; }
Property Value
Remarks
These instructions are sent to clients during the initialization handshake and provide guidance on how to effectively use the server's capabilities. They can include details about available tools, expected input formats, limitations, or other helpful information. Client applications typically use these instructions as system messages for LLM interactions to provide context about available functionality.
ToolCollection
Gets or sets a collection of tools served by the server.
public McpServerPrimitiveCollection<McpServerTool>? ToolCollection { get; set; }
Property Value
Remarks
Tools specified via ToolCollection augment the ListToolsHandler and CallToolHandler, if provided. ListTools requests will output information about every tool in ToolCollection and then also any tools output by ListToolsHandler, if it's non-null. CallTool requests will first check ToolCollection for the tool being requested, and if the tool is not found in the ToolCollection, any specified CallToolHandler will be invoked as a fallback.