Skip to content

Commit 16d1ab7

Browse files
authored
Merge branch 'main' into localden/tasks-session
2 parents 0e504fa + 0fe16dd commit 16d1ab7

Some content is hidden

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

49 files changed

+359
-194
lines changed

.github/workflows/publish-docs-manually.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ jobs:
3131
3232
- run: uv sync --frozen --group docs
3333
- run: uv run --frozen --no-sync mkdocs gh-deploy --force
34+
env:
35+
ENABLE_SOCIAL_CARDS: "true"

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)

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ watch:
112112

113113
plugins:
114114
- search
115-
- social
115+
- social:
116+
enabled: !ENV [ENABLE_SOCIAL_CARDS, false]
116117
- glightbox
117118
- mkdocstrings:
118119
handlers:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ dev = [
7575
docs = [
7676
"mkdocs>=1.6.1",
7777
"mkdocs-glightbox>=0.4.0",
78-
"mkdocs-material>=9.5.45",
78+
"mkdocs-material[imaging]>=9.5.45",
7979
"mkdocstrings-python>=2.0.1",
8080
]
8181

src/mcp/cli/cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,12 @@ def run(
317317
) -> None: # pragma: no cover
318318
"""Run an MCP server.
319319
320-
The server can be specified in two ways:\n
321-
1. Module approach: server.py - runs the module directly, expecting a server.run() call.\n
322-
2. Import approach: server.py:app - imports and runs the specified server object.\n\n
320+
The server can be specified in two ways:
321+
1. Module approach: server.py - runs the module directly, expecting a server.run() call.
322+
2. Import approach: server.py:app - imports and runs the specified server object.
323323
324324
Note: This command runs the server directly. You are responsible for ensuring
325-
all dependencies are available.\n
325+
all dependencies are available.
326326
For dependency management, use `mcp install` or `mcp dev` instead.
327327
""" # noqa: E501
328328
file, server_object = _parse_file_path(file_spec)

src/mcp/client/auth/extensions/client_credentials.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def _add_client_authentication_jwt(self, *, token_data: dict[str, Any]): # prag
450450
# When using private_key_jwt, in a client_credentials flow, we use RFC 7523 Section 2.2
451451
token_data["client_assertion"] = assertion
452452
token_data["client_assertion_type"] = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
453-
# We need to set the audience to the resource server, the audience is difference from the one in claims
453+
# We need to set the audience to the resource server, the audience is different from the one in claims
454454
# it represents the resource server that will validate the token
455455
token_data["audience"] = self.context.get_resource_url()
456456

src/mcp/client/auth/oauth2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def prepare_token_auth(
215215

216216
class OAuthClientProvider(httpx.Auth):
217217
"""OAuth2 authentication for httpx.
218+
218219
Handles OAuth flow with automatic client registration and token storage.
219220
"""
220221

@@ -241,7 +242,7 @@ def __init__(
241242
callback_handler: Handler for authorization callbacks.
242243
timeout: Timeout for the OAuth flow.
243244
client_metadata_url: URL-based client ID. When provided and the server
244-
advertises client_id_metadata_document_supported=true, this URL will be
245+
advertises client_id_metadata_document_supported=True, this URL will be
245246
used as the client_id instead of performing dynamic client registration.
246247
Must be a valid HTTPS URL with a non-root pathname.
247248
validate_resource_url: Optional callback to override resource URL validation.

src/mcp/client/auth/utils.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def extract_field_from_www_auth(response: Response, field_name: str) -> str | No
3838

3939

4040
def extract_scope_from_www_auth(response: Response) -> str | None:
41-
"""Extract scope parameter from WWW-Authenticate header as per RFC6750.
41+
"""Extract scope parameter from WWW-Authenticate header as per RFC 6750.
4242
4343
Returns:
4444
Scope string if found in WWW-Authenticate header, None otherwise
@@ -47,7 +47,7 @@ def extract_scope_from_www_auth(response: Response) -> str | None:
4747

4848

4949
def extract_resource_metadata_from_www_auth(response: Response) -> str | None:
50-
"""Extract protected resource metadata URL from WWW-Authenticate header as per RFC9728.
50+
"""Extract protected resource metadata URL from WWW-Authenticate header as per RFC 9728.
5151
5252
Returns:
5353
Resource metadata URL if found in WWW-Authenticate header, None otherwise
@@ -67,8 +67,8 @@ def build_protected_resource_metadata_discovery_urls(www_auth_url: str | None, s
6767
3. Fall back to root-based well-known URI: /.well-known/oauth-protected-resource
6868
6969
Args:
70-
www_auth_url: optional resource_metadata url extracted from the WWW-Authenticate header
71-
server_url: server url
70+
www_auth_url: Optional resource_metadata URL extracted from the WWW-Authenticate header
71+
server_url: Server URL
7272
7373
Returns:
7474
Ordered list of URLs to try for discovery
@@ -120,10 +120,10 @@ def get_client_metadata_scopes(
120120

121121

122122
def build_oauth_authorization_server_metadata_discovery_urls(auth_server_url: str | None, server_url: str) -> list[str]:
123-
"""Generate ordered list of (url, type) tuples for discovery attempts.
123+
"""Generate an ordered list of URLs for authorization server metadata discovery.
124124
125125
Args:
126-
auth_server_url: URL for the OAuth Authorization Metadata URL if found, otherwise None
126+
auth_server_url: OAuth Authorization Server Metadata URL if found, otherwise None
127127
server_url: URL for the MCP server, used as a fallback if auth_server_url is None
128128
"""
129129

@@ -170,7 +170,7 @@ async def handle_protected_resource_response(
170170
Per SEP-985, supports fallback when discovery fails at one URL.
171171
172172
Returns:
173-
True if metadata was successfully discovered, False if we should try next URL
173+
ProtectedResourceMetadata if successfully discovered, None if we should try next URL
174174
"""
175175
if response.status_code == 200:
176176
try:
@@ -206,7 +206,7 @@ def create_oauth_metadata_request(url: str) -> Request:
206206
def create_client_registration_request(
207207
auth_server_metadata: OAuthMetadata | None, client_metadata: OAuthClientMetadata, auth_base_url: str
208208
) -> Request:
209-
"""Build registration request or skip if already registered."""
209+
"""Build a client registration request."""
210210

211211
if auth_server_metadata and auth_server_metadata.registration_endpoint:
212212
registration_url = str(auth_server_metadata.registration_endpoint)
@@ -261,7 +261,7 @@ def should_use_client_metadata_url(
261261
"""Determine if URL-based client ID (CIMD) should be used instead of DCR.
262262
263263
URL-based client IDs should be used when:
264-
1. The server advertises client_id_metadata_document_supported=true
264+
1. The server advertises client_id_metadata_document_supported=True
265265
2. The client has a valid client_metadata_url configured
266266
267267
Args:
@@ -306,7 +306,7 @@ def create_client_info_from_metadata_url(
306306
async def handle_token_response_scopes(
307307
response: Response,
308308
) -> OAuthToken:
309-
"""Parse and validate token response with optional scope validation.
309+
"""Parse and validate a token response.
310310
311311
Parses token response JSON. Callers should check response.status_code before calling.
312312

src/mcp/client/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
class Client:
3838
"""A high-level MCP client for connecting to MCP servers.
3939
40-
Currently supports in-memory transport for testing. Pass a Server or
41-
MCPServer instance directly to the constructor.
40+
Supports in-memory transport for testing (pass a Server or MCPServer instance),
41+
Streamable HTTP transport (pass a URL string), or a custom Transport instance.
4242
4343
Example:
4444
```python
@@ -205,7 +205,7 @@ async def read_resource(self, uri: str, *, meta: RequestParamsMeta | None = None
205205
206206
Args:
207207
uri: The URI of the resource to read.
208-
meta: Additional metadata for the request
208+
meta: Additional metadata for the request.
209209
210210
Returns:
211211
The resource content.
@@ -239,7 +239,7 @@ async def call_tool(
239239
meta: Additional metadata for the request
240240
241241
Returns:
242-
The tool result
242+
The tool result.
243243
"""
244244
return await self.session.call_tool(
245245
name=name,

src/mcp/client/experimental/task_handlers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,13 @@ class ExperimentalTaskHandlers:
187187
WARNING: These APIs are experimental and may change without notice.
188188
189189
Example:
190+
```python
190191
handlers = ExperimentalTaskHandlers(
191192
get_task=my_get_task_handler,
192193
list_tasks=my_list_tasks_handler,
193194
)
194195
session = ClientSession(..., experimental_task_handlers=handlers)
196+
```
195197
"""
196198

197199
# Pure task request handlers

0 commit comments

Comments
 (0)