Skip to content

Commit 4780e00

Browse files
authored
Merge branch 'modelcontextprotocol:main' into main
2 parents 8840ae1 + dcc9b4f commit 4780e00

File tree

337 files changed

+29246
-4744
lines changed

Some content is hidden

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

337 files changed

+29246
-4744
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

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: monthly
7+
groups:
8+
github-actions:
9+
patterns:
10+
- "*"
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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Get previous release
21+
id: previous_release
22+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
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@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
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@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
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: 0 additions & 13 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["main", "v1.x"]
6+
tags: ["v*.*.*"]
7+
pull_request:
8+
branches: ["main", "v1.x"]
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
checks:
15+
uses: ./.github/workflows/shared.yml
16+
17+
all-green:
18+
if: always()
19+
needs: [checks]
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
23+
with:
24+
jobs: ${{ toJSON(needs) }}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ jobs:
99
permissions:
1010
contents: write
1111
steps:
12-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1313
- name: Configure Git Credentials
1414
run: |
1515
git config user.name github-actions[bot]
1616
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
1717
1818
- name: Install uv
19-
uses: astral-sh/setup-uv@v3
19+
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
2020
with:
2121
enable-cache: true
2222
version: 0.9.5
2323

2424
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
25-
- uses: actions/cache@v4
25+
- uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
2626
with:
2727
key: mkdocs-material-${{ env.cache_id }}
2828
path: .cache

.github/workflows/publish-pypi.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
runs-on: ubuntu-latest
1111
needs: [checks]
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1414

1515
- name: Install uv
16-
uses: astral-sh/setup-uv@v3
16+
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
1717
with:
1818
enable-cache: true
1919
version: 0.9.5
@@ -25,7 +25,7 @@ jobs:
2525
run: uv build
2626

2727
- name: Upload artifacts
28-
uses: actions/upload-artifact@v4
28+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
2929
with:
3030
name: release-dists
3131
path: dist/
@@ -44,34 +44,34 @@ jobs:
4444

4545
steps:
4646
- name: Retrieve release distributions
47-
uses: actions/download-artifact@v4
47+
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
4848
with:
4949
name: release-dists
5050
path: dist/
5151

5252
- name: Publish package distributions to PyPI
53-
uses: pypa/gh-action-pypi-publish@release/v1
53+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
5454

5555
docs-publish:
5656
runs-on: ubuntu-latest
5757
needs: ["pypi-publish"]
5858
permissions:
5959
contents: write
6060
steps:
61-
- uses: actions/checkout@v4
61+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
6262
- name: Configure Git Credentials
6363
run: |
6464
git config user.name github-actions[bot]
6565
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
6666
6767
- name: Install uv
68-
uses: astral-sh/setup-uv@v3
68+
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
6969
with:
7070
enable-cache: true
7171
version: 0.9.5
7272

7373
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
74-
- uses: actions/cache@v4
74+
- uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
7575
with:
7676
key: mkdocs-material-${{ env.cache_id }}
7777
path: .cache

.github/workflows/pull-request-checks.yml

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

.github/workflows/shared.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ jobs:
1313
pre-commit:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v5
16+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1717

18-
- uses: astral-sh/setup-uv@v7
18+
- uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
1919
with:
2020
enable-cache: true
2121
version: 0.9.5
2222
- name: Install dependencies
2323
run: uv sync --frozen --all-extras --python 3.10
2424

25-
- uses: pre-commit/action@v3.0.1
25+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
2626
with:
2727
extra_args: --all-files --verbose
2828
env:
@@ -35,37 +35,39 @@ jobs:
3535
continue-on-error: true
3636
strategy:
3737
matrix:
38-
python-version: ["3.10", "3.11", "3.12", "3.13"]
38+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
3939
dep-resolution:
4040
- name: lowest-direct
41-
install-flags: "--resolution lowest-direct"
42-
- name: highest
41+
install-flags: "--upgrade --resolution lowest-direct"
42+
- name: locked
4343
install-flags: "--frozen"
4444
os: [ubuntu-latest, windows-latest]
4545

4646
steps:
47-
- uses: actions/checkout@v5
47+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
4848

4949
- name: Install uv
50-
uses: astral-sh/setup-uv@v7
50+
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
5151
with:
5252
enable-cache: true
5353
version: 0.9.5
5454

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+
shell: bash
60+
run: |
61+
uv run --frozen --no-sync coverage run -m pytest
62+
uv run --frozen --no-sync coverage combine
63+
uv run --frozen --no-sync coverage report
6264
6365
readme-snippets:
6466
runs-on: ubuntu-latest
6567
steps:
66-
- uses: actions/checkout@v5
68+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
6769

68-
- uses: astral-sh/setup-uv@v7
70+
- uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
6971
with:
7072
enable-cache: true
7173
version: 0.9.5

0 commit comments

Comments
 (0)