Skip to content

Commit 8695e01

Browse files
Merge branch 'main' into patch-1
2 parents 95ef3c9 + c4ee360 commit 8695e01

File tree

97 files changed

+7450
-924
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+7450
-924
lines changed

.changeset/config.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@
77
"access": "public",
88
"baseBranch": "main",
99
"updateInternalDependencies": "patch",
10-
"ignore": ["@modelcontextprotocol/examples-client", "@modelcontextprotocol/examples-server", "@modelcontextprotocol/examples-shared"]
10+
"ignore": [
11+
"@modelcontextprotocol/examples-client",
12+
"@modelcontextprotocol/examples-client-quickstart",
13+
"@modelcontextprotocol/examples-server",
14+
"@modelcontextprotocol/examples-server-quickstart",
15+
"@modelcontextprotocol/examples-shared"
16+
]
1117
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@modelcontextprotocol/client': minor
3+
---
4+
5+
Add `discoverOAuthServerInfo()` function and unified discovery state caching for OAuth
6+
7+
- New `discoverOAuthServerInfo(serverUrl)` export that performs RFC 9728 protected resource metadata discovery followed by authorization server metadata discovery in a single call. Use this for operations like token refresh and revocation that need the authorization server URL outside of `auth()`.
8+
- New `OAuthDiscoveryState` type and optional `OAuthClientProvider` methods `saveDiscoveryState()` / `discoveryState()` allow providers to persist all discovery results (auth server URL, resource metadata URL, resource metadata, auth server metadata) across sessions. This avoids redundant discovery requests and handles browser redirect scenarios where discovery state would otherwise be lost.
9+
- New `'discovery'` scope for `invalidateCredentials()` to clear cached discovery state.
10+
- New `OAuthServerInfo` type exported for the return value of `discoverOAuthServerInfo()`.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Temporary files
2+
tmp/
3+
14
# Logs
25
logs
36
*.log

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ pnpm-lock.yaml
1111

1212
# Ignore generated files
1313
src/spec.types.ts
14+
15+
# Quickstart examples uses 2-space indent to match ecosystem conventions
16+
examples/client-quickstart/
17+
examples/server-quickstart/

CLAUDE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ Include what changed, why, and how to migrate. Search for related sections and g
4141
- **Testing**: Co-locate tests with source files, use descriptive test names
4242
- **Comments**: JSDoc for public APIs, inline comments for complex logic
4343

44+
### JSDoc `@example` Code Snippets
45+
46+
JSDoc `@example` tags should pull type-checked code from companion `.examples.ts` files (e.g., `client.ts``client.examples.ts`). Use `` ```ts source="./file.examples.ts#regionName" `` fences referencing `//#region regionName` blocks; region names follow `exportedName_variant` or `ClassName_methodName_variant` pattern (e.g., `applyMiddlewares_basicUsage`, `Client_connect_basicUsage`). For whole-file inclusion (any file type), omit the `#regionName`.
47+
48+
Run `pnpm sync:snippets` to sync example content into JSDoc comments and markdown files.
49+
4450
## Architecture Overview
4551

4652
### Core Layers

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This repository contains the TypeScript SDK implementation of the MCP specificat
3030
- MCP **server** libraries (tools/resources/prompts, Streamable HTTP, stdio, auth helpers)
3131
- MCP **client** libraries (transports, high-level helpers, OAuth helpers)
3232
- Optional **middleware packages** for specific runtimes/frameworks (Express, Hono, Node.js HTTP)
33-
- Runnable **examples** (under [`examples/`](examples/))
33+
- Runnable **examples** (under [`examples/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/examples))
3434

3535
## Packages
3636

@@ -43,7 +43,7 @@ Both packages have a **required peer dependency** on `zod` for schema validation
4343

4444
### Middleware packages (optional)
4545

46-
The SDK also publishes small middleware packages under [`packages/middleware/`](packages/middleware/) that help you **wire MCP into a specific runtime or web framework**.
46+
The SDK also publishes small "middleware" packages under [`packages/middleware/`](https://github.com/modelcontextprotocol/typescript-sdk/tree/main/packages/middleware) that help you **wire MCP into a specific runtime or web framework**.
4747

4848
They are intentionally thin adapters: they should not introduce new MCP functionality or business logic. See [`packages/middleware/README.md`](packages/middleware/README.md) for details.
4949

@@ -127,10 +127,9 @@ Next steps:
127127
## Documentation
128128

129129
- Local SDK docs:
130-
- [docs/server.md](docs/server.md) – building MCP servers, transports, tools/resources/prompts, CORS, DNS rebinding, and deployment patterns.
131-
- [docs/client.md](docs/client.md) – using the high-level client, transports, backwards compatibility, and OAuth helpers.
132-
- [docs/capabilities.md](docs/capabilities.md) – sampling, elicitation (form and URL), and experimental task-based execution.
133-
- [docs/faq.md](docs/faq.md) – environment and troubleshooting FAQs (including Node.js Web Crypto support).
130+
- [docs/server.md](docs/server.md) – building MCP servers, transports, tools/resources/prompts, sampling, elicitation, tasks, and deployment patterns.
131+
- [docs/client.md](docs/client.md) – building MCP clients: connecting, tools, resources, prompts, server-initiated requests, and error handling
132+
- [docs/faq.md](docs/faq.md) – frequently asked questions and troubleshooting
134133
- External references:
135134
- [SDK API documentation](https://modelcontextprotocol.github.io/typescript-sdk/)
136135
- [Model Context Protocol documentation](https://modelcontextprotocol.io)

SECURITY.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
# Security Policy
22

3-
Thank you for helping us keep the SDKs and systems they interact with secure.
3+
Thank you for helping keep the Model Context Protocol and its ecosystem secure.
44

55
## Reporting Security Issues
66

7-
This SDK is maintained by [Anthropic](https://www.anthropic.com/) as part of the Model Context Protocol project.
7+
If you discover a security vulnerability in this repository, please report it through
8+
the [GitHub Security Advisory process](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability)
9+
for this repository.
810

9-
The security of our systems and user data is Anthropic’s top priority. We appreciate the work of security researchers acting in good faith in identifying and reporting potential vulnerabilities.
11+
Please **do not** report security vulnerabilities through public GitHub issues, discussions,
12+
or pull requests.
1013

11-
Our security program is managed on HackerOne and we ask that any validated vulnerability in this functionality be reported through their [submission form](https://hackerone.com/anthropic-vdp/reports/new?type=team&report_type=vulnerability).
14+
## What to Include
1215

13-
## Vulnerability Disclosure Program
16+
To help us triage and respond quickly, please include:
1417

15-
Our Vulnerability Program Guidelines are defined on our [HackerOne program page](https://hackerone.com/anthropic-vdp).
18+
- A description of the vulnerability
19+
- Steps to reproduce the issue
20+
- The potential impact
21+
- Any suggested fixes (optional)

common/eslint-config/eslint.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ export default defineConfig(
8686
'unicorn/consistent-function-scoping': 'off'
8787
}
8888
},
89+
{
90+
// Example files contain intentionally unused functions (one per region)
91+
files: ['**/*.examples.ts'],
92+
rules: {
93+
'@typescript-eslint/no-unused-vars': 'off',
94+
'no-console': 'off'
95+
}
96+
},
8997
{
9098
// Ignore generated protocol types everywhere
9199
ignores: ['**/spec.types.ts']

docs/capabilities.md

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)