/** * Minimal MCP (Model Context Protocol) types — covers the subset this * package implements: initialize, tools/list, tools/call, plus JSON-RPC. * * Aligned with the public MCP spec but trimmed to v0.1 needs. See * https://spec.modelcontextprotocol.io/ for the full surface. */ type JsonValue = string | number | boolean | null | { [key: string]: JsonValue; } | JsonValue[]; type JsonObject = { [key: string]: JsonValue; }; type JsonRpcId = string | number | null; type JsonRpcRequest = { jsonrpc: "2.0"; id: JsonRpcId; method: string; params?: JsonObject; }; type JsonRpcNotification = { jsonrpc: "2.0"; method: string; params?: JsonObject; }; type JsonRpcSuccess = { jsonrpc: "2.0"; id: JsonRpcId; result: JsonValue; }; type JsonRpcError = { jsonrpc: "2.0"; id: JsonRpcId; error: { code: number; message: string; data?: JsonValue; }; }; type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcSuccess | JsonRpcError; declare const JSONRPC_PARSE_ERROR = -32700; declare const JSONRPC_INVALID_REQUEST = -32600; declare const JSONRPC_METHOD_NOT_FOUND = -32601; declare const JSONRPC_INVALID_PARAMS = -32602; declare const JSONRPC_INTERNAL_ERROR = -32603; type ServerCapabilities = { tools?: { listChanged?: boolean; }; resources?: { listChanged?: boolean; subscribe?: boolean; }; prompts?: { listChanged?: boolean; }; logging?: Record; experimental?: Record; }; type ServerInfo = { name: string; version: string; title?: string; }; type InitializeResult = { protocolVersion: string; capabilities: ServerCapabilities; serverInfo: ServerInfo; instructions?: string; }; type ToolInputSchema = { /** The JSON Schema dialect, when a server states it (e.g. draft-07). */ $schema?: string; type: "object"; properties?: Record; required?: string[]; additionalProperties?: boolean; }; /** Behaviour hints a client may use when presenting or gating a tool. */ type ToolAnnotations = { title?: string; readOnlyHint?: boolean; destructiveHint?: boolean; idempotentHint?: boolean; openWorldHint?: boolean; }; /** * A tool as `tools/list` reports it. Every field is passed to the client * verbatim, so the optional ones below are the spec's, not extensions. */ type ToolDefinition = { name: string; title?: string; description?: string; inputSchema: ToolInputSchema; /** JSON Schema for `structuredContent`, when the tool returns it. */ outputSchema?: ToolInputSchema; annotations?: ToolAnnotations; /** 2025-11-25: whether the tool may run as a task. */ execution?: { taskSupport?: "forbidden" | "optional" | "required"; }; _meta?: { [key: string]: JsonValue; }; }; type ContentBlock = { type: "text"; text: string; } | { type: "image"; data: string; mimeType: string; } | { type: "resource"; resource: { uri: string; text?: string; mimeType?: string; }; }; type CallToolResult = { content: ContentBlock[]; isError?: boolean; /** Structured tool output — non-spec but useful for typed bridges. */ structuredContent?: JsonValue; }; /** Handler signature for a tool registered on the MicroMcpServer. */ type ToolCallContext = { transport?: unknown; }; type ToolHandler = (args: JsonObject, context?: ToolCallContext) => Promise | CallToolResult; /** * Options for `ToolHost.registerTool`. * * Tool names are one namespace shared by every bridge and agent on a host, so a * name belongs to whoever registered it. A second registrant for a held name is * refused rather than silently replacing the first. */ type RegisterToolOptions = { /** * Who is registering — a stable identity for the surface, e.g. the bridge id * (`"whiteboard"`, `"chart:revenue"`). The SAME owner may register a name it * already holds again; that replaces the tool, which is what a React remount * needs. A different owner is refused. A registration without an owner is a * registrant nobody can identify, so it never matches another one. */ owner?: string; /** * Take the name over whoever holds it. The explicit opt-in for the one thing * `registerTool` used to do implicitly; reach for it only when replacing * another registrant's tool is the point. */ replace?: boolean; }; /** Internal record kept by the server. */ type RegisteredTool = { definition: ToolDefinition; handler: ToolHandler; /** The registrant that holds this name, when it identified itself. */ owner?: string; }; declare const MCP_PROTOCOL_VERSION = "2025-06-18"; export { type CallToolResult as C, type InitializeResult as I, type JsonObject as J, MCP_PROTOCOL_VERSION as M, type RegisterToolOptions as R, type ServerInfo as S, type ToolDefinition as T, type ToolHandler as a, type RegisteredTool as b, type ServerCapabilities as c, type JsonRpcMessage as d, type ContentBlock as e, type JsonRpcNotification as f, type JsonRpcRequest as g, type JsonValue as h, type ToolCallContext as i, JSONRPC_INTERNAL_ERROR as j, JSONRPC_INVALID_PARAMS as k, JSONRPC_INVALID_REQUEST as l, JSONRPC_METHOD_NOT_FOUND as m, JSONRPC_PARSE_ERROR as n, type JsonRpcError as o, type JsonRpcId as p, type JsonRpcSuccess as q, type ToolAnnotations as r, type ToolInputSchema as s };