Skip to content

Commit 59984d9

Browse files
authored
Merge branch 'main' into fix/auth-requestinit-headers
2 parents 37a8fa9 + 2da89db commit 59984d9

32 files changed

+4928
-798
lines changed

.github/workflows/main.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,35 @@ jobs:
1818
- uses: actions/checkout@v4
1919
- uses: actions/setup-node@v4
2020
with:
21-
node-version: 18
21+
node-version: 24
2222
cache: npm
2323

2424
- run: npm ci
25+
- run: npm run check
2526
- run: npm run build
27+
28+
test:
29+
runs-on: ubuntu-latest
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
node-version: [18, 24]
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: actions/setup-node@v4
38+
with:
39+
node-version: ${{ matrix.node-version }}
40+
cache: npm
41+
42+
- run: npm ci
2643
- run: npm test
27-
- run: npm run lint
2844

2945
publish:
3046
runs-on: ubuntu-latest
3147
if: github.event_name == 'release'
3248
environment: release
33-
needs: build
49+
needs: [build, test]
3450

3551
permissions:
3652
contents: read
@@ -40,7 +56,7 @@ jobs:
4056
- uses: actions/checkout@v4
4157
- uses: actions/setup-node@v4
4258
with:
43-
node-version: 18
59+
node-version: 24
4460
cache: npm
4561
registry-url: 'https://registry.npmjs.org'
4662

.github/workflows/publish.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Publish Any Commit
2+
permissions:
3+
contents: read
4+
on:
5+
pull_request:
6+
push:
7+
branches:
8+
- '**'
9+
tags:
10+
- '!**'
11+
12+
jobs:
13+
pkg-publish:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: 24
21+
cache: npm
22+
23+
- run: npm ci
24+
- name: Build
25+
run: npm run build
26+
- name: Publish
27+
run: npx pkg-pr-new publish
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Update Spec Types
2+
3+
on:
4+
schedule:
5+
# Run nightly at 4 AM UTC
6+
- cron: '0 4 * * *'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
update-spec-types:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '24'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Fetch latest spec types
29+
run: npm run fetch:spec-types
30+
31+
- name: Check for changes
32+
id: check_changes
33+
run: |
34+
if git diff --quiet src/spec.types.ts; then
35+
echo "has_changes=false" >> $GITHUB_OUTPUT
36+
else
37+
echo "has_changes=true" >> $GITHUB_OUTPUT
38+
LATEST_SHA=$(grep "Last updated from commit:" src/spec.types.ts | cut -d: -f2 | tr -d ' ')
39+
echo "sha=$LATEST_SHA" >> $GITHUB_OUTPUT
40+
fi
41+
42+
- name: Create Pull Request
43+
if: steps.check_changes.outputs.has_changes == 'true'
44+
env:
45+
GH_TOKEN: ${{ github.token }}
46+
run: |
47+
git config user.name "github-actions[bot]"
48+
git config user.email "github-actions[bot]@users.noreply.github.com"
49+
50+
git checkout -B update-spec-types
51+
git add src/spec.types.ts
52+
git commit -m "chore: update spec.types.ts from upstream"
53+
git push -f origin update-spec-types
54+
55+
# Create PR if it doesn't exist, or update if it does
56+
PR_BODY="This PR updates \`src/spec.types.ts\` from the Model Context Protocol specification.
57+
58+
Source file: https://github.com/modelcontextprotocol/modelcontextprotocol/blob/${{ steps.check_changes.outputs.sha }}/schema/draft/schema.ts
59+
60+
This is an automated update triggered by the nightly cron job."
61+
62+
if gh pr view update-spec-types &>/dev/null; then
63+
echo "PR already exists, updating description..."
64+
gh pr edit update-spec-types --body "$PR_BODY"
65+
else
66+
gh pr create \
67+
--title "chore: update spec.types.ts from upstream" \
68+
--body "$PR_BODY" \
69+
--base main \
70+
--head update-spec-types
71+
fi

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ web_modules/
6969
# Output of 'npm pack'
7070
*.tgz
7171

72-
# Output of 'npm run fetch:spec-types'
73-
spec.types.ts
74-
7572
# Yarn Integrity file
7673
.yarn-integrity
7774

.prettierignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ node_modules
77
**/build
88
**/dist
99
.github/CODEOWNERS
10-
pnpm-lock.yaml
10+
pnpm-lock.yaml
11+
12+
# Ignore generated files
13+
src/spec.types.ts

eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export default tseslint.config(
1515
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }]
1616
}
1717
},
18+
{
19+
ignores: ['src/spec.types.ts']
20+
},
1821
{
1922
files: ['src/client/**/*.ts', 'src/server/**/*.ts'],
2023
ignores: ['**/*.test.ts'],

package-lock.json

Lines changed: 124 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@modelcontextprotocol/sdk",
3-
"version": "1.21.0",
3+
"version": "1.21.1",
44
"description": "Model Context Protocol implementation for TypeScript",
55
"license": "MIT",
66
"author": "Anthropic, PBC (https://anthropic.com)",
@@ -59,7 +59,8 @@
5959
"dist"
6060
],
6161
"scripts": {
62-
"fetch:spec-types": "curl -o spec.types.ts https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/refs/heads/main/schema/draft/schema.ts",
62+
"fetch:spec-types": "tsx scripts/fetch-spec-types.ts",
63+
"typecheck": "tsgo --noEmit",
6364
"build": "npm run build:esm && npm run build:cjs",
6465
"build:esm": "mkdir -p dist/esm && echo '{\"type\": \"module\"}' > dist/esm/package.json && tsc -p tsconfig.prod.json",
6566
"build:esm:w": "npm run build:esm -- -w",
@@ -69,10 +70,11 @@
6970
"prepack": "npm run build:esm && npm run build:cjs",
7071
"lint": "eslint src/ && prettier --check .",
7172
"lint:fix": "eslint src/ --fix && prettier --write .",
72-
"test": "npm run fetch:spec-types && jest",
73+
"check": "npm run typecheck && npm run lint",
74+
"test": "jest",
7375
"start": "npm run server",
74-
"server": "tsx watch --clear-screen=false src/cli.ts server",
75-
"client": "tsx src/cli.ts client"
76+
"server": "tsx watch --clear-screen=false scripts/cli.ts server",
77+
"client": "tsx scripts/cli.ts client"
7678
},
7779
"dependencies": {
7880
"ajv": "^8.17.1",
@@ -111,6 +113,7 @@
111113
"@types/node": "^22.0.2",
112114
"@types/supertest": "^6.0.2",
113115
"@types/ws": "^8.5.12",
116+
"@typescript/native-preview": "^7.0.0-dev.20251103.1",
114117
"eslint": "^9.8.0",
115118
"eslint-config-prettier": "^10.1.8",
116119
"jest": "^29.7.0",

0 commit comments

Comments
 (0)