diff --git a/README.md b/README.md index 22404e5f68..080025cd11 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ This repository contains the TypeScript SDK implementation of the MCP specificat - MCP **server** libraries (tools/resources/prompts, Streamable HTTP, stdio, auth helpers) - MCP **client** libraries (transports, high-level helpers, OAuth helpers) -- Optional **middleware packages** for specific runtimes/frameworks (Express, Hono, Node.js HTTP) +- Optional **middleware packages** for specific runtimes/frameworks (Express, Fastify, Hono, Node.js HTTP) - Runnable **examples** (under [`examples/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/examples)) ## Packages @@ -58,6 +58,7 @@ They are intentionally thin adapters: they should not introduce new MCP function - **`@modelcontextprotocol/node`**: Node.js Streamable HTTP transport wrapper for `IncomingMessage` / `ServerResponse` - **`@modelcontextprotocol/express`**: Express helpers (app defaults + Host header validation) +- **`@modelcontextprotocol/fastify`**: Fastify helpers (app defaults + Host header validation) - **`@modelcontextprotocol/hono`**: Hono helpers (app defaults + JSON body parsing hook + Host header validation) ## Installation @@ -84,7 +85,7 @@ deno add npm:@modelcontextprotocol/client ### Optional middleware packages -The SDK also publishes optional “middleware” packages that help you **wire MCP into a specific runtime or web framework** (for example Express, Hono, or Node.js `http`). +The SDK also publishes optional “middleware” packages that help you **wire MCP into a specific runtime or web framework** (for example Express, Fastify, Hono, or Node.js `http`). These packages are intentionally thin adapters and should not introduce additional MCP features or business logic. See [`packages/middleware/README.md`](packages/middleware/README.md) for details. @@ -95,6 +96,9 @@ npm install @modelcontextprotocol/node # Express integration: npm install @modelcontextprotocol/express express +# Fastify integration: +npm install @modelcontextprotocol/fastify fastify + # Hono integration: npm install @modelcontextprotocol/hono hono ``` diff --git a/docs/clients/middleware.md b/docs/clients/middleware.md index 2904850fea..88eafd2967 100644 --- a/docs/clients/middleware.md +++ b/docs/clients/middleware.md @@ -26,7 +26,7 @@ const transport = new StreamableHTTPClientTransport(new URL('http://localhost:30 Every request this transport sends now carries the header — including the requests the SDK sends that you never wrote, like `initialize`. ::: info Not the framework middleware packages -This page is about client request middleware: functions that wrap the `fetch` inside `@modelcontextprotocol/client`. The `@modelcontextprotocol/express`, `@modelcontextprotocol/hono`, and `@modelcontextprotocol/node` packages also carry the word "middleware" — those are server-side framework adapters for mounting a handler. See [Express](../serving/express.md) and [Hono](../serving/hono.md). +This page is about client request middleware: functions that wrap the `fetch` inside `@modelcontextprotocol/client`. The `@modelcontextprotocol/express`, `@modelcontextprotocol/fastify`, `@modelcontextprotocol/hono`, and `@modelcontextprotocol/node` packages also carry the word "middleware" — those are server-side framework adapters for mounting a handler. See [Express](../serving/express.md), [Fastify](../serving/fastify.md), and [Hono](../serving/hono.md). ::: ## Compose several middlewares diff --git a/packages/middleware/README.md b/packages/middleware/README.md index 2dd2335fb1..06f4efcef5 100644 --- a/packages/middleware/README.md +++ b/packages/middleware/README.md @@ -11,6 +11,7 @@ They intentionally **do not** add new MCP features or “business logic”. MCP ## Packages - `@modelcontextprotocol/express` — Express helpers (app defaults + Host header validation for DNS rebinding protection). +- `@modelcontextprotocol/fastify` — Fastify 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`. diff --git a/packages/server/README.md b/packages/server/README.md index 1d5aefb73f..cc2f626846 100644 --- a/packages/server/README.md +++ b/packages/server/README.md @@ -18,7 +18,7 @@ npm install @modelcontextprotocol/server@beta TypeScript ≥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`](https://www.npmjs.com/package/@modelcontextprotocol/express), [`@modelcontextprotocol/hono`](https://www.npmjs.com/package/@modelcontextprotocol/hono), +Optional framework adapters: [`@modelcontextprotocol/express`](https://www.npmjs.com/package/@modelcontextprotocol/express), [`@modelcontextprotocol/fastify`](https://www.npmjs.com/package/@modelcontextprotocol/fastify), [`@modelcontextprotocol/hono`](https://www.npmjs.com/package/@modelcontextprotocol/hono), [`@modelcontextprotocol/node`](https://www.npmjs.com/package/@modelcontextprotocol/node). ## Documentation