You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Split protocol types into a standalone mcp-types package
Extract the wire types from `src/mcp/types/` into a separate distribution,
`mcp-types` (imported as `mcp_types`), wired into the uv workspace. The new
package depends only on pydantic, so tooling and lightweight clients can
(de)serialize MCP traffic without the full server/transport stack.
`mcp.shared.version` moves to `mcp_types.version` (a pure leaf with no `mcp`
deps), which lets `mcp_types` depend on nothing in `mcp`. The `mcp.types`
submodule and `mcp.shared.version` are removed; `mcp` re-exports the type
names at the top level, so `from mcp import Tool` is unchanged. All importers
are rewritten to `mcp_types`. Documented in docs/migration.md.
Copy file name to clipboardExpand all lines: docs/migration.md
+51-22Lines changed: 51 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -209,9 +209,38 @@ named `mcp.os.win32.utilities` (was `client.stdio.win32`).
209
209
210
210
The WebSocket transport has been removed: `mcp.client.websocket.websocket_client`, `mcp.server.websocket.websocket_server`, and the `ws` optional dependency extra (`mcp[ws]`) no longer exist. WebSocket was never part of the MCP specification. Use the streamable HTTP transport instead (`mcp.client.streamable_http.streamable_http_client` on the client, `streamable_http_app()` on the server), which supports bidirectional communication with server-to-client streaming over standard HTTP.
211
211
212
+
### `mcp.types` moved to the `mcp-types` package
213
+
214
+
The protocol wire types now live in a standalone distribution, `mcp-types`, imported as
215
+
`mcp_types`. It depends only on `pydantic`, so code that just needs to (de)serialize MCP
216
+
traffic can install it without the full SDK. The `mcp` package depends on `mcp-types` and
217
+
continues to re-export the type names at the top level, so `from mcp import Tool` is
218
+
unchanged. Only the `mcp.types` submodule and `mcp.shared.version` were removed.
219
+
220
+
**Why:** keeping the wire types in their own package lets tooling and lightweight clients
221
+
depend on the protocol schema without pulling in `httpx`, `starlette`, `uvicorn`, and the
222
+
rest of the server/transport stack.
223
+
224
+
**Before (v1):**
225
+
226
+
```python
227
+
from mcp.types import Tool, CallToolResult
228
+
from mcp.shared.version importLATEST_PROTOCOL_VERSION
229
+
```
230
+
231
+
**After (v2):**
232
+
233
+
```python
234
+
from mcp_types import Tool, CallToolResult
235
+
from mcp_types.version importLATEST_PROTOCOL_VERSION
236
+
237
+
# Top-level re-exports are unchanged:
238
+
from mcp import Tool, CallToolResult
239
+
```
240
+
212
241
### Removed type aliases and classes
213
242
214
-
The following deprecated type aliases and classes have been removed from `mcp.types`:
243
+
The following deprecated type aliases and classes have been removed from `mcp_types`:
215
244
216
245
| Removed | Replacement |
217
246
|---------|-------------|
@@ -231,13 +260,13 @@ from mcp.types import Content, ResourceReference, Cursor
# Use `str` instead of `Cursor` for pagination cursors
236
265
```
237
266
238
267
### Field names changed from camelCase to snake_case
239
268
240
-
All Pydantic model fields in `mcp.types` now use snake_case names for Python attribute access. The JSON wire format is unchanged — serialization still uses camelCase via Pydantic aliases.
269
+
All Pydantic model fields in `mcp_types` now use snake_case names for Python attribute access. The JSON wire format is unchanged — serialization still uses camelCase via Pydantic aliases.
241
270
242
271
**Before (v1):**
243
272
@@ -287,7 +316,7 @@ Results returned from server handlers are now validated against the negotiated p
287
316
288
317
### Client validates inbound traffic against the protocol schema
289
318
290
-
`ClientSession` now validates server requests, notifications, and results against the negotiated protocol version's schema before parsing them into `mcp.types` models. Spec-invalid server output that the previous monolith parse tolerated may now raise `pydantic.ValidationError` from `list_tools()`, `call_tool()`, and similar calls. `_meta` remains the sanctioned place for result extras (and `experimental` for capability extras).
319
+
`ClientSession` now validates server requests, notifications, and results against the negotiated protocol version's schema before parsing them into `mcp_types` models. Spec-invalid server output that the previous monolith parse tolerated may now raise `pydantic.ValidationError` from `list_tools()`, `call_tool()`, and similar calls. `_meta` remains the sanctioned place for result extras (and `experimental` for capability extras).
291
320
292
321
### `args` parameter removed from `ClientSessionGroup.call_tool()`
293
322
@@ -326,7 +355,7 @@ result = await session.list_tools(cursor="next_page_token")
326
355
**After (v2):**
327
356
328
357
```python
329
-
frommcp.typesimport PaginatedRequestParams
358
+
frommcp_typesimport PaginatedRequestParams
330
359
331
360
result =await session.list_resources(params=PaginatedRequestParams(cursor="next_page_token"))
332
361
result =await session.list_tools(params=PaginatedRequestParams(cursor="next_page_token"))
@@ -402,7 +431,7 @@ The constructor signature also changed — it now takes `code`, `message`, and o
Tasks (SEP-1686) have been removed from the MCP specification and are no longer part of this SDK. The `mcp.client.experimental`, `mcp.server.experimental`, `mcp.shared.experimental`, and `mcp.server.lowlevel.experimental` modules have been removed, along with the `experimental` properties on `ClientSession`, `ServerSession`, `Server`, and `ServerRequestContext`. The corresponding `Task*` types remain in `mcp.types` as types-only definitions.
1318
+
Tasks (SEP-1686) have been removed from the MCP specification and are no longer part of this SDK. The `mcp.client.experimental`, `mcp.server.experimental`, `mcp.shared.experimental`, and `mcp.server.lowlevel.experimental` modules have been removed, along with the `experimental` properties on `ClientSession`, `ServerSession`, `Server`, and `ServerRequestContext`. The corresponding `Task*` types remain in `mcp_types` as types-only definitions.
1290
1319
1291
1320
Tasks are expected to return as a separate MCP extension in a future release.
1292
1321
@@ -1354,7 +1383,7 @@ In v1, MCP protocol types were configured with `extra="allow"`: unknown fields p
1354
1383
In v2, MCP types silently ignore extra fields. Unknown constructor keyword arguments and unknown keys in wire data are dropped during validation — no error is raised, and the values do not round-trip:
1355
1384
1356
1385
```python
1357
-
frommcp.typesimport CallToolRequestParams
1386
+
frommcp_typesimport CallToolRequestParams
1358
1387
1359
1388
params = CallToolRequestParams(
1360
1389
name="my_tool",
@@ -1400,15 +1429,15 @@ Under OIDC, omitting `application_type` defaults to `"web"`, which an authorizat
1400
1429
1401
1430
### 2025-11-25 and 2026-07-28 protocol fields modeled
1402
1431
1403
-
`mcp.types` models the 2025-11-25 and 2026-07-28 protocol fields (e.g. `resultType`, `ttlMs`/`cacheScope` on cacheable results, `inputResponses`/`requestState` on retried requests), so inbound payloads carrying these keys parse into typed fields and round-trip. `ttlMs`/`cacheScope` default to `0`/`"private"` (immediately stale, not shared-cacheable); `resultType` defaults to `"complete"` on concrete results (`None` on `EmptyResult`); the server strips all of them from the wire at pre-2026 versions.
1432
+
`mcp_types` models the 2025-11-25 and 2026-07-28 protocol fields (e.g. `resultType`, `ttlMs`/`cacheScope` on cacheable results, `inputResponses`/`requestState` on retried requests), so inbound payloads carrying these keys parse into typed fields and round-trip. `ttlMs`/`cacheScope` default to `0`/`"private"` (immediately stale, not shared-cacheable); `resultType` defaults to `"complete"` on concrete results (`None` on `EmptyResult`); the server strips all of them from the wire at pre-2026 versions.
1404
1433
1405
1434
### `streamable_http_app()` available on lowlevel Server
1406
1435
1407
1436
The `streamable_http_app()` method is now available directly on the lowlevel `Server` class, not just `MCPServer`. This allows using the streamable HTTP transport without the MCPServer wrapper.
1408
1437
1409
1438
```python
1410
1439
from mcp.server import Server, ServerRequestContext
0 commit comments