Skip to content

basalt / mcp/src / McpServer

Class: McpServer ​

Defined in: mcp/src/server.ts:79

A Basalt app as an MCP server. Tools are the routes opted in with meta.mcp; handleMessage implements the MCP JSON-RPC surface, transport-independently, so the HTTP route and the stdio server share one code path.

The wire dispatch is delegated to the zero-dependency @basaltkit/mcp-core server — this class stays the framework-aware adapter that turns routes into function tools and preserves the package's public surface.

Constructors ​

Constructor ​

> new McpServer(options): McpServer

Defined in: mcp/src/server.ts:83

Parameters ​

options ​

McpServerOptions

Returns ​

McpServer

Properties ​

serverInfo ​

> readonly serverInfo: McpServerInfo

Defined in: mcp/src/server.ts:80

Methods ​

callTool() ​

> callTool(name, args, callCtx?): Promise<McpToolResult>

Defined in: mcp/src/server.ts:99

Parameters ​

name ​

string

args ​

Record<string, unknown>

callCtx? ​

ToolCallContext

Returns ​

Promise<McpToolResult>


handleMessage() ​

> handleMessage(message, callCtx?): Promise<JsonRpcResponse | null>

Defined in: mcp/src/server.ts:113

Handle one JSON-RPC message. Returns the response, or null for a notification (which by spec gets no reply). callCtx may carry per-request headers, the caller ip, a session (scopes cancellation) and, over stdio, notify/elicit hooks — all forwarded to the core.

Parameters ​

message ​

JsonRpcRequest

callCtx? ​

McpCallContext

Returns ​

Promise<JsonRpcResponse | null>


listTools() ​

> listTools(): ToolDescriptor[]

Defined in: mcp/src/server.ts:95

Tool descriptors, as returned by tools/list.

Returns ​

ToolDescriptor[]

Released under the MIT License.