Skip to content

Commit bc867a7

Browse files
Merge branch 'main' into server_session_group
2 parents 68a8b40 + b41b917 commit bc867a7

File tree

191 files changed

+16170
-4351
lines changed

Some content is hidden

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

191 files changed

+16170
-4351
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/check-lock.yml

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ jobs:
3030
mkdocs-material-
3131
3232
- run: uv sync --frozen --group docs
33-
- run: uv run --no-sync mkdocs gh-deploy --force
33+
- run: uv run --frozen --no-sync mkdocs gh-deploy --force

.github/workflows/publish-pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ jobs:
7979
mkdocs-material-
8080
8181
- run: uv sync --frozen --group docs
82-
- run: uv run --no-sync mkdocs gh-deploy --force
82+
- run: uv run --frozen --no-sync mkdocs gh-deploy --force

.github/workflows/shared.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ name: Shared Checks
33
on:
44
workflow_call:
55

6+
permissions:
7+
contents: read
8+
9+
env:
10+
COLUMNS: 150
11+
612
jobs:
713
pre-commit:
814
runs-on: ubuntu-latest
@@ -25,9 +31,12 @@ jobs:
2531

2632
test:
2733
runs-on: ${{ matrix.os }}
34+
timeout-minutes: 10
35+
continue-on-error: true
2836
strategy:
2937
matrix:
3038
python-version: ["3.10", "3.11", "3.12", "3.13"]
39+
dep-resolution: ["lowest-direct", "highest"]
3140
os: [ubuntu-latest, windows-latest]
3241

3342
steps:
@@ -40,8 +49,23 @@ jobs:
4049
version: 0.7.2
4150

4251
- name: Install the project
43-
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 }}
4453

4554
- name: Run pytest
46-
run: uv run --no-sync pytest
47-
continue-on-error: true
55+
run: uv run --frozen --no-sync pytest
56+
57+
readme-snippets:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- uses: astral-sh/setup-uv@v5
63+
with:
64+
enable-cache: true
65+
version: 0.7.2
66+
67+
- name: Install dependencies
68+
run: uv sync --frozen --all-extras --python 3.10
69+
70+
- name: Check README snippets are up to date
71+
run: uv run --frozen scripts/update_readme_snippets.py --check

.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: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ repos:
77
- id: prettier
88
types_or: [yaml, json5]
99

10+
- repo: https://github.com/igorshubovych/markdownlint-cli
11+
rev: v0.45.0
12+
hooks:
13+
- id: markdownlint
14+
args:
15+
[
16+
"--fix",
17+
"--config",
18+
"pyproject.toml",
19+
"--configPointer",
20+
"/tool/markdown/lint",
21+
]
22+
types: [markdown]
23+
1024
- repo: local
1125
hooks:
1226
- id: ruff-format
@@ -23,10 +37,10 @@ repos:
2337
types: [python]
2438
language: system
2539
pass_filenames: false
40+
exclude: ^README\.md$
2641
- id: pyright
2742
name: pyright
2843
entry: uv run pyright
29-
args: [src]
3044
language: system
3145
types: [python]
3246
pass_filenames: false
@@ -36,3 +50,9 @@ repos:
3650
language: system
3751
files: ^(pyproject\.toml|uv\.lock)$
3852
pass_filenames: false
53+
- id: readme-snippets
54+
name: Check README snippets are up to date
55+
entry: uv run scripts/update_readme_snippets.py --check
56+
language: system
57+
files: ^(README\.md|examples/.*\.py|scripts/update_readme_snippets\.py)$
58+
pass_filenames: false

CLAUDE.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This document contains critical information about working with this codebase. Fo
1616
- Public APIs must have docstrings
1717
- Functions must be focused and small
1818
- Follow existing patterns exactly
19-
- Line length: 88 chars maximum
19+
- Line length: 120 chars maximum
2020

2121
3. Testing Requirements
2222
- Framework: `uv run --frozen pytest`
@@ -26,15 +26,19 @@ This document contains critical information about working with this codebase. Fo
2626
- Bug fixes require regression tests
2727

2828
- For commits fixing bugs or adding features based on user reports add:
29+
2930
```bash
3031
git commit --trailer "Reported-by:<name>"
3132
```
33+
3234
Where `<name>` is the name of the user.
3335

3436
- For commits related to a Github issue, add
37+
3538
```bash
3639
git commit --trailer "Github-Issue:#<number>"
3740
```
41+
3842
- NEVER ever mention a `co-authored-by` or similar aspects. In particular, never
3943
mention the tool used to create the commit message or PR.
4044

@@ -116,3 +120,15 @@ This document contains critical information about working with this codebase. Fo
116120
- Follow existing patterns
117121
- Document public APIs
118122
- Test thoroughly
123+
124+
## Exception Handling
125+
126+
- **Always use `logger.exception()` instead of `logger.error()` when catching exceptions**
127+
- Don't include the exception in the message: `logger.exception("Failed")` not `logger.exception(f"Failed: {e}")`
128+
- **Catch specific exceptions** where possible:
129+
- File ops: `except (OSError, PermissionError):`
130+
- JSON: `except json.JSONDecodeError:`
131+
- Network: `except (ConnectionError, TimeoutError):`
132+
- **Only catch `Exception` for**:
133+
- Top-level handlers that must not crash
134+
- Cleanup blocks (log at debug level)

0 commit comments

Comments
 (0)