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
Copy file name to clipboardExpand all lines: .changeset/spec-type-schema.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,4 +3,4 @@
3
3
'@modelcontextprotocol/server': minor
4
4
---
5
5
6
-
Export `isSpecType` and `specTypeSchemas` records for runtime validation of any MCP spec type by name. `isSpecType.ContentBlock(value)` is a type predicate; `specTypeSchemas.ContentBlock` is a `StandardSchemaV1<ContentBlock>` validator. Guards are standalone functions, so `arr.filter(isSpecType.ContentBlock)` works. Also export the `SpecTypeName`and `SpecTypes` types.
6
+
Export `isSpecType` and `specTypeSchemas` records for runtime validation of any MCP spec type by name. `isSpecType.ContentBlock(value)` is a type predicate; `specTypeSchemas.ContentBlock` is a `StandardSchemaV1Sync<ContentBlock>` validator — `validate()` returns the result synchronously. Guards are standalone functions, so `arr.filter(isSpecType.ContentBlock)` works. Also export the `SpecTypeName`, `SpecTypes`, and `StandardSchemaV1Sync` types.
Copy file name to clipboardExpand all lines: README.md
+17-13Lines changed: 17 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,15 @@
1
1
# MCP TypeScript SDK
2
2
3
-
> [!IMPORTANT]**This is the `main` branch which contains v2 of the SDK (currently in development, pre-alpha).**
3
+
<!-- prettier-ignore -->
4
+
> [!IMPORTANT]
5
+
> **This is the `main` branch which contains v2 of the SDK (currently in development, pre-alpha).**
4
6
>
5
7
> We anticipate a stable v2 release in Q1 2026. Until then, **v1.x remains the recommended version** for production use. v1.x will continue to receive bug fixes and security updates for at least 6 months after v2 ships to give people time to upgrade.
6
8
>
7
9
> For v1 documentation, see the [V1 API docs](https://ts.sdk.modelcontextprotocol.io/). For v2 API docs, see [`/v2/`](https://ts.sdk.modelcontextprotocol.io/v2/).
[](https://www.npmjs.com/package/@modelcontextprotocol/server)
12
+
[](https://www.npmjs.com/package/@modelcontextprotocol/client)
10
13
11
14
<details>
12
15
<summary>Table of Contents</summary>
@@ -102,19 +105,19 @@ import * as z from 'zod/v4';
102
105
const server =newMcpServer({ name: 'greeting-server', version: '1.0.0' });
@@ -125,7 +128,8 @@ Ready to build something real? Follow the step-by-step quickstart tutorials:
125
128
-[Build a weather server](docs/server-quickstart.md) — server quickstart
126
129
-[Build an LLM-powered chatbot](docs/client-quickstart.md) — client quickstart
127
130
128
-
The complete code for each tutorial is in [`examples/server-quickstart/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/examples/server-quickstart/) and [`examples/client-quickstart/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/examples/client-quickstart/). For more advanced runnable examples, see:
131
+
The complete code for each tutorial is in [`examples/server-quickstart/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/examples/server-quickstart/) and
132
+
[`examples/client-quickstart/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/examples/client-quickstart/). For more advanced runnable examples, see:
129
133
130
134
-[`examples/server/README.md`](examples/server/README.md) — server examples index
131
135
-[`examples/client/README.md`](examples/client/README.md) — client examples index
|`StreamableHTTPError`| REMOVED (use `SdkError` with `SdkErrorCode.ClientHttp*`)|
98
+
|`StreamableHTTPError`| REMOVED (use `SdkHttpError` with `SdkErrorCode.ClientHttp*`) |
99
99
|`WebSocketClientTransport`| REMOVED (use `StreamableHTTPClientTransport` or `StdioClientTransport`) |
100
100
101
101
All other **type** symbols from `@modelcontextprotocol/sdk/types.js` retain their original names. **Zod schemas** (e.g., `CallToolResultSchema`, `ListToolsResultSchema`) are no longer part of the public API — they are internal to the SDK. For runtime validation, use
102
-
`isSpecType.TypeName(value)` (e.g., `isSpecType.CallToolResult(v)`) or `specTypeSchemas.TypeName` for the `StandardSchemaV1` validator object. The keys are typed as `SpecTypeName`, a literal union of all spec type names.
102
+
`isSpecType.TypeName(value)` (e.g., `isSpecType.CallToolResult(v)`) or `specTypeSchemas.TypeName` for the `StandardSchemaV1Sync` validator object. The keys are typed as `SpecTypeName`, a literal union of all spec type names.
103
103
104
104
### Error class changes
105
105
106
-
Two error classes now exist:
106
+
Three error classes now exist:
107
107
108
108
-**`ProtocolError`** (renamed from `McpError`): Protocol errors that cross the wire as JSON-RPC responses
109
109
-**`SdkError`** (new): Local SDK errors that never cross the wire
110
+
-**`SdkHttpError`** (extends `SdkError`): HTTP transport errors with typed `.status` and `.statusText` accessors
const result =awaitspecTypeSchemas.CallToolResult['~standard'].validate(value);
510
+
const result =specTypeSchemas.CallToolResult['~standard'].validate(value);
511
511
```
512
512
513
-
`isSpecType` and `specTypeSchemas` are keyed by `SpecTypeName` — a literal union of every named type in the MCP spec — so you get autocomplete and a compile error on typos. `specTypeSchemas.X` is a `StandardSchemaV1<In, Out>`, which composes with any Standard-Schema-aware library. The pre-existing `isCallToolResult(value)` guard still works.
513
+
`isSpecType` and `specTypeSchemas` are keyed by `SpecTypeName` — a literal union of every named type in the MCP spec — so you get autocomplete and a compile error on typos. `specTypeSchemas.X` is a `StandardSchemaV1Sync<In, Out>` — `validate()` returns the result synchronously, so you can access `.issues` / `.value` without `await`. It composes with any Standard-Schema-aware library. The pre-existing `isCallToolResult(value)` guard still works.
514
514
515
515
### Client list methods return empty results for missing capabilities
516
516
@@ -652,10 +652,11 @@ These replace the pattern of calling `server.sendLoggingMessage()`, `server.crea
652
652
653
653
### Error hierarchy refactoring
654
654
655
-
The SDK now distinguishes between two types of errors:
655
+
The SDK now distinguishes between three types of errors:
656
656
657
657
1.**`ProtocolError`** (renamed from `McpError`): Protocol errors that cross the wire as JSON-RPC error responses
658
658
2.**`SdkError`**: Local SDK errors that never cross the wire (timeouts, connection issues, capability checks)
659
+
3.**`SdkHttpError`** (extends `SdkError`): HTTP transport errors with typed `.status` and `.statusText` accessors
659
660
660
661
#### Renamed exports
661
662
@@ -725,7 +726,7 @@ The new `SdkErrorCode` enum contains string-valued codes for local SDK errors:
725
726
726
727
#### `StreamableHTTPError` removed
727
728
728
-
The `StreamableHTTPError` class has been removed. HTTP transport errors are now thrown as `SdkError` with specific `SdkErrorCode` values that provide more granular error information:
729
+
The `StreamableHTTPError` class has been removed. HTTP transport errors are now thrown as `SdkHttpError` (a subclass of `SdkError` with typed `.status` and `.statusText` accessors) with specific `SdkErrorCode` values that provide more granular error information:
Copy file name to clipboardExpand all lines: packages/client/README.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,13 @@
2
2
3
3
The MCP (Model Context Protocol) TypeScript client SDK. Build MCP clients that connect to MCP servers.
4
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.
5
+
<!-- prettier-ignore -->
6
+
> [!WARNING]
7
+
> **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
8
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.
9
+
<!-- prettier-ignore -->
10
+
> [!NOTE]
11
+
> 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.
0 commit comments