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: README.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@
25
25
26
26
The Model Context Protocol (MCP) allows applications to provide context for LLMs in a standardized way, separating the concerns of providing context from the actual LLM interaction.
27
27
28
-
This repository contains the TypeScript SDK implementation of the MCP specification and ships:
28
+
This repository contains the TypeScript SDK implementation of the MCP specification. It runs on **Node.js**, **Bun**, and **Deno**, and ships:
Copy file name to clipboardExpand all lines: docs/client-quickstart.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,10 +19,13 @@ This quickstart assumes you have familiarity with:
19
19
20
20
Before starting, ensure your system meets these requirements:
21
21
22
-
- Node.js 20 or higher installed
22
+
- Node.js 20 or higher installed (or **Bun** / **Deno** — the SDK supports all three runtimes)
23
23
- Latest version of `npm` installed
24
24
- An Anthropic API key from the [Anthropic Console](https://console.anthropic.com/settings/keys)
25
25
26
+
> [!TIP]
27
+
> This tutorial uses Node.js and npm, but you can substitute `bun` or `deno` commands where appropriate. For example, use `bun add` instead of `npm install`, or run the client with `bun run` / `deno run`.
28
+
26
29
## Set up your environment
27
30
28
31
First, let's create and set up our project:
@@ -109,7 +112,7 @@ First, let's set up our imports and create the basic client class in `src/index.
@@ -153,6 +154,51 @@ For user-facing applications, implement the {@linkcode @modelcontextprotocol/cli
153
154
154
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
+
156
202
## Tools
157
203
158
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).
@@ -198,13 +244,16 @@ if (result.structuredContent) {
198
244
Pass `onprogress` to receive incremental progress notifications from long-running tools. Use `resetTimeoutOnProgress` to keep the request alive while the server is actively reporting, and `maxTotalTimeout` as an absolute cap:
|`ctx.mcpReq.elicitInput(params, options?)`| Elicit user input (form or URL) |`server.elicitInput(...)` from within handler |
397
397
|`ctx.mcpReq.requestSampling(params, options?)`| Request LLM sampling from client |`server.createMessage(...)` from within handler |
398
398
399
-
## 11. Client Behavioral Changes
399
+
## 11. Schema parameter removed from `request()`, `send()`, and `callTool()`
400
+
401
+
`Protocol.request()`, `BaseContext.mcpReq.send()`, and `Client.callTool()` no longer take a Zod result schema argument. The SDK resolves the schema internally from the method name.
Remove unused schema imports: `CallToolResultSchema`, `CompatibilityCallToolResultSchema`, `ElicitResultSchema`, `CreateMessageResultSchema`, etc., when they were only used in `request()`/`send()`/`callTool()` calls.
426
+
427
+
## 12. Client Behavioral Changes
400
428
401
429
`Client.listPrompts()`, `listResources()`, `listResourceTemplates()`, `listTools()` now return empty results when the server lacks the corresponding capability (instead of sending the request). Set `enforceStrictCapabilities: true` in `ClientOptions` to throw an error instead.
2. Replace all imports from `@modelcontextprotocol/sdk/...` using the import mapping tables (sections 3-4), including `StreamableHTTPServerTransport` → `NodeStreamableHTTPServerTransport`
### `Protocol.request()`, `ctx.mcpReq.send()`, and `Client.callTool()` no longer take a schema parameter
341
+
342
+
The public `Protocol.request()`, `BaseContext.mcpReq.send()`, and `Client.callTool()` methods no longer accept a Zod result schema argument. The SDK now resolves the correct result schema internally based on the method name. This means you no longer need to import result schemas like `CallToolResultSchema` or `ElicitResultSchema` when making requests.
const result =awaitclient.callTool({ name: 'my-tool', arguments: {} });
403
+
```
404
+
405
+
The return type is now inferred from the method name via `ResultTypeMap`. For example, `client.request({ method: 'tools/call', ... })` returns `Promise<CallToolResult | CreateTaskResult>`.
406
+
340
407
### Client list methods return empty results for missing capabilities
341
408
342
409
`Client.listPrompts()`, `listResources()`, `listResourceTemplates()`, and `listTools()` now return empty results when the server didn't advertise the corresponding capability, instead of sending the request. This respects the MCP spec's capability negotiation.
0 commit comments