Skip to content

Commit cf3b082

Browse files
committed
Merge main into revert-1373-fix-json-header-notifs
Resolved conflicts: - packages/server/src/server/webStandardStreamableHttp.ts: deleted in main - packages/server/test/server/streamableHttp.test.ts: took main's version Applied revert change to packages/server/src/server/streamableHttp.ts: - Removed Content-Type: application/json header from 202 notification responses
1 parent 95e127e commit cf3b082

File tree

112 files changed

+8193
-15750
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+8193
-15750
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ jobs:
3838
run: pnpm run build:all
3939

4040
- name: Publish preview packages
41-
run: pnpm dlx pkg-pr-new publish --packageManager=npm --pnpm './packages/server' './packages/client'
41+
run:
42+
pnpm dlx pkg-pr-new publish --packageManager=npm --pnpm './packages/server' './packages/client'
43+
'./packages/middleware/express' './packages/middleware/hono' './packages/middleware/node'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ dist/
133133

134134
# IDE
135135
.idea/
136+
.cursor/
136137

137138
# Conformance test results
138139
results/

CLAUDE.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,15 @@ Transports (`packages/core/src/shared/transport.ts`) provide the communication l
6464
### Client-Side Features
6565

6666
- **Auth**: OAuth client support in `packages/client/src/client/auth.ts` and `packages/client/src/client/auth-extensions.ts`
67-
- **Middleware**: Request middleware in `packages/client/src/client/middleware.ts`
67+
- **Client middleware**: Request middleware in `packages/client/src/client/middleware.ts` (unrelated to the framework adapter packages below)
6868
- **Sampling**: Clients can handle `sampling/createMessage` requests from servers (LLM completions)
6969
- **Elicitation**: Clients can handle `elicitation/create` requests for user input (form or URL mode)
7070
- **Roots**: Clients can expose filesystem roots to servers via `roots/list`
7171

72+
### Middleware packages (framework/runtime adapters)
73+
74+
The repo also ships “middleware” packages under `packages/middleware/` (e.g. `@modelcontextprotocol/express`, `@modelcontextprotocol/hono`, `@modelcontextprotocol/node`). These are thin integration layers for specific frameworks/runtimes and should not add new MCP functionality.
75+
7276
### Experimental Features
7377

7478
Located in `packages/*/src/experimental/`:
@@ -224,7 +228,8 @@ mcpServer.tool('tool-name', { param: z.string() }, async ({ param }, extra) => {
224228

225229
```typescript
226230
// Server
227-
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: () => randomUUID() });
231+
// (Node.js IncomingMessage/ServerResponse wrapper; exported by @modelcontextprotocol/node)
232+
const transport = new NodeStreamableHTTPServerTransport({ sessionIdGenerator: () => randomUUID() });
228233
await server.connect(transport);
229234

230235
// Client

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ This repository contains the TypeScript SDK implementation of the MCP specificat
3030

3131
- MCP **server** libraries (tools/resources/prompts, Streamable HTTP, stdio, auth helpers)
3232
- MCP **client** libraries (transports, high-level helpers, OAuth helpers)
33+
- Optional **middleware packages** for specific runtimes/frameworks (Express, Hono, Node.js HTTP)
3334
- Runnable **examples** (under [`examples/`](examples/))
3435

3536
## Packages
@@ -41,6 +42,16 @@ This monorepo publishes split packages:
4142

4243
Both packages have a **required peer dependency** on `zod` for schema validation. The SDK internally imports from `zod/v4`, but remains compatible with projects using Zod v3.25+.
4344

45+
### Middleware packages (optional)
46+
47+
The SDK also publishes small “middleware” packages under [`packages/middleware/`](packages/middleware/) that help you **wire MCP into a specific runtime or web framework**.
48+
49+
They are intentionally thin adapters: they should not introduce new MCP functionality or business logic. See [`packages/middleware/README.md`](packages/middleware/README.md) for details.
50+
51+
- **`@modelcontextprotocol/node`**: Node.js Streamable HTTP transport wrapper for `IncomingMessage` / `ServerResponse`
52+
- **`@modelcontextprotocol/express`**: Express helpers (app defaults + Host header validation)
53+
- **`@modelcontextprotocol/hono`**: Hono helpers (app defaults + JSON body parsing hook + Host header validation)
54+
4455
## Installation
4556

4657
### Server
@@ -55,6 +66,23 @@ npm install @modelcontextprotocol/server zod
5566
npm install @modelcontextprotocol/client zod
5667
```
5768

69+
### Optional middleware packages
70+
71+
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`).
72+
73+
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.
74+
75+
```bash
76+
# Node.js HTTP (IncomingMessage/ServerResponse) Streamable HTTP transport:
77+
npm install @modelcontextprotocol/node
78+
79+
# Express integration:
80+
npm install @modelcontextprotocol/express express
81+
82+
# Hono integration:
83+
npm install @modelcontextprotocol/hono hono
84+
```
85+
5886
## Quick Start (runnable examples)
5987

6088
The runnable examples live under `examples/` and are kept in sync with the docs.

common/eslint-config/eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default defineConfig(
4747
'@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }],
4848
'simple-import-sort/imports': 'warn',
4949
'simple-import-sort/exports': 'warn',
50+
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
5051
'import/no-extraneous-dependencies': [
5152
'error',
5253
{

common/vitest-config/vitest.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export default defineConfig({
1515
deps: {
1616
moduleDirectories: ['node_modules', path.resolve(__dirname, '../../packages'), path.resolve(__dirname, '../../common')]
1717
},
18-
poolOptions: {
19-
threads: {
20-
useAtomics: true
21-
}
18+
},
19+
poolOptions: {
20+
threads: {
21+
useAtomics: true
2222
}
2323
},
2424
plugins: [tsconfigPaths()]

docs/faq.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ For production use, you can either:
6565

6666
The SDK ships several runnable server examples under `examples/server/src`. Start from the server examples index in [`examples/server/README.md`](../examples/server/README.md) and the entry-point quick start in the root [`README.md`](../README.md).
6767

68+
### Why did we remove `server` auth exports?
69+
70+
Server authentication & authorization is outside of the scope of the SDK, and the recommendation is to use packages that focus on this area specifically (or a full-fledged Authorization Server for those who use such). Example packages provide an example with `better-auth`.
71+
72+
### Why did we remove `server` SSE transport?
73+
74+
The SSE transport has been deprecated for a long time, and `v2` will not support it on the server side any more. Client side will keep supporting it in order to be able to connect to legacy SSE servers via the `v2` SDK, but serving SSE from `v2` will not be possible. Servers
75+
wanting to switch to `v2` and using SSE should migrate to Streamable HTTP.
76+
6877
## v1 (legacy)
6978

7079
### Where do v1 documentation and v1-specific fixes live?

docs/server.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ For more detailed patterns (stateless vs stateful, JSON response mode, CORS, DNS
7070
MCP servers running on localhost are vulnerable to DNS rebinding attacks. Use `createMcpExpressApp()` to create an Express app with DNS rebinding protection enabled by default:
7171

7272
```typescript
73-
import { createMcpExpressApp } from '@modelcontextprotocol/server';
73+
import { createMcpExpressApp } from '@modelcontextprotocol/express';
7474

7575
// Protection auto-enabled (default host is 127.0.0.1)
7676
const app = createMcpExpressApp();
@@ -85,7 +85,7 @@ const app = createMcpExpressApp({ host: '0.0.0.0' });
8585
When binding to `0.0.0.0` / `::`, provide an allow-list of hosts:
8686

8787
```typescript
88-
import { createMcpExpressApp } from '@modelcontextprotocol/server';
88+
import { createMcpExpressApp } from '@modelcontextprotocol/express';
8989

9090
const app = createMcpExpressApp({
9191
host: '0.0.0.0',

examples/server/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# MCP TypeScript SDK Examples (Server)
22

3-
This directory contains runnable MCP **server** examples built with `@modelcontextprotocol/server`.
3+
This directory contains runnable MCP **server** examples built with `@modelcontextprotocol/server` plus framework adapters:
4+
5+
- `@modelcontextprotocol/express`
6+
- `@modelcontextprotocol/hono`
47

58
For client examples, see [`../client/README.md`](../client/README.md). For guided docs, see [`../../docs/server.md`](../../docs/server.md).
69

@@ -68,7 +71,7 @@ When deploying MCP servers in a horizontally scaled environment (multiple server
6871

6972
### Stateless mode
7073

71-
To enable stateless mode, configure the `StreamableHTTPServerTransport` with:
74+
To enable stateless mode, configure the `NodeStreamableHTTPServerTransport` with:
7275

7376
```typescript
7477
sessionIdGenerator: undefined;

examples/server/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@
3535
},
3636
"dependencies": {
3737
"@hono/node-server": "catalog:runtimeServerOnly",
38-
"hono": "catalog:runtimeServerOnly",
3938
"@modelcontextprotocol/examples-shared": "workspace:^",
39+
"@modelcontextprotocol/node": "workspace:^",
4040
"@modelcontextprotocol/server": "workspace:^",
41+
"@modelcontextprotocol/express": "workspace:^",
42+
"@modelcontextprotocol/hono": "workspace:^",
43+
"better-auth": "^1.4.7",
4144
"cors": "catalog:runtimeServerOnly",
4245
"express": "catalog:runtimeServerOnly",
46+
"hono": "catalog:runtimeServerOnly",
4347
"zod": "catalog:runtimeShared"
4448
},
4549
"devDependencies": {

0 commit comments

Comments
 (0)