Relocate the ~6k-file docs tree from the repo root into plugins/document-navigator/docs/ so the plugin is self-contained and portable. docs/superpowers/ (specs and plans) stays at the repo root. Moved via cp+rm rather than git mv because directory rename() fails with EPERM on this WSL /mnt DrvFs mount; git rename-detection pairs the identical-content files at commit time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@suaveplan/mcp - Universal Model Context Protocol (MCP) server + client with JSON-RPC dispatcher, pluggable transports (in-memory, stdio, HTTP+SSE), AbortSignal cancellation, progress notifications, authorize hook, OTel meter, and Zod-derived wire types.
Universal Model Context Protocol (MCP) server + client with a pluggable transport stack, JSON-RPC dispatcher, AbortSignal cancellation, progress notifications, authorize hook, and OTel meter.
Documentation tree
- mcp-client —
MCPClientis the consumer-side surface of the Model Context Protocol.connect(transport)performs the MCP initializ…- mcp-client —
MCPClientis the consumer-side surface of the Model Context Protocol.connect(transport)performs the MCP initializ…
- mcp-client —
- error-codes —
@suaveplan/mcpraises three typed error classes —MCPError,MCPTransportError, andMCPProtocolError— for every…- error-codes —
@suaveplan/mcpraises three typed error classes —MCPError,MCPTransportError, andMCPProtocolError— for every…
- error-codes —
- events —
events.tsdeclaresMCPEventMap— the typed payload map shared byMCPServerandMCPClientvia the `EventBus<MCPE…- events —
events.tsdeclaresMCPEventMap— the typed payload map shared byMCPServerandMCPClientvia the `EventBus<MCPE…
- events —
- dispatcher —
JsonRpcDispatcheris the symmetric JSON-RPC 2.0 engine sitting underMCPServerandMCPClient. It owns id allocati…- dispatcher —
JsonRpcDispatcheris the symmetric JSON-RPC 2.0 engine sitting underMCPServerandMCPClient. It owns id allocati…
- dispatcher —
- schemas —
schemas.tsis the single source of truth for every wire shape in@suaveplan/mcp. Every public TypeScript type for a…- schemas —
schemas.tsis the single source of truth for every wire shape in@suaveplan/mcp. Every public TypeScript type for a…
- schemas —
- mcp-server —
MCPServeris the host-side surface of the Model Context Protocol. Owners register tools, resources, prompts, and root…- mcp-server —
MCPServeris the host-side surface of the Model Context Protocol. Owners register tools, resources, prompts, and root…
- mcp-server —
- telemetry —
telemetryregisters the OpenTelemetry meter@suaveplan/mcpand exposes three instruments (mcp_request_total, `mcp…- telemetry —
telemetryregisters the OpenTelemetry meter@suaveplan/mcpand exposes three instruments (mcp_request_total, `mcp…
- telemetry —
- http-sse —
HttpSseTransportrides MCP over a duplex pair: outbound requests via HTTP POST toendpointand inbound server-pushe…- http-sse —
HttpSseTransportrides MCP over a duplex pair: outbound requests via HTTP POST toendpointand inbound server-pushe…
- http-sse —
- in-memory —
InMemoryTransport.pair()creates twoTransportinstances wired head-to-head. Asendon one is immediately dispatc…- in-memory —
InMemoryTransport.pair()creates twoTransportinstances wired head-to-head. Asendon one is immediately dispatc…
- in-memory —
- stdio —
StdioTransportframes JSON-RPC messages over a newline-delimited JSON byte stream — the MCP spec default for sub-proc…- stdio —
StdioTransportframes JSON-RPC messages over a newline-delimited JSON byte stream — the MCP spec default for sub-proc…
- stdio —
- transport — The
Transportinterface is the contract that decouplesJsonRpcDispatcherfrom any specific I/O backend. Concrete tr…- transport — The
Transportinterface is the contract that decouplesJsonRpcDispatcherfrom any specific I/O backend. Concrete tr…
- transport — The
- types —
types/types.tscollects the structural / scalar types@suaveplan/mcpuses across modules that are NOT part of the w…- types —
types/types.tscollects the structural / scalar types@suaveplan/mcpuses across modules that are NOT part of the w…
- types —
Quick start
import { InMemoryTransport, MCPClient, MCPServer } from "@suaveplan/mcp";
const server = new MCPServer({ info: { name: "demo-server", version: "0.1.0" } });
server.registerTool({
name: "echo",
description: "Echo back the input",
inputSchema: { type: "object", properties: { msg: { type: "string" } } },
async handler({ msg }) {
return { content: [{ type: "text", text: String(msg) }] };
},
});
const client = new MCPClient({ info: { name: "demo-client", version: "0.1.0" } });
const [a, b] = InMemoryTransport.pair();
await server.start(a);
await client.connect(b);
const result = await client.callTool("echo", { msg: "hello" });
console.log(result.content);
await client.disconnect();
await server.stop();
Transport options
| Transport | Universal? | Subpath export | Notes |
|---|---|---|---|
InMemoryTransport.pair() |
yes | ./transport/in-memory |
In-process bridge; used by tests and embedded hosts. |
createStdioTransport({ readable, writable }) |
yes | ./transport/stdio |
Newline-delimited JSON. Caller injects byte streams; no Node imports. |
createHttpSseTransport({ endpoint, fetchImpl, eventSourceImpl }) |
yes | ./transport/http-sse |
HTTP POST out, SSE in. Caller injects platform globals or fakes. |
The Transport interface is exported so consumers can ship their own (e.g. WebSocket once @suaveplan/network-websockets lands).
Surface
| Module | Subpath | Highlights |
|---|---|---|
| Errors | ./error-codes |
MCP_CODES (15 codes), MCPError, MCPTransportError, MCPProtocolError. |
| Schemas | ./schemas |
Every wire type as a Zod schema + z.infer type. |
| JSON-RPC | ./jsonrpc |
JsonRpcDispatcher — symmetric request/notification engine. |
| Server | ./server |
MCPServer — tool/resource/prompt/root registration, authorize hook, sampling+completion providers, progress, abort. |
| Client | ./client |
MCPClient — initialize handshake, cached lists, callTool / readResource / getPrompt / complete / subscribeResource. |
| Telemetry | ./telemetry |
mcp_request_total counter, mcp_notification_total counter, mcp_request_duration_ms histogram. |
| Events | ./events |
MCPEventMap + createMCPEventBus(). |
MCP methods supported
All host-side methods of the MCP 2024-11-05 spec: initialize, ping, tools/list, tools/call, resources/list, resources/templates/list, resources/read, resources/subscribe, resources/unsubscribe, prompts/list, prompts/get, completion/complete, sampling/createMessage, roots/list, logging/setLevel. All notifications: notifications/initialized, notifications/cancelled, notifications/progress, notifications/message, notifications/resources/updated, notifications/resources/list_changed, notifications/tools/list_changed, notifications/prompts/list_changed, notifications/roots/list_changed.
Error codes
MCP.PROTOCOL_INVALID, MCP.METHOD_NOT_FOUND, MCP.INVALID_PARAMS, MCP.INTERNAL_ERROR, MCP.UNAUTHORIZED, MCP.REQUEST_CANCELLED, MCP.TIMEOUT, MCP.TRANSPORT_CLOSED, MCP.TRANSPORT_ERROR, MCP.NOT_INITIALIZED, MCP.ALREADY_CONNECTED, MCP.DUPLICATE_REGISTRATION, MCP.NOT_FOUND, MCP.PROTOCOL_VERSION_MISMATCH, MCP.HANDLER_FAILED.
License
MIT — © Suaveplan Team.