Table of Contents

Class McpToolServer

Namespace
RDCore.SDK.Assistant
Assembly
RDCore.SDK.Protocol.dll

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.

MessageAnswer
initializeAt once, without waiting for the platform: the protocol version ProtocolVersion (whichever one the host asked for), the tools capability, McpServerInfo.
pingAn empty result.
tools/listEvery tool, in one answer; a cursor is ignored.
tools/callThe tool's result. A refusal of the tool itself is a result with isError.
notifications/cancelledCancels the request it names, which is then not answered.
Any other notificationNothing.

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

tools IAssistantToolSource

Where the tools come from.

server McpServerInfo

The server, as initialize describes it.

limits McpLimits

The bounds the server keeps; Default when null.

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.

MessageAnswer
initializeAt once, without waiting for the platform: the protocol version ProtocolVersion (whichever one the host asked for), the tools capability, McpServerInfo.
pingAn empty result.
tools/listEvery tool, in one answer; a cursor is ignored.
tools/callThe tool's result. A refusal of the tool itself is a result with isError.
notifications/cancelledCancels the request it names, which is then not answered.
Any other notificationNothing.

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

int

InvalidParams

JSON-RPC 2.0: the parameters of the request cannot be read.

public const int InvalidParams = -32602

Field Value

int

InvalidRequest

JSON-RPC 2.0: the message is not a request or a notification the server reads.

public const int InvalidRequest = -32600

Field Value

int

MethodNotFound

JSON-RPC 2.0: the server has no such method.

public const int MethodNotFound = -32601

Field Value

int

ParseError

JSON-RPC 2.0: the message is not JSON.

public const int ParseError = -32700

Field Value

int

ProtocolVersion

The version of the Model Context Protocol the server speaks.

public const string ProtocolVersion = "2025-06-18"

Field Value

string

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

input Stream

Where the host's messages are read: the server's standard input, under the stdio transport.

output Stream

Where the answers are written: the server's standard output, under the stdio transport. Nothing else may write to it.

cancellationToken CancellationToken

A token that stops the server.

Returns

Task

A task that completes when the server has stopped.