Architecture | Project Structure | Startup Process | Server Features | Extension Points | How It Works
- Usage
node dist/index.js [stdio|sse|streamableHttp] - Runs the specified transport manager to handle client connections.
- Specify transport type on command line (default
stdio)stdio→transports/stdio.jssse→transports/sse.jsstreamableHttp→transports/streamableHttp.js
- Creates a server instance using
createServer()fromserver/index.ts- Connects it to the chosen transport type from the MCP SDK.
- Handles communication according to the MCP specs for the chosen transport.
- STDIO:
- One simple, process‑bound connection.
- Calls
clientConnect()upon connection. - Closes and calls
cleanup()onSIGINT.
- SSE:
- Supports multiple client connections.
- Client transports are mapped to
sessionId; - Calls
clientConnect(sessionId)upon connection. - Hooks server’s
oncloseto clean and remove session. - Exposes
/sseGET (SSE stream)/messagePOST (JSON‑RPC messages)
- Streamable HTTP:
- Supports multiple client connections.
- Client transports are mapped to
sessionId; - Calls
clientConnect(sessionId)upon connection. - Exposes
/mcpfor- POST (JSON‑RPC messages)
- GET (SSE stream)
- DELETE (termination)
- Uses an event store for resumability and stores transports by
sessionId. - Calls
cleanup(sessionId)on DELETE.
- STDIO:
- Invoke
createServer()fromserver/index.ts - Creates a new
McpServerinstance with- Capabilities:
tools: {}logging: {}prompts: {}resources: { subscribe: true }
- Server Instructions
- Loaded from the docs folder (
server-instructions.md).
- Loaded from the docs folder (
- Registrations
- Registers tools via
registerTools(server). - Registers resources via
registerResources(server). - Registers prompts via
registerPrompts(server).
- Registers tools via
- Other Request Handlers
- Sets up resource subscription handlers via
setSubscriptionHandlers(server). - Roots list change handler is added post-connection via
- Sets up resource subscription handlers via
- Returns
- The
McpServerinstance - A
clientConnect(sessionId)callback that enables post-connection setup - A
cleanup(sessionId?)callback that stops any active intervals and removes any session‑scoped state
- The
- Capabilities:
Some of the transport managers defined in the transports folder can support multiple clients.
In order to do so, they must map certain data to a session identifier.