typescript-sdk/packages/middleware
xiaoxue 7e65fec24a 同步完整源码 - 2026-05-25 2026-05-25 00:25:13 +08:00
..
express 同步完整源码 - 2026-05-25 2026-05-25 00:25:13 +08:00
fastify 同步完整源码 - 2026-05-25 2026-05-25 00:25:13 +08:00
hono 同步完整源码 - 2026-05-25 2026-05-25 00:25:13 +08:00
node 同步完整源码 - 2026-05-25 2026-05-25 00:25:13 +08:00
README.md 同步完整源码 - 2026-05-25 2026-05-25 00:25:13 +08:00

README.md

Middleware packages

The packages in packages/middleware/* are thin integration layers that help you expose an MCP server in a specific runtime, platform, or web framework.

They intentionally do not add new MCP features or “business logic”. MCP functionality (tools, resources, prompts, transports, auth primitives, etc.) lives in @modelcontextprotocol/server (and other core packages). Middleware packages should primarily:

  • adapt request/response types to the SDK (e.g. Node.js IncomingMessage/ServerResponse)
  • provide small framework helpers (e.g. wiring, body parsing hooks)
  • supply safe defaults for common deployment pitfalls (e.g. localhost DNS rebinding protection)

Packages

  • @modelcontextprotocol/express — Express helpers (app defaults + Host header validation for DNS rebinding protection).
  • @modelcontextprotocol/hono — Hono helpers (app defaults + JSON body parsing hook + Host header validation).
  • @modelcontextprotocol/node — Node.js Streamable HTTP transport wrapper for IncomingMessage/ServerResponse.

Typical usage

Most servers use:

  • @modelcontextprotocol/server for the MCP server implementation
  • one middleware package for framework/runtime integration (this folder)
  • (optionally) additional platform/framework dependencies (Express, Hono, etc.)