Class McpToolServer
Serves the tools of an IAssistantToolSource to an assistant's host, as a Model Context Protocol (2025-06-18) server: the
bridge between an assistant and the language server's rdcore/tools/* requests.
public sealed class McpToolServer
- Inheritance
-
McpToolServer
- Inherited Members
Remarks
Messages are JSON-RPC 2.0, one per line of UTF-8 (the MCP stdio transport), over any pair of streams. The tools and their results go through as the source answers them: ToolDescriptor and ToolCallResult are already the MCP shapes.
| Message | Answer |
|---|---|
initialize | At once, without waiting for the platform: the protocol version ProtocolVersion (whichever
one the host asked for), the tools capability, McpServerInfo. |
ping | An empty result. |
tools/list | Every tool, in one answer; a cursor is ignored. |
tools/call | The tool's result. A refusal of the tool itself is a result with isError. |
notifications/cancelled | Cancels the request it names, which is then not answered. |
| Any other notification | Nothing. |
tools/list and tools/call wait for WaitForReadyAsync(CancellationToken) for at most ReadyTimeout.
They run as they come, several at a time; the answers are written one at a time, in the order they complete.
JSON-RPC errors: -32700 for a message that is not JSON, -32600 for one that is not a request or a notification (a batch, a message longer
than MaxMessageLength, the id of a request still running), -32601 for an unknown method, -32602 for a
tools/call that names no tool or whose parameters cannot be read, and -32603 for a platform that is not ready in time and for any failure of
the source, with its message. Messages are in the language of CurrentUICulture.
Constructors
McpToolServer(IAssistantToolSource, McpServerInfo, McpLimits?)
Serves the tools of an IAssistantToolSource to an assistant's host, as a Model Context Protocol (2025-06-18) server: the
bridge between an assistant and the language server's rdcore/tools/* requests.
public McpToolServer(IAssistantToolSource tools, McpServerInfo server, McpLimits? limits = null)
Parameters
toolsIAssistantToolSourceWhere the tools come from.
serverMcpServerInfoThe server, as
initializedescribes it.limitsMcpLimits
Remarks
Messages are JSON-RPC 2.0, one per line of UTF-8 (the MCP stdio transport), over any pair of streams. The tools and their results go through as the source answers them: ToolDescriptor and ToolCallResult are already the MCP shapes.
| Message | Answer |
|---|---|
initialize | At once, without waiting for the platform: the protocol version ProtocolVersion (whichever
one the host asked for), the tools capability, McpServerInfo. |
ping | An empty result. |
tools/list | Every tool, in one answer; a cursor is ignored. |
tools/call | The tool's result. A refusal of the tool itself is a result with isError. |
notifications/cancelled | Cancels the request it names, which is then not answered. |
| Any other notification | Nothing. |
tools/list and tools/call wait for WaitForReadyAsync(CancellationToken) for at most ReadyTimeout.
They run as they come, several at a time; the answers are written one at a time, in the order they complete.
JSON-RPC errors: -32700 for a message that is not JSON, -32600 for one that is not a request or a notification (a batch, a message longer
than MaxMessageLength, the id of a request still running), -32601 for an unknown method, -32602 for a
tools/call that names no tool or whose parameters cannot be read, and -32603 for a platform that is not ready in time and for any failure of
the source, with its message. Messages are in the language of CurrentUICulture.
Fields
InternalError
JSON-RPC 2.0: the request failed in the server.
public const int InternalError = -32603
Field Value
InvalidParams
JSON-RPC 2.0: the parameters of the request cannot be read.
public const int InvalidParams = -32602
Field Value
InvalidRequest
JSON-RPC 2.0: the message is not a request or a notification the server reads.
public const int InvalidRequest = -32600
Field Value
MethodNotFound
JSON-RPC 2.0: the server has no such method.
public const int MethodNotFound = -32601
Field Value
ParseError
JSON-RPC 2.0: the message is not JSON.
public const int ParseError = -32700
Field Value
ProtocolVersion
The version of the Model Context Protocol the server speaks.
public const string ProtocolVersion = "2025-06-18"
Field Value
Methods
RunAsync(Stream, Stream, CancellationToken)
Reads and answers messages until input ends or cancellationToken is cancelled. The requests still running then
are cancelled, and are not answered.
public Task RunAsync(Stream input, Stream output, CancellationToken cancellationToken)
Parameters
inputStreamWhere the host's messages are read: the server's standard input, under the stdio transport.
outputStreamWhere the answers are written: the server's standard output, under the stdio transport. Nothing else may write to it.
cancellationTokenCancellationTokenA token that stops the server.
Returns
- Task
A task that completes when the server has stopped.