MCP TypeScript SDK (V2) / @modelcontextprotocol/server
@modelcontextprotocol/server
The MCP (Model Context Protocol) TypeScript server SDK. Build MCP servers that expose tools, resources, and prompts.
WARNING
This is a beta release. The API surface is settling but breaking changes remain possible until v2 stabilizes. Please try it and open issues — feedback during the beta directly shapes the stable release.
NOTE
This is v2 of the MCP TypeScript SDK. It replaces the monolithic @modelcontextprotocol/sdk package from v1. See the migration guide if you're coming from v1.
Install
npm install @modelcontextprotocol/server@betaTypeScript ≥6.0 no longer auto-includes @types/* — add "types": ["node"] to your tsconfig.json compilerOptions (the published .d.mts references Buffer).
Optional framework adapters: @modelcontextprotocol/express, @modelcontextprotocol/hono, @modelcontextprotocol/node.
Documentation
- Repository README — overview, package layout, examples
- Server guide — tools, resources, prompts, and the rest of the server surface
- Serving guide — stdio, HTTP, the framework adapters, sessions, and authorization
- API reference
- MCP specification
Modules
- fromJsonSchema
- index
- server/completable
- server/completable.examples
- server/createMcpHandler
- server/invoke
- server/legacyInputRequiredShim
- server/listenRouter
- server/mcp
- server/mcp.examples
- server/middleware/hostHeaderValidation
- server/middleware/hostHeaderValidation.examples
- server/middleware/originValidation
- server/perRequestTransport
- server/requestStateCodec
- server/server
- server/serverEventBus
- server/serveStdio
- server/stdio
- server/stdio.examples
- server/streamableHttp
- server/streamableHttp.examples
- shimsNode
- shimsWorkerd
- stdio
- validators/ajv
- validators/cfWorker