Skip to content

Commit c08d641

Browse files
Merge branch 'main' into fweinberger/tooltask-handlers
2 parents 56f0082 + babaa50 commit c08d641

7 files changed

Lines changed: 117 additions & 52 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@modelcontextprotocol/server': patch
3+
---
4+
5+
fix(server): propagate negotiated protocol version to transport in _oninitialize

.changeset/pre.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"mode": "pre",
3+
"tag": "alpha",
4+
"initialVersions": {
5+
"@modelcontextprotocol/eslint-config": "2.0.0",
6+
"@modelcontextprotocol/tsconfig": "2.0.0",
7+
"@modelcontextprotocol/vitest-config": "2.0.0",
8+
"@modelcontextprotocol/examples-client": "2.0.0-alpha.0",
9+
"@modelcontextprotocol/examples-client-quickstart": "2.0.0-alpha.0",
10+
"@modelcontextprotocol/examples-server": "2.0.0-alpha.0",
11+
"@modelcontextprotocol/examples-server-quickstart": "2.0.0-alpha.0",
12+
"@modelcontextprotocol/examples-shared": "2.0.0-alpha.0",
13+
"@modelcontextprotocol/client": "2.0.0-alpha.0",
14+
"@modelcontextprotocol/core": "2.0.0-alpha.0",
15+
"@modelcontextprotocol/express": "2.0.0-alpha.0",
16+
"@modelcontextprotocol/fastify": "2.0.0-alpha.0",
17+
"@modelcontextprotocol/hono": "2.0.0-alpha.0",
18+
"@modelcontextprotocol/node": "2.0.0-alpha.0",
19+
"@modelcontextprotocol/server": "2.0.0-alpha.0",
20+
"@modelcontextprotocol/test-conformance": "2.0.0-alpha.0",
21+
"@modelcontextprotocol/test-helpers": "2.0.0-alpha.0",
22+
"@modelcontextprotocol/test-integration": "2.0.0-alpha.0"
23+
},
24+
"changesets": []
25+
}

.github/workflows/main.yml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
- main
55
pull_request:
66
workflow_dispatch:
7-
release:
8-
types: [published]
97

108
concurrency:
119
group: ${{ github.workflow }}-${{ github.ref }}
@@ -94,53 +92,3 @@ jobs:
9492
- name: Run ${{ matrix.runtime }} integration tests
9593
run: pnpm --filter @modelcontextprotocol/test-integration test:integration:${{ matrix.runtime }}
9694

97-
publish:
98-
runs-on: ubuntu-latest
99-
if: github.event_name == 'release'
100-
environment: release
101-
needs: [build, test, test-runtimes]
102-
103-
permissions:
104-
contents: read
105-
id-token: write
106-
107-
steps:
108-
- uses: actions/checkout@v6
109-
110-
- name: Install pnpm
111-
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
112-
id: pnpm-install
113-
with:
114-
run_install: false
115-
- uses: actions/setup-node@v6
116-
with:
117-
node-version: 24
118-
cache: pnpm
119-
cache-dependency-path: pnpm-lock.yaml
120-
registry-url: 'https://registry.npmjs.org'
121-
- run: pnpm install
122-
123-
- name: Determine npm tag
124-
id: npm-tag
125-
run: |
126-
VERSION=$(node -p "require('./package.json').version")
127-
# Check if this is a beta release
128-
if [[ "$VERSION" == *"-beta"* ]]; then
129-
echo "tag=--tag beta" >> $GITHUB_OUTPUT
130-
# Check if this release is from a non-primary branch (patch/maintenance release)
131-
elif [[ "${{ github.event.release.target_commitish }}" != "main" && "${{ github.event.release.target_commitish }}" != "v1.x" ]]; then
132-
# Use "release-X.Y" as tag for old branch releases (e.g., "release-1.23" for 1.23.x)
133-
# npm tags are mutable pointers to versions (like "latest" pointing to 1.24.3).
134-
# Using "release-1.23" means users can `npm install @modelcontextprotocol/sdk@release-1.23`
135-
# to get the latest patch on that minor version, and the tag updates if we
136-
# release 1.23.2, 1.23.3, etc.
137-
# Note: Can't use "v1.23" because npm rejects tags that look like semver ranges.
138-
MAJOR_MINOR=$(echo "$VERSION" | cut -d. -f1,2)
139-
echo "tag=--tag release-${MAJOR_MINOR}" >> $GITHUB_OUTPUT
140-
else
141-
echo "tag=" >> $GITHUB_OUTPUT
142-
fi
143-
144-
- run: pnpm publish --provenance --access public ${{ steps.npm-tag.outputs.tag }}
145-
env:
146-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

packages/client/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# `@modelcontextprotocol/client`
2+
3+
The MCP (Model Context Protocol) TypeScript client SDK. Build MCP clients that connect to MCP servers.
4+
5+
> [!WARNING] **This is an alpha release.** Expect breaking changes until v2 stabilizes. We're publishing early to gather feedback — please try it and open issues — but we can't guarantee API stability yet. We'll aim to minimize disruption between alphas.
6+
7+
> [!NOTE] This is **v2** of the MCP TypeScript SDK. It replaces the monolithic `@modelcontextprotocol/sdk` package from v1. See the **[migration guide](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/docs/migration.md)** if you're coming from v1.
8+
9+
## Install
10+
11+
```bash
12+
npm install @modelcontextprotocol/client@alpha
13+
```
14+
15+
## Documentation
16+
17+
- **[Repository README](https://github.com/modelcontextprotocol/typescript-sdk#readme)** — overview, package layout, examples
18+
- **[Client guide](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/docs/client.md)**
19+
- **[API reference](https://ts.sdk.modelcontextprotocol.io/v2/)**
20+
- **[MCP specification](https://modelcontextprotocol.io)**

packages/server/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# `@modelcontextprotocol/server`
2+
3+
The MCP (Model Context Protocol) TypeScript server SDK. Build MCP servers that expose tools, resources, and prompts.
4+
5+
> [!WARNING] **This is an alpha release.** Expect breaking changes until v2 stabilizes. We're publishing early to gather feedback — please try it and open issues — but we can't guarantee API stability yet. We'll aim to minimize disruption between alphas.
6+
7+
> [!NOTE] This is **v2** of the MCP TypeScript SDK. It replaces the monolithic `@modelcontextprotocol/sdk` package from v1. See the **[migration guide](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/docs/migration.md)** if you're coming from v1.
8+
9+
## Install
10+
11+
```bash
12+
npm install @modelcontextprotocol/server@alpha
13+
```
14+
15+
Optional framework adapters: [`@modelcontextprotocol/express`](https://www.npmjs.com/package/@modelcontextprotocol/express), [`@modelcontextprotocol/hono`](https://www.npmjs.com/package/@modelcontextprotocol/hono),
16+
[`@modelcontextprotocol/node`](https://www.npmjs.com/package/@modelcontextprotocol/node).
17+
18+
## Documentation
19+
20+
- **[Repository README](https://github.com/modelcontextprotocol/typescript-sdk#readme)** — overview, package layout, examples
21+
- **[Server guide](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/docs/server.md)**
22+
- **[API reference](https://ts.sdk.modelcontextprotocol.io/v2/)**
23+
- **[MCP specification](https://modelcontextprotocol.io)**

packages/server/src/server/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ export class Server extends Protocol<ServerContext> {
433433
? requestedVersion
434434
: (this._supportedProtocolVersions[0] ?? LATEST_PROTOCOL_VERSION);
435435

436+
this.transport?.setProtocolVersion?.(protocolVersion);
437+
436438
return {
437439
protocolVersion,
438440
capabilities: this.getCapabilities(),
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import type { JSONRPCMessage } from '@modelcontextprotocol/core';
2+
import { InMemoryTransport, LATEST_PROTOCOL_VERSION } from '@modelcontextprotocol/core';
3+
import { Server } from '../../src/server/server.js';
4+
5+
describe('Server', () => {
6+
describe('_oninitialize', () => {
7+
it('should propagate negotiated protocol version to transport', async () => {
8+
const server = new Server({ name: 'test', version: '1.0.0' }, { capabilities: {} });
9+
10+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
11+
12+
const setProtocolVersion = vi.fn();
13+
(serverTransport as { setProtocolVersion?: (version: string) => void }).setProtocolVersion = setProtocolVersion;
14+
15+
await server.connect(serverTransport);
16+
17+
// Collect response from the server
18+
const responsePromise = new Promise<JSONRPCMessage>(resolve => {
19+
clientTransport.onmessage = msg => resolve(msg);
20+
});
21+
await clientTransport.start();
22+
23+
// Send initialize request directly
24+
await clientTransport.send({
25+
jsonrpc: '2.0',
26+
id: 1,
27+
method: 'initialize',
28+
params: {
29+
protocolVersion: LATEST_PROTOCOL_VERSION,
30+
capabilities: {},
31+
clientInfo: { name: 'test-client', version: '1.0.0' }
32+
}
33+
} as JSONRPCMessage);
34+
35+
await responsePromise;
36+
37+
expect(setProtocolVersion).toHaveBeenCalledWith(LATEST_PROTOCOL_VERSION);
38+
39+
await server.close();
40+
});
41+
});
42+
});

0 commit comments

Comments
 (0)