basalt / mcp-core/src / McpServer
Class: McpServer
Defined in: mcp-core/src/server.ts:193
A transport-neutral MCP server over function-shaped tools/resources/prompts. handleMessage implements the MCP JSON-RPC surface independently of any transport, so stdio and HTTP share one code path. Resources and prompts are only served (and advertised in initialize capabilities) when registered, so a tools-only server behaves exactly like a classic MCP tool server.
Constructors
Constructor
> new McpServer(options?): McpServer
Defined in: mcp-core/src/server.ts:207
Parameters
options?
McpServerOptions = {}
Returns
McpServer
Properties
serverInfo
> readonly serverInfo: McpServerInfo
Defined in: mcp-core/src/server.ts:194
Methods
callTool()
> callTool(name, args, ctx?): Promise<McpToolResult>
Defined in: mcp-core/src/server.ts:252
Invoke a tool directly (bypassing the JSON-RPC layer). Throws for an unknown name.
Parameters
name
string
args
Record<string, unknown>
ctx?
CallContext = {}
Returns
Promise<McpToolResult>
handleMessage()
> handleMessage(message, ctx?): Promise<JsonRpcResponse | null>
Defined in: mcp-core/src/server.ts:268
Handle one JSON-RPC message. Returns the response, or null for a notification (which by spec gets no reply).
Parameters
message
ctx?
CallContext = {}
Returns
Promise<JsonRpcResponse | null>
listTools()
Call Signature
> listTools(): ToolDescriptor[]
Defined in: mcp-core/src/server.ts:220
Tool descriptors, as returned by tools/list. Without a context, every tool; with one, only the tools whose visible hook (if any) admits it — then the result is a promise.
Returns
Call Signature
> listTools(ctx): Promise<ToolDescriptor[]>
Defined in: mcp-core/src/server.ts:221
Tool descriptors, as returned by tools/list. Without a context, every tool; with one, only the tools whose visible hook (if any) admits it — then the result is a promise.
Parameters
ctx
Returns
Promise<ToolDescriptor[]>