Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/remove-websocket-transport.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@modelcontextprotocol/client': major
---

Remove `WebSocketClientTransport`. WebSocket is not a spec-defined transport; use stdio or Streamable HTTP. The `Transport` interface remains exported for custom implementations. See #142.
3 changes: 2 additions & 1 deletion docs/migration-SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Replace all `@modelcontextprotocol/sdk/...` imports using this table.
| `@modelcontextprotocol/sdk/client/streamableHttp.js` | `@modelcontextprotocol/client` |
| `@modelcontextprotocol/sdk/client/sse.js` | `@modelcontextprotocol/client` |
| `@modelcontextprotocol/sdk/client/stdio.js` | `@modelcontextprotocol/client` |
| `@modelcontextprotocol/sdk/client/websocket.js` | `@modelcontextprotocol/client` |
| `@modelcontextprotocol/sdk/client/websocket.js` | REMOVED (use Streamable HTTP or stdio; implement `Transport` for custom needs) |

### Server imports

Expand Down Expand Up @@ -96,6 +96,7 @@ Notes:
| `ErrorCode.RequestTimeout` | `SdkErrorCode.RequestTimeout` |
| `ErrorCode.ConnectionClosed` | `SdkErrorCode.ConnectionClosed` |
| `StreamableHTTPError` | REMOVED (use `SdkError` with `SdkErrorCode.ClientHttp*`) |
| `WebSocketClientTransport` | REMOVED (use `StreamableHTTPClientTransport` or `StdioClientTransport`) |

All other symbols from `@modelcontextprotocol/sdk/types.js` retain their original names (e.g., `CallToolResultSchema`, `ListToolsResultSchema`, etc.).

Expand Down
20 changes: 20 additions & 0 deletions docs/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,26 @@ const transport = new NodeStreamableHTTPServerTransport({ sessionIdGenerator: ()

The SSE transport has been removed from the server. Servers should migrate to Streamable HTTP. The client-side SSE transport remains available for connecting to legacy SSE servers.

### `WebSocketClientTransport` removed

`WebSocketClientTransport` has been removed. WebSocket is not a spec-defined MCP transport, and keeping it in the SDK encouraged transport proliferation without a conformance baseline.

Use `StdioClientTransport` for local servers or `StreamableHTTPClientTransport` for remote servers. If you need WebSocket for a custom deployment, implement the `Transport` interface directly — it remains exported from `@modelcontextprotocol/client`.

**Before (v1):**

```typescript
import { WebSocketClientTransport } from '@modelcontextprotocol/sdk/client/websocket.js';
const transport = new WebSocketClientTransport(new URL('ws://localhost:3000'));
```

**After (v2):**

```typescript
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/client';
const transport = new StreamableHTTPClientTransport(new URL('http://localhost:3000/mcp'));
```

### Server auth removed

Server-side OAuth/auth has been removed entirely from the SDK. This includes `mcpAuthRouter`, `OAuthServerProvider`, `OAuthTokenVerifier`, `requireBearerAuth`, `authenticateClient`, `ProxyOAuthServerProvider`, `allowedMethods`, and all associated types.
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"@types/express-serve-static-core": "catalog:devTools",
"@types/node": "^24.10.1",
"@types/supertest": "catalog:devTools",
"@types/ws": "catalog:devTools",
"@typescript/native-preview": "catalog:devTools",
"eslint": "catalog:devTools",
"eslint-config-prettier": "catalog:devTools",
Expand All @@ -75,7 +74,6 @@
"typescript": "catalog:devTools",
"typescript-eslint": "catalog:devTools",
"vitest": "catalog:devTools",
"ws": "catalog:devTools",
"zod": "catalog:runtimeShared"
},
"resolutions": {
Expand Down
74 changes: 0 additions & 74 deletions packages/client/src/client/websocket.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export type { StdioServerParameters } from './client/stdio.js';
export { DEFAULT_INHERITED_ENV_VARS, getDefaultEnvironment, StdioClientTransport } from './client/stdio.js';
export type { StartSSEOptions, StreamableHTTPClientTransportOptions, StreamableHTTPReconnectionOptions } from './client/streamableHttp.js';
export { StreamableHTTPClientTransport } from './client/streamableHttp.js';
export { WebSocketClientTransport } from './client/websocket.js';

// experimental exports
export { ExperimentalClientTasks } from './experimental/tasks/client.js';
Expand Down
33 changes: 0 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ catalogs:
'@types/express': ^5.0.6
'@types/express-serve-static-core': ^5.1.0
'@types/supertest': ^6.0.2
'@types/ws': ^8.5.12
'@typescript/native-preview': ^7.0.0-dev.20251217.1
eslint: ^9.39.2
eslint-config-prettier: ^10.1.8
Expand All @@ -32,7 +31,6 @@ catalogs:
typescript-eslint: ^8.48.1
vite-tsconfig-paths: ^5.1.4
vitest: ^4.0.15
ws: ^8.18.0
runtimeClientOnly:
cross-spawn: ^7.0.5
eventsource: ^3.0.2
Expand Down
8 changes: 1 addition & 7 deletions scripts/cli.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import WebSocket from 'ws';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(global as any).WebSocket = WebSocket;

import express from 'express';
import { Client } from '../src/client/index.js';
import { SSEClientTransport } from '../src/client/sse.js';
import { StdioClientTransport } from '../src/client/stdio.js';
import { WebSocketClientTransport } from '../src/client/websocket.js';
import { Server } from '../src/server/index.js';
Comment thread
claude[bot] marked this conversation as resolved.
import { SSEServerTransport } from '../src/server/sse.js';
import { StdioServerTransport } from '../src/server/stdio.js';
Expand Down Expand Up @@ -38,7 +32,7 @@ async function runClient(url_or_command: string, args: string[]) {
if (url?.protocol === 'http:' || url?.protocol === 'https:') {
clientTransport = new SSEClientTransport(new URL(url_or_command));
} else if (url?.protocol === 'ws:' || url?.protocol === 'wss:') {
clientTransport = new WebSocketClientTransport(new URL(url_or_command));
throw new Error('WebSocket URLs are no longer supported. Use http(s) or stdio instead.');
} else {
clientTransport = new StdioClientTransport({
command: url_or_command,
Comment thread
claude[bot] marked this conversation as resolved.
Expand Down
Loading