import { S as ServerInfo, c as ServerCapabilities, d as JsonRpcMessage, C as CallToolResult } from './types-ITRQFAir.js'; import { a as ToolRegistry } from './tool-host-BqJRPr_T.js'; type McpServerOptions = { info: ServerInfo; /** Defaults to { tools: { listChanged: true } } */ capabilities?: ServerCapabilities; /** Free-text instructions surfaced to clients during initialize. */ instructions?: string; /** * The protocol revisions this server speaks, NEWEST FIRST. * * `initialize` echoes the client's requested revision when it is in this * list, and answers the first entry otherwise — the spec's rule, which leaves * the client to decide whether it can live with the answer. * * Defaults to `[MCP_PROTOCOL_VERSION]`: one revision, answered whatever the * client asks, which is exactly what this server did before the option * existed. Only list a revision the tools you register are correct under. */ protocolVersions?: readonly string[]; }; type Transport = { /** Called by the server when it has a message to deliver to the client. */ send: (message: JsonRpcMessage) => void; /** Called by the server when it's torn down so the transport can clean up. */ close?: () => void; }; /** * MicroMcpServer — protocol-level MCP server, transport-agnostic. * * Use it like: * * const server = new MicroMcpServer({ info: { name: "session", version: "0.1" } }); * server.registerTool({ name: "...", inputSchema: { type: "object" } }, async (args) => ({...})); * const transport = new InProcessTransport(); * server.attach(transport); * transport.deliver({ ... }); // client → server frames * * The same server can serve multiple transports (e.g. an in-process agent * AND a relayed external client) by attaching each one. */ declare class MicroMcpServer extends ToolRegistry { private transports; /** * Transports owed a `tools/list_changed` at the end of this tick. Empty when * none is scheduled. See {@link scheduleListChangedNotification}. */ private listChangedOwed; readonly info: ServerInfo; readonly capabilities: ServerCapabilities; readonly instructions?: string; readonly protocolVersions: readonly string[]; constructor(options: McpServerOptions); attach(transport: Transport): () => void; detach(transport: Transport): void; unregisterTool(name: string): void; protected onToolsChanged(): void; /** * Receive a JSON-RPC frame from a client (called by the transport). * The transport is responsible for sending the response back. */ receive(transport: Transport, message: JsonRpcMessage): Promise; private handle; /** The revision to answer `initialize` with: the one asked for if spoken, else the newest. */ private negotiate; /** * Tell the transports that SAW the old tool list that it changed. * * Changes in one tick coalesce into one notification. The recipients are the * transports attached at the moment of a change, not at the moment the * notification goes out: a transport attached afterwards never had the old * list, so "your list is stale" is noise to it — and on stdio, where a host * builds the server and attaches stdin/stdout in the same tick, it was the * first frame a client received, before it had even sent `initialize`. */ private scheduleListChangedNotification; /** Send an application notification to every client, or one attached transport. */ notify(message: JsonRpcMessage, transport?: Transport): void; private broadcast; private toRpcError; } declare function rpcError(code: number, message: string, data?: any): { data?: any; code: number; message: string; }; /** * Helper to build a CallToolResult from a string or structured value. */ declare function textResult(text: string, structured?: any): CallToolResult; declare function errorResult(text: string): CallToolResult; export { MicroMcpServer as M, type Transport as T, type McpServerOptions as a, errorResult as e, rpcError as r, textResult as t };