Skip to content

Commit bc354a7

Browse files
Merge branch 'main' into main
2 parents 20006b3 + 8dd15ac commit bc354a7

File tree

183 files changed

+9692
-2264
lines changed

Some content is hidden

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

183 files changed

+9692
-2264
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/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: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,40 @@ 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
1327
name: Ruff Format
14-
entry: uv run ruff
28+
entry: uv run --frozen ruff
1529
args: [format]
1630
language: system
1731
types: [python]
1832
pass_filenames: false
1933
- id: ruff
2034
name: Ruff
21-
entry: uv run ruff
35+
entry: uv run --frozen ruff
2236
args: ["check", "--fix", "--exit-non-zero-on-fix"]
2337
types: [python]
2438
language: system
2539
pass_filenames: false
2640
exclude: ^README\.md$
2741
- id: pyright
2842
name: pyright
29-
entry: uv run pyright
30-
args: [src]
43+
entry: uv run --frozen pyright
3144
language: system
3245
types: [python]
3346
pass_filenames: false
@@ -39,7 +52,7 @@ repos:
3952
pass_filenames: false
4053
- id: readme-snippets
4154
name: Check README snippets are up to date
42-
entry: uv run scripts/update_readme_snippets.py --check
55+
entry: uv run --frozen python scripts/update_readme_snippets.py --check
4356
language: system
4457
files: ^(README\.md|examples/.*\.py|scripts/update_readme_snippets\.py)$
4558
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)

CODE_OF_CONDUCT.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ representative at an online or offline event.
6060

6161
Instances of abusive, harassing, or otherwise unacceptable behavior may be
6262
reported to the community leaders responsible for enforcement at
63-
63+
6464
All complaints will be reviewed and investigated promptly and fairly.
6565

6666
All community leaders are obligated to respect the privacy and security of the
@@ -116,13 +116,13 @@ the community.
116116

117117
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118118
version 2.0, available at
119-
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
119+
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.
120120

121121
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122122
enforcement ladder](https://github.com/mozilla/diversity).
123123

124124
[homepage]: https://www.contributor-covenant.org
125125

126126
For answers to common questions about this code of conduct, see the FAQ at
127-
https://www.contributor-covenant.org/faq. Translations are available at
128-
https://www.contributor-covenant.org/translations.
127+
<https://www.contributor-covenant.org/faq>. Translations are available at
128+
<https://www.contributor-covenant.org/translations>.

CONTRIBUTING.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@ Thank you for your interest in contributing to the MCP Python SDK! This document
99
3. Fork the repository
1010
4. Clone your fork: `git clone https://github.com/YOUR-USERNAME/python-sdk.git`
1111
5. Install dependencies:
12+
1213
```bash
1314
uv sync --frozen --all-extras --dev
1415
```
1516

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

1825
1. Choose the correct branch for your changes:
@@ -25,27 +32,37 @@ uv sync --frozen --all-extras --dev
2532
3. Make your changes
2633

2734
4. Ensure tests pass:
28-
```bash
35+
36+
```bash
2937
uv run pytest
3038
```
3139

3240
5. Run type checking:
41+
3342
```bash
3443
uv run pyright
3544
```
3645

3746
6. Run linting:
47+
3848
```bash
3949
uv run ruff check .
4050
uv run ruff format .
4151
```
4252

4353
7. Update README snippets if you modified example code:
54+
4455
```bash
4556
uv run scripts/update_readme_snippets.py
4657
```
4758

48-
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
4966

5067
## Code Style
5168

0 commit comments

Comments
 (0)