Interface IMcpServer
- Namespace
- ModelContextProtocol.Server
- Assembly
- ModelContextProtocol.dll
Represents an instance of a Model Context Protocol (MCP) server that connects to and communicates with an MCP client.
public interface IMcpServer : IMcpEndpoint, IAsyncDisposable
- Inherited Members
- Extension Methods
Properties
ClientCapabilities
Gets the capabilities supported by the client.
ClientCapabilities? ClientCapabilities { get; }
Property Value
Remarks
These capabilities are established during the initialization handshake and indicate which features the client supports, such as sampling, roots, and other protocol-specific functionality.
Server implementations can check these capabilities to determine which features are available when interacting with the client.
ClientInfo
Gets the version and implementation information of the connected client.
Implementation? ClientInfo { get; }
Property Value
Remarks
This property contains identification information about the client that has connected to this server, including its name and version. This information is provided by the client during initialization.
Server implementations can use this information for logging, tracking client versions, or implementing client-specific behaviors.
LoggingLevel
Gets the last logging level set by the client, or null if it's never been set.
LoggingLevel? LoggingLevel { get; }
Property Value
ServerOptions
Gets the options used to construct this server.
McpServerOptions ServerOptions { get; }
Property Value
Remarks
These options define the server's capabilities, protocol version, and other configuration settings that were used to initialize the server.
Services
Gets the service provider for the server.
IServiceProvider? Services { get; }
Property Value
Methods
RunAsync(CancellationToken)
Runs the server, listening for and handling client requests.
Task RunAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationToken