Skip to content

Commit 0206b4d

Browse files
dvlpjrsfelixweinbergeryurikunashpamelafoxihrpr
authored
[GMLP-5458] Sync upstream (#5)
* Add regression test for stateless request memory cleanup (modelcontextprotocol#1140) * Implement RFC9728 - Support WWW-Authenticate header by MCP client (modelcontextprotocol#1071) * Add streamable HTTP starlette example to Python SDK docs (modelcontextprotocol#1111) * fix markdown error in README in main (modelcontextprotocol#1147) * README - replace code snippets with examples - add lowlevel to snippets (modelcontextprotocol#1150) * README - replace code snippets with examples - streamable http (modelcontextprotocol#1155) * chore: don't allow users to create issues outside the templates (modelcontextprotocol#1163) * Tests(cli): Add coverage for helper functions (modelcontextprotocol#635) * Docs: Update CallToolResult parsing in README (modelcontextprotocol#812) Co-authored-by: Felix Weinberger <[email protected]> * docs: add pre-commit install guide on CONTRIBUTING.md (modelcontextprotocol#995) Co-authored-by: Felix Weinberger <[email protected]> * fix flaky fix-test_streamablehttp_client_resumption test (modelcontextprotocol#1166) * README - replace code snippets with examples -- auth examples (modelcontextprotocol#1164) * Support falling back to OIDC metadata for auth (modelcontextprotocol#1061) * Add CODEOWNERS file for sdk (modelcontextprotocol#1169) * fix flaky test test_88_random_error (modelcontextprotocol#1171) * Make sure `RequestId` is not coerced as `int` (modelcontextprotocol#1178) * Fix: Replace threading.Lock with anyio.Lock for Ray deployment compatibility (modelcontextprotocol#1151) * fix: fix OAuth flow request object handling (modelcontextprotocol#1174) * update codeowners group (modelcontextprotocol#1191) * fix: perform auth server metadata discovery fallbacks on any 4xx (modelcontextprotocol#1193) * server: skip duplicate response on CancelledError (modelcontextprotocol#1153) Co-authored-by: ihrpr <[email protected]> * Unpack settings in FastMCP (modelcontextprotocol#1198) * chore: Remove unused prompt_manager.py file (modelcontextprotocol#1229) Co-authored-by: Tapan Chugh <[email protected]> * Improved supported for ProtectedResourceMetadata (modelcontextprotocol#1235) Co-authored-by: Paul Carleton <[email protected]> * chore: Remove unused variable notification_options (modelcontextprotocol#1238) * Improve README around the Context object (modelcontextprotocol#1203) * fix: allow to pass `list[str]` to `token_endpoint_auth_signing_alg_values_supported` (modelcontextprotocol#1226) * Remove strict validation on `response_modes_supported` member of `OAuthMetadata` (modelcontextprotocol#1243) * Add pyright strict mode on the whole project (modelcontextprotocol#1254) * Consistent casing for default headers Accept and Content-Type (modelcontextprotocol#1263) * Update dependencies and fix type issues (modelcontextprotocol#1268) Co-authored-by: Marcelo Trylesinski <[email protected]> * fix: prevent async generator cleanup errors in StreamableHTTP transport (modelcontextprotocol#1271) Co-authored-by: David Soria Parra <[email protected]> * chore: uncomment .idea/ in .gitignore (modelcontextprotocol#1287) Co-authored-by: Claude <[email protected]> * docs: clarify streamable_http_path configuration when mounting servers (modelcontextprotocol#1172) * feat: Add CORS configuration for browser-based MCP clients (modelcontextprotocol#1059) Co-authored-by: Marcelo Trylesinski <[email protected]> Co-authored-by: Felix Weinberger <[email protected]> * Added Audio to FastMCP (modelcontextprotocol#1130) * fix: avoid uncessary retries in OAuth authenticated requests (modelcontextprotocol#1206) Co-authored-by: Felix Weinberger <[email protected]> * Add PATHEXT to default STDIO env vars in windows (modelcontextprotocol#1256) * fix: error too many values to unpack (expected 2) (modelcontextprotocol#1279) Signed-off-by: San Nguyen <[email protected]> Co-authored-by: Felix Weinberger <[email protected]> Co-authored-by: Felix Weinberger <[email protected]> * SDK Parity: Avoid Parsing Server Response for non-JsonRPCMessage Requests (modelcontextprotocol#1290) * types: Setting default value for method: Literal (modelcontextprotocol#1292) * changes structured temperature to not deadly (modelcontextprotocol#1328) * Update simple-resource example to use non-deprecated read_resource return type (modelcontextprotocol#1331) Co-authored-by: Claude <[email protected]> * docs: Update README to include link to API docs for modelcontextprotocol#1329 (modelcontextprotocol#1330) * Allow ping requests before initialization (modelcontextprotocol#1312) * Python lint: Ruff rules for pylint and code complexity (modelcontextprotocol#525) * Fix context injection for resources and prompts (modelcontextprotocol#1336) * fix(fastmcp): propagate mimeType in resource template list (modelcontextprotocol#1186) Co-authored-by: Felix Weinberger <[email protected]> * fix: allow elicitations accepted without content (modelcontextprotocol#1285) Co-authored-by: Olivier Schiavo <[email protected]> * Use --frozen in pre-commit config (modelcontextprotocol#1375) * Return HTTP 403 for invalid Origin headers (modelcontextprotocol#1353) * Add test for ProtectedResourceMetadataParsing (modelcontextprotocol#1236) Co-authored-by: Paul Carleton <[email protected]> Co-authored-by: Marcelo Trylesinski <[email protected]> Co-authored-by: Felix Weinberger <[email protected]> * Fastmcp logging progress example (modelcontextprotocol#1270) Co-authored-by: Felix Weinberger <[email protected]> * feat: add paginated list decorators for prompts, resources, and tools (modelcontextprotocol#1286) Co-authored-by: Claude <[email protected]> * Remove "unconditionally" from conditional description (modelcontextprotocol#1289) * Use streamable-http consistently in examples (modelcontextprotocol#1389) * feat: Add SDK support for SEP-1034 default values in elicitation schemas (modelcontextprotocol#1337) Co-authored-by: Tapan Chugh <[email protected]> Co-authored-by: Felix Weinberger <[email protected]> * Implementation of SEP 973 - Additional metadata + icons support (modelcontextprotocol#1357) * Merge upstream/main with custom filtering --------- Signed-off-by: San Nguyen <[email protected]> Co-authored-by: Felix Weinberger <[email protected]> Co-authored-by: yurikunash <[email protected]> Co-authored-by: Pamela Fox <[email protected]> Co-authored-by: Inna Harper <[email protected]> Co-authored-by: Marcelo Trylesinski <[email protected]> Co-authored-by: Ian Davenport <[email protected]> Co-authored-by: Dagang Wei <[email protected]> Co-authored-by: Felix Weinberger <[email protected]> Co-authored-by: Stanley Law <[email protected]> Co-authored-by: Luca Chang <[email protected]> Co-authored-by: leweng <[email protected]> Co-authored-by: Clare Liguori <[email protected]> Co-authored-by: lukacf <[email protected]> Co-authored-by: ihrpr <[email protected]> Co-authored-by: Tapan Chugh <[email protected]> Co-authored-by: Tapan Chugh <[email protected]> Co-authored-by: Yann Jouanin <[email protected]> Co-authored-by: Paul Carleton <[email protected]> Co-authored-by: Sreenath Somarajapuram <[email protected]> Co-authored-by: Omer Korner <[email protected]> Co-authored-by: joesavage-silabs <[email protected]> Co-authored-by: Gregory L <[email protected]> Co-authored-by: David Soria Parra <[email protected]> Co-authored-by: Moustapha Ebnou <[email protected]> Co-authored-by: Max Isbey <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: Jerome <[email protected]> Co-authored-by: xavier <[email protected]> Co-authored-by: keurcien <[email protected]> Co-authored-by: Tim Esler <[email protected]> Co-authored-by: San Nguyen <[email protected]> Co-authored-by: Justin Wang <[email protected]> Co-authored-by: jess <[email protected]> Co-authored-by: Peter Alexander <[email protected]> Co-authored-by: Reid Geyer <[email protected]> Co-authored-by: Eleftheria Stein-Kousathana <[email protected]> Co-authored-by: Christian Clauss <[email protected]> Co-authored-by: pchoudhury22 <[email protected]> Co-authored-by: owengo <[email protected]> Co-authored-by: Olivier Schiavo <[email protected]> Co-authored-by: Steve Billings <[email protected]> Co-authored-by: Mike Salvatore <[email protected]>
1 parent f2c07e1 commit 0206b4d

File tree

158 files changed

+5608
-1739
lines changed

Some content is hidden

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

158 files changed

+5608
-1739
lines changed

.gitattribute

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Generated
2+
uv.lock linguist-generated=true

.github/CODEOWNERS

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# CODEOWNERS for MCP Python SDK
2+
# See https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
3+
4+
# Default maintainers for everything
5+
* @modelcontextprotocol/python-sdk
6+
7+
# Auth-related code requires additional review from auth team
8+
/src/mcp/client/auth.py @modelcontextprotocol/python-sdk-auth
9+
/src/mcp/server/auth/ @modelcontextprotocol/python-sdk-auth
10+
/src/mcp/server/transport_security.py @modelcontextprotocol/python-sdk-auth
11+
/src/mcp/shared/auth*.py @modelcontextprotocol/python-sdk-auth
12+
13+
# Auth-related tests
14+
/tests/client/test_auth.py @modelcontextprotocol/python-sdk-auth
15+
/tests/server/auth/ @modelcontextprotocol/python-sdk-auth
16+
/tests/server/test_*security.py @modelcontextprotocol/python-sdk-auth
17+
/tests/server/fastmcp/auth/ @modelcontextprotocol/python-sdk-auth
18+
/tests/shared/test_auth*.py @modelcontextprotocol/python-sdk-auth
19+
20+
# Auth-related examples
21+
/examples/clients/simple-auth-client/ @modelcontextprotocol/python-sdk-auth
22+
/examples/snippets/clients/oauth_client.py @modelcontextprotocol/python-sdk-auth
23+
/examples/snippets/servers/oauth_server.py @modelcontextprotocol/python-sdk-auth

.github/ISSUE_TEMPLATE/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
blank_issues_enabled: true
1+
blank_issues_enabled: false

.github/workflows/shared.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
permissions:
77
contents: read
88

9+
env:
10+
COLUMNS: 150
11+
912
jobs:
1013
pre-commit:
1114
runs-on: ubuntu-latest
@@ -33,6 +36,7 @@ jobs:
3336
strategy:
3437
matrix:
3538
python-version: ["3.10", "3.11", "3.12", "3.13"]
39+
dep-resolution: ["lowest-direct", "highest"]
3640
os: [ubuntu-latest, windows-latest]
3741

3842
steps:
@@ -45,18 +49,11 @@ jobs:
4549
version: 0.7.2
4650

4751
- name: Install the project
48-
run: uv sync --frozen --all-extras --python ${{ matrix.python-version }}
52+
run: uv sync --frozen --all-extras --python ${{ matrix.python-version }} --resolution ${{ matrix.dep-resolution }}
4953

5054
- name: Run pytest
5155
run: uv run --frozen --no-sync pytest
5256

53-
# This must run last as it modifies the environment!
54-
- name: Run pytest with lowest versions
55-
run: |
56-
uv sync --all-extras --upgrade
57-
uv run --no-sync pytest
58-
env:
59-
UV_RESOLUTION: lowest-direct
6057
readme-snippets:
6158
runs-on: ubuntu-latest
6259
steps:

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ coverage.xml
5252
*.py,cover
5353
.hypothesis/
5454
.pytest_cache/
55+
.ruff_cache/
5556
cover/
5657

5758
# Translations
@@ -162,9 +163,12 @@ cython_debug/
162163
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
163164
# and can be added to the global gitignore or merged into this file. For a more nuclear
164165
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
165-
#.idea/
166+
.idea/
166167

167168
# vscode
168169
.vscode/
169170
.windsurfrules
170171
**/CLAUDE.local.md
172+
173+
# claude code
174+
.claude/

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ repos:
2525
hooks:
2626
- id: ruff-format
2727
name: Ruff Format
28-
entry: uv run ruff
28+
entry: uv run --frozen ruff
2929
args: [format]
3030
language: system
3131
types: [python]
3232
pass_filenames: false
3333
- id: ruff
3434
name: Ruff
35-
entry: uv run ruff
35+
entry: uv run --frozen ruff
3636
args: ["check", "--fix", "--exit-non-zero-on-fix"]
3737
types: [python]
3838
language: system
3939
pass_filenames: false
4040
exclude: ^README\.md$
4141
- id: pyright
4242
name: pyright
43-
entry: uv run pyright
43+
entry: uv run --frozen pyright
4444
language: system
4545
types: [python]
4646
pass_filenames: false
@@ -52,7 +52,7 @@ repos:
5252
pass_filenames: false
5353
- id: readme-snippets
5454
name: Check README snippets are up to date
55-
entry: uv run scripts/update_readme_snippets.py --check
55+
entry: uv run --frozen python scripts/update_readme_snippets.py --check
5656
language: system
5757
files: ^(README\.md|examples/.*\.py|scripts/update_readme_snippets\.py)$
5858
pass_filenames: false

CONTRIBUTING.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ Thank you for your interest in contributing to the MCP Python SDK! This document
1414
uv sync --frozen --all-extras --dev
1515
```
1616

17+
6. Set up pre-commit hooks:
18+
19+
```bash
20+
uv tool install pre-commit --with pre-commit-uv --force-reinstall
21+
```
22+
1723
## Development Workflow
1824

1925
1. Choose the correct branch for your changes:
@@ -50,7 +56,13 @@ uv run ruff format .
5056
uv run scripts/update_readme_snippets.py
5157
```
5258

53-
8. Submit a pull request to the same branch you branched from
59+
8. (Optional) Run pre-commit hooks on all files:
60+
61+
```bash
62+
pre-commit run --all-files
63+
```
64+
65+
9. Submit a pull request to the same branch you branched from
5466

5567
## Code Style
5668

examples/clients/simple-auth-client/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ mcp> quit
7171
## Configuration
7272

7373
- `MCP_SERVER_PORT` - Server URL (default: 8000)
74-
- `MCP_TRANSPORT_TYPE` - Transport type: `streamable_http` (default) or `sse`
74+
- `MCP_TRANSPORT_TYPE` - Transport type: `streamable-http` (default) or `sse`

examples/clients/simple-auth-client/mcp_simple_auth_client/main.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def get_state(self):
150150
class SimpleAuthClient:
151151
"""Simple MCP client with auth support."""
152152

153-
def __init__(self, server_url: str, transport_type: str = "streamable_http"):
153+
def __init__(self, server_url: str, transport_type: str = "streamable-http"):
154154
self.server_url = server_url
155155
self.transport_type = transport_type
156156
self.session: ClientSession | None = None
@@ -188,9 +188,7 @@ async def _default_redirect_handler(authorization_url: str) -> None:
188188
# Create OAuth authentication handler using the new interface
189189
oauth_auth = OAuthClientProvider(
190190
server_url=self.server_url.replace("/mcp", ""),
191-
client_metadata=OAuthClientMetadata.model_validate(
192-
client_metadata_dict
193-
),
191+
client_metadata=OAuthClientMetadata.model_validate(client_metadata_dict),
194192
storage=InMemoryTokenStorage(),
195193
redirect_handler=_default_redirect_handler,
196194
callback_handler=callback_handler,
@@ -322,9 +320,7 @@ async def interactive_loop(self):
322320
await self.call_tool(tool_name, arguments)
323321

324322
else:
325-
print(
326-
"❌ Unknown command. Try 'list', 'call <tool_name>', or 'quit'"
327-
)
323+
print("❌ Unknown command. Try 'list', 'call <tool_name>', or 'quit'")
328324

329325
except KeyboardInterrupt:
330326
print("\n\n👋 Goodbye!")
@@ -338,10 +334,10 @@ async def main():
338334
# Default server URL - can be overridden with environment variable
339335
# Most MCP streamable HTTP servers use /mcp as the endpoint
340336
server_url = os.getenv("MCP_SERVER_PORT", 8000)
341-
transport_type = os.getenv("MCP_TRANSPORT_TYPE", "streamable_http")
337+
transport_type = os.getenv("MCP_TRANSPORT_TYPE", "streamable-http")
342338
server_url = (
343339
f"http://localhost:{server_url}/mcp"
344-
if transport_type == "streamable_http"
340+
if transport_type == "streamable-http"
345341
else f"http://localhost:{server_url}/sse"
346342
)
347343

examples/clients/simple-auth-client/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ classifiers = [
1515
"Programming Language :: Python :: 3.10",
1616
]
1717
dependencies = [
18-
"click>=8.0.0",
18+
"click>=8.2.0",
1919
"mcp>=1.0.0",
2020
]
2121

@@ -39,7 +39,7 @@ select = ["E", "F", "I"]
3939
ignore = []
4040

4141
[tool.ruff]
42-
line-length = 88
42+
line-length = 120
4343
target-version = "py310"
4444

4545
[tool.uv]

0 commit comments

Comments
 (0)