Skip to content

Commit eb07bbb

Browse files
authored
Merge branch 'main' into fix-oauth-token-status-codes
2 parents d2ed7e4 + 3f6b059 commit eb07bbb

File tree

248 files changed

+25513
-2047
lines changed

Some content is hidden

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

248 files changed

+25513
-2047
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# Applied 120 line-length rule to all files: https://github.com/modelcontextprotocol/python-sdk/pull/856
22
543961968c0634e93d919d509cce23a1d6a56c21
3+
4+
# Added 100% code coverage baseline with pragma comments: https://github.com/modelcontextprotocol/python-sdk/pull/1553
5+
89e9c43acf7e23cf766357d776ec1ce63ac2c58e

.gitattribute

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Generated
2-
uv.lock linguist-generated=true
2+
uv.lock linguist-generated=true
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Comment on PRs in Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
pull-requests: write
9+
contents: read
10+
11+
jobs:
12+
comment-on-prs:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Get previous release
21+
id: previous_release
22+
uses: actions/github-script@v7
23+
with:
24+
script: |
25+
const currentTag = '${{ github.event.release.tag_name }}';
26+
27+
// Get all releases
28+
const { data: releases } = await github.rest.repos.listReleases({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
per_page: 100
32+
});
33+
34+
// Find current release index
35+
const currentIndex = releases.findIndex(r => r.tag_name === currentTag);
36+
37+
if (currentIndex === -1) {
38+
console.log('Current release not found in list');
39+
return null;
40+
}
41+
42+
// Get previous release (next in the list since they're sorted by date desc)
43+
const previousRelease = releases[currentIndex + 1];
44+
45+
if (!previousRelease) {
46+
console.log('No previous release found, this might be the first release');
47+
return null;
48+
}
49+
50+
console.log(`Found previous release: ${previousRelease.tag_name}`);
51+
52+
return previousRelease.tag_name;
53+
54+
- name: Get merged PRs between releases
55+
id: get_prs
56+
uses: actions/github-script@v7
57+
with:
58+
script: |
59+
const currentTag = '${{ github.event.release.tag_name }}';
60+
const previousTag = ${{ steps.previous_release.outputs.result }};
61+
62+
if (!previousTag) {
63+
console.log('No previous release found, skipping');
64+
return [];
65+
}
66+
67+
console.log(`Finding PRs between ${previousTag} and ${currentTag}`);
68+
69+
// Get commits between previous and current release
70+
const comparison = await github.rest.repos.compareCommits({
71+
owner: context.repo.owner,
72+
repo: context.repo.repo,
73+
base: previousTag,
74+
head: currentTag
75+
});
76+
77+
const commits = comparison.data.commits;
78+
console.log(`Found ${commits.length} commits`);
79+
80+
// Get PRs associated with each commit using GitHub API
81+
const prNumbers = new Set();
82+
83+
for (const commit of commits) {
84+
try {
85+
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
86+
owner: context.repo.owner,
87+
repo: context.repo.repo,
88+
commit_sha: commit.sha
89+
});
90+
91+
for (const pr of prs) {
92+
if (pr.merged_at) {
93+
prNumbers.add(pr.number);
94+
console.log(`Found merged PR: #${pr.number}`);
95+
}
96+
}
97+
} catch (error) {
98+
console.log(`Failed to get PRs for commit ${commit.sha}: ${error.message}`);
99+
}
100+
}
101+
102+
console.log(`Found ${prNumbers.size} merged PRs`);
103+
return Array.from(prNumbers);
104+
105+
- name: Comment on PRs
106+
uses: actions/github-script@v7
107+
with:
108+
script: |
109+
const prNumbers = ${{ steps.get_prs.outputs.result }};
110+
const releaseTag = '${{ github.event.release.tag_name }}';
111+
const releaseUrl = '${{ github.event.release.html_url }}';
112+
113+
const comment = `This pull request is included in [${releaseTag}](${releaseUrl})`;
114+
115+
let commentedCount = 0;
116+
117+
for (const prNumber of prNumbers) {
118+
try {
119+
// Check if we've already commented on this PR for this release
120+
const { data: comments } = await github.rest.issues.listComments({
121+
owner: context.repo.owner,
122+
repo: context.repo.repo,
123+
issue_number: prNumber,
124+
per_page: 100
125+
});
126+
127+
const alreadyCommented = comments.some(c =>
128+
c.user.type === 'Bot' && c.body.includes(releaseTag)
129+
);
130+
131+
if (alreadyCommented) {
132+
console.log(`Skipping PR #${prNumber} - already commented for ${releaseTag}`);
133+
continue;
134+
}
135+
136+
await github.rest.issues.createComment({
137+
owner: context.repo.owner,
138+
repo: context.repo.repo,
139+
issue_number: prNumber,
140+
body: comment
141+
});
142+
commentedCount++;
143+
console.log(`Successfully commented on PR #${prNumber}`);
144+
} catch (error) {
145+
console.error(`Failed to comment on PR #${prNumber}:`, error.message);
146+
}
147+
}
148+
149+
console.log(`Commented on ${commentedCount} of ${prNumbers.length} PRs`);

.github/workflows/main-checks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- main
77
- "v*.*.*"
8+
- "v1.x"
89
tags:
910
- "v*.*.*"
1011

.github/workflows/shared.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ jobs:
3838
python-version: ["3.10", "3.11", "3.12", "3.13"]
3939
dep-resolution:
4040
- name: lowest-direct
41-
install-flags: "--resolution lowest-direct"
41+
install-flags: "--upgrade --resolution lowest-direct"
4242
- name: highest
43-
install-flags: "--frozen"
43+
install-flags: "--upgrade --resolution highest"
4444
os: [ubuntu-latest, windows-latest]
4545

4646
steps:
@@ -55,10 +55,11 @@ jobs:
5555
- name: Install the project
5656
run: uv sync ${{ matrix.dep-resolution.install-flags }} --all-extras --python ${{ matrix.python-version }}
5757

58-
- name: Run pytest
59-
run: uv run ${{ matrix.dep-resolution.install-flags }} --no-sync pytest
60-
env:
61-
UV_RESOLUTION: ${{ matrix.dep-resolution.name == 'lowest-direct' && 'lowest-direct' || 'highest' }}
58+
- name: Run pytest with coverage
59+
run: |
60+
uv run --frozen --no-sync coverage run -m pytest
61+
uv run --frozen --no-sync coverage combine
62+
uv run --frozen --no-sync coverage report
6263
6364
readme-snippets:
6465
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
fail_fast: true
22

33
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v6.0.0
6+
hooks:
7+
- id: end-of-file-fixer
8+
49
- repo: https://github.com/pre-commit/mirrors-prettier
510
rev: v3.1.0
611
hooks:

CONTRIBUTING.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ uv tool install pre-commit --with pre-commit-uv --force-reinstall
2323
## Development Workflow
2424

2525
1. Choose the correct branch for your changes:
26-
- For bug fixes to a released version: use the latest release branch (e.g. v1.1.x for 1.1.3)
27-
- For new features: use the main branch (which will become the next minor/major version)
28-
- If unsure, ask in an issue first
26+
27+
| Change Type | Target Branch | Example |
28+
|-------------|---------------|---------|
29+
| New features, breaking changes | `main` | New APIs, refactors |
30+
| Security fixes for v1 | `v1.x` | Critical patches |
31+
| Bug fixes for v1 | `v1.x` | Non-breaking fixes |
32+
33+
> **Note:** `main` is the v2 development branch. Breaking changes are welcome on `main`. The `v1.x` branch receives only security and critical bug fixes.
2934
3035
2. Create a new branch from your chosen base branch
3136

0 commit comments

Comments
 (0)