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
Support Standard Schema for tool and prompt schemas
8
+
9
+
Tool and prompt registration now accepts any schema library that implements the [Standard Schema spec](https://standardschema.dev/): Zod v4, Valibot, ArkType, and others. `RegisteredTool.inputSchema`, `RegisteredTool.outputSchema`, and `RegisteredPrompt.argsSchema` now use `StandardSchemaWithJSON` (requires both `~standard.validate` and `~standard.jsonSchema`) instead of the Zod-specific `AnySchema` type.
10
+
11
+
**Zod v4 schemas continue to work unchanged** — Zod v4 implements the required interfaces natively.
-`experimental.tasks.getTaskResult()` no longer accepts a `resultSchema` parameter. Returns `GetTaskPayloadResult` (a loose `Result`); cast to the expected type at the call site.
33
+
- Removed unused exports from `@modelcontextprotocol/core`: `SchemaInput`, `schemaToJson`, `parseSchemaAsync`, `getSchemaShape`, `getSchemaDescription`, `isOptionalSchema`, `unwrapOptionalSchema`. Use the new `standardSchemaToJsonSchema` and `validateStandardSchema` instead.
34
+
-`completable()` remains Zod-specific (it relies on Zod's `.shape` introspection).
Copy file name to clipboardExpand all lines: docs/client.md
+47Lines changed: 47 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,8 @@ import {
19
19
Client,
20
20
ClientCredentialsProvider,
21
21
createMiddleware,
22
+
CrossAppAccessProvider,
23
+
discoverAndRequestJwtAuthGrant,
22
24
PrivateKeyJwtProvider,
23
25
ProtocolError,
24
26
SdkError,
@@ -152,6 +154,51 @@ For user-facing applications, implement the {@linkcode @modelcontextprotocol/cli
152
154
153
155
For a complete working OAuth flow, see [`simpleOAuthClient.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/simpleOAuthClient.ts) and [`simpleOAuthClientProvider.ts`](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/examples/client/src/simpleOAuthClientProvider.ts).
{@linkcode@modelcontextprotocol/client!client/authExtensions.CrossAppAccessProvider | CrossAppAccessProvider} implements Enterprise Managed Authorization (SEP-990) for scenarios where users authenticate with an enterprise identity provider (IdP) and clients need to access protected MCP servers on their behalf.
160
+
161
+
This provider handles a two-step OAuth flow:
162
+
1. Exchange the user's ID Token from the enterprise IdP for a JWT Authorization Grant (JAG) via RFC 8693 token exchange
163
+
2. Exchange the JAG for an access token from the MCP server via RFC 7523 JWT bearer grant
const result =awaitdiscoverAndRequestJwtAuthGrant({
170
+
idpUrl: 'https://idp.example.com',
171
+
audience: ctx.authorizationServerUrl,
172
+
resource: ctx.resourceUrl,
173
+
idToken: awaitgetIdToken(),
174
+
clientId: 'my-idp-client',
175
+
clientSecret: 'my-idp-secret',
176
+
scope: ctx.scope,
177
+
fetchFn: ctx.fetchFn
178
+
});
179
+
returnresult.jwtAuthGrant;
180
+
},
181
+
clientId: 'my-mcp-client',
182
+
clientSecret: 'my-mcp-secret'
183
+
});
184
+
185
+
const transport =newStreamableHTTPClientTransport(newURL('http://localhost:3000/mcp'), { authProvider });
186
+
```
187
+
188
+
The `assertion` callback receives a context object with:
189
+
-`authorizationServerUrl` – The MCP server's authorization server (discovered automatically)
190
+
-`resourceUrl` – The MCP resource URL (discovered automatically)
191
+
-`scope` – Optional scope passed to `auth()` or from `clientMetadata`
192
+
-`fetchFn` – Fetch implementation to use for HTTP requests
193
+
194
+
For manual control over the token exchange steps, use the Layer 2 utilities from `@modelcontextprotocol/client`:
195
+
-`requestJwtAuthorizationGrant()` – Exchange ID Token for JAG at IdP
196
+
-`discoverAndRequestJwtAuthGrant()` – Discovery + JAG acquisition
197
+
-`exchangeJwtAuthGrant()` – Exchange JAG for access token at MCP server
198
+
199
+
> [!NOTE]
200
+
> See [RFC 8693 (Token Exchange)](https://datatracker.ietf.org/doc/html/rfc8693), [RFC 7523 (JWT Bearer Grant)](https://datatracker.ietf.org/doc/html/rfc7523), and [RFC 9728 (Resource Discovery)](https://datatracker.ietf.org/doc/html/rfc9728) for the underlying OAuth standards.
201
+
155
202
## Tools
156
203
157
204
Tools are callable actions offered by servers — discovering and invoking them is usually how your client enables an LLM to take action (see [Tools](https://modelcontextprotocol.io/docs/learn/server-concepts#tools) in the MCP overview).
The variadic `.tool()`, `.prompt()`, `.resource()` methods are removed. Use the `register*` methods with a config object.
211
211
212
-
**IMPORTANT**: v2 requires full Zod schemas — raw shapes like `{ name: z.string() }` are no longer supported. You must wrap with `z.object()`. This applies to `inputSchema`, `outputSchema`, and `argsSchema`.
212
+
**IMPORTANT**: v2 requires schema objects implementing [Standard Schema](https://standardschema.dev/)— raw shapes like `{ name: z.string() }` are no longer supported. Wrap with `z.object()` (Zod v4), or use ArkType's `type({...})`, or Valibot. For raw JSON Schema, wrap with `fromJsonSchema(schema, validator)` from `@modelcontextprotocol/core`. Applies to `inputSchema`, `outputSchema`, and `argsSchema`.
213
213
214
214
### Tools
215
215
@@ -279,13 +279,22 @@ Note: the third argument (`metadata`) is required — pass `{}` if no metadata.
### Zod schemas required (raw shapes no longer supported)
223
+
### Standard Schema objects required (raw shapes no longer supported)
224
224
225
-
v2 requires full Zod schemas for `inputSchema`and `argsSchema`. Raw object shapes are no longer accepted.
225
+
v2 requires schema objects implementing the [Standard Schema spec](https://standardschema.dev/)for `inputSchema`, `outputSchema`, and `argsSchema`. Raw object shapes are no longer accepted. Zod v4, ArkType, and Valibot all implement the spec.
|`getSchemaShape`, `getSchemaDescription`, `isOptionalSchema`, `unwrapOptionalSchema`| No replacement — these are now internal Zod introspection helpers |
279
+
259
280
### Host header validation moved
260
281
261
282
Express-specific middleware (`hostHeaderValidation()`, `localhostHostValidation()`) moved from the server package to `@modelcontextprotocol/express`. The server package now exports framework-agnostic functions instead: `validateHostHeader()`, `localhostAllowedHostnames()`,
0 commit comments