Skip to content

Commit 1a9554d

Browse files
authored
Merge pull request #4975 from modelcontextprotocol/v2/chore/4860-everything-interface-diff
ci(everything): adopt the MCP interface diff (adapted from #3260)
2 parents 4423f2c + 4d0fcbe commit 1a9554d

9 files changed

Lines changed: 1052 additions & 12 deletions

File tree

‎.claude/skills/pre-push-gate/SKILL.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,31 @@ of the server's stderr. Re-run a subset with
273273
- **A new server fails `test:scripts`** with "every server directory in the
274274
repo has a smoke entry": add it to `SERVERS` in `scripts/smoke-servers.mjs`.
275275

276+
### `interface-diff`
277+
278+
The last stage diffs the `everything` server's MCP interface (capabilities,
279+
tools, prompts, resources, resource templates) in this checkout's build
280+
against the same server built from the merge-base with `origin/v2/main`, and
281+
prints the report. **A changed interface does not fail it**: the report is
282+
what the PR's sticky comment will show, so read it, and if a change is not
283+
one you meant, that is the finding. It fails only when the diff cannot run,
284+
with `❌ The interface diff could not run` and the reason:
285+
286+
- **"origin/v2/main is not available"**: `git fetch origin v2/main`.
287+
- **"src/everything/dist/index.js does not exist"**: you ran it on its own
288+
before building: `npm run build -w src/everything`.
289+
- **An `npm ci` or `npm run build` failure**: the _base_ did not install or
290+
build. Offline with a cold npm cache is the usual cause; otherwise name a
291+
base that builds with `npm run interface-diff -- --base <ref>`.
292+
- **"Base server probe failed" / "Target probe failed"**: a server did not
293+
answer the probe. A target failure is this checkout's server and is the
294+
real defect; the smoke stage before it usually fails first.
295+
296+
Re-run it on its own with `npm run interface-diff` (about ten seconds). What
297+
it compares against in CI, and why it is a script rather than an action, is
298+
in [`docs/quality-gate.md`](../../../docs/quality-gate.md) and the header of
299+
`scripts/interface-diff.mjs`.
300+
276301
## Waiting on the lease
277302

278303
A gate that starts with
Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
# Tracks public interface changes to the Everything MCP server.
2+
# The Everything server is a reference implementation demonstrating all MCP features.
3+
# This workflow helps reviewers see how tools, resources, prompts, and capabilities
4+
# evolve over time - useful for SDK compliance validation and catching regressions.
5+
#
6+
# Contributed by @SamMorrowDrums in #3260 and adapted for v2/main in #4860:
7+
#
8+
# - The check is `npm run interface-diff` (scripts/interface-diff.mjs), which
9+
# drives the `mcp-server-diff` CLI, an exact-pinned root devDependency. The
10+
# same script is a `local:gate` stage, and `scripts/lib/workflow-gate.test.mjs`
11+
# requires every npm script a workflow runs to be one, so CI and the gate run
12+
# the same check. No third-party action runs here.
13+
# - The base is chosen per event below rather than by the tool, whose default
14+
# (the merge-base with origin/main) is the wrong base for PRs to v2/main.
15+
# - Untrusted code (the PR's install, build and server) runs only in `diff`,
16+
# which holds a read-only token and no persisted credentials. The sticky
17+
# comment is posted by `comment`, which holds `pull-requests: write` and runs
18+
# none of the PR's code, and only for PRs from this repository: a fork PR's
19+
# token is read-only, so there the report is in the job summary and the
20+
# `mcp-diff-report` artifact. `pull_request_target` is deliberately not used,
21+
# since it would run the fork's build next to a write token. If fork PRs need
22+
# the comment too, the way is a separate `workflow_run` workflow that posts
23+
# the artifact without checking anything out.
24+
#
25+
# A changed interface does not fail the run: the diff is information for the
26+
# reviewer. A diff that cannot run (a base that does not build, a server that
27+
# cannot be probed) does.
28+
#
29+
# See: https://github.com/modelcontextprotocol/inspector/issues/1034
30+
name: Everything Server MCP Diff
31+
32+
on:
33+
push:
34+
branches: [main, v2/main]
35+
paths:
36+
- "src/everything/**"
37+
- "package.json"
38+
- "package-lock.json"
39+
- "tsconfig.json"
40+
- "scripts/interface-diff.mjs"
41+
- "scripts/lib/win-shell-args.mjs"
42+
- ".github/workflows/everything-mcp-diff.yml"
43+
# No branch filter: PRs to v2/main and to main both run, and so does a PR
44+
# stacked on another PR's branch. The base is the PR's own base either way.
45+
pull_request:
46+
paths:
47+
- "src/everything/**"
48+
- "package.json"
49+
- "package-lock.json"
50+
- "tsconfig.json"
51+
- "scripts/interface-diff.mjs"
52+
- "scripts/lib/win-shell-args.mjs"
53+
- ".github/workflows/everything-mcp-diff.yml"
54+
# A published Release (a milestone, tagged vX.Y.Z on main; see RELEASING.md)
55+
# surfaces the cumulative interface delta since the previous Release. This
56+
# replaces #3260's `typescript-servers-*` tag trigger: those tags stopped in
57+
# 2024, and no release since has used them.
58+
release:
59+
types: [published]
60+
# Manual trigger: the branch chosen in "Use workflow from" is the head, and
61+
# `compare_ref` any base. #3260 also took a `target_ref`, but a target that
62+
# predates the interface-diff script has no `npm run interface-diff` to run,
63+
# so the head is the dispatched branch instead.
64+
workflow_dispatch:
65+
inputs:
66+
compare_ref:
67+
description: "Base ref to compare against (commit SHA, tag, or branch; defaults to the merge-base with v2/main)"
68+
required: false
69+
default: ""
70+
71+
permissions:
72+
contents: read
73+
74+
# Superseded runs on the same PR are cancelled. Every other run gets a group
75+
# of its own: a group holds one running and one pending run, so a shared group
76+
# would drop a push's run when two more queued behind it.
77+
concurrency:
78+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
79+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
80+
81+
jobs:
82+
diff:
83+
name: Diff Everything Server Interface
84+
timeout-minutes: 15
85+
runs-on: ubuntu-latest
86+
permissions:
87+
contents: read
88+
steps:
89+
- name: Checkout repository
90+
uses: actions/checkout@v6
91+
with:
92+
# The base is built from history, so all of it is needed, tags
93+
# included (the release base is the previous Release's tag).
94+
fetch-depth: 0
95+
# The event's own commit (the merge commit for a PR), not a branch
96+
# ref that a later push could move before this step runs.
97+
ref: ${{ github.sha }}
98+
persist-credentials: false
99+
100+
- uses: actions/setup-node@v7
101+
with:
102+
node-version: 22
103+
cache: npm
104+
105+
# A root `npm ci` runs every workspace's `prepare`, which builds it, so
106+
# the head build the diff probes exists after this step.
107+
- name: Install dependencies and build
108+
run: npm ci
109+
110+
- name: Choose the base to compare against
111+
id: base
112+
env:
113+
EVENT: ${{ github.event_name }}
114+
PR_BASE: ${{ github.event.pull_request.base.sha }}
115+
BEFORE: ${{ github.event.before }}
116+
INPUT_BASE: ${{ inputs.compare_ref }}
117+
TAG: ${{ github.event.release.tag_name }}
118+
PUBLISHED: ${{ github.event.release.published_at }}
119+
REPO: ${{ github.repository }}
120+
GH_TOKEN: ${{ github.token }}
121+
run: |
122+
case "$EVENT" in
123+
# The checkout is the PR's merge commit, so its base tip is
124+
# exactly what the PR changes.
125+
pull_request) base="$PR_BASE" ;;
126+
# The branch as it was before this push; a new branch has none.
127+
push)
128+
if [ -n "$BEFORE" ] && [ "$BEFORE" != 0000000000000000000000000000000000000000 ]; then
129+
base="$BEFORE"
130+
else
131+
base=$(git rev-parse HEAD^)
132+
fi ;;
133+
# The Release published just before this one (so a re-run of an
134+
# older Release still compares against ITS predecessor). Not
135+
# `git describe`: the date-stamped releases tagged commits that
136+
# never reached main, so the nearest ancestor tag is years older
137+
# than the last release.
138+
release)
139+
base=$(gh release list --repo "$REPO" --exclude-drafts --exclude-pre-releases --limit 50 \
140+
--json tagName,publishedAt \
141+
--jq "map(select(.tagName != \"$TAG\" and .publishedAt < \"$PUBLISHED\")) | sort_by(.publishedAt) | last | .tagName // empty")
142+
if [ -z "$base" ]; then echo "no earlier Release to compare against" >&2; exit 1; fi ;;
143+
workflow_dispatch)
144+
if [ -n "$INPUT_BASE" ]; then
145+
base="$INPUT_BASE"
146+
else
147+
base=$(git merge-base HEAD origin/v2/main)
148+
fi ;;
149+
*) echo "unexpected event: $EVENT" >&2; exit 1 ;;
150+
esac
151+
echo "Comparing against $base"
152+
echo "ref=$base" >> "$GITHUB_OUTPUT"
153+
154+
- name: Diff the interface
155+
env:
156+
BASE: ${{ steps.base.outputs.ref }}
157+
run: npm run interface-diff -- --base "$BASE" --report-dir mcp-diff-report
158+
159+
- name: Write the job summary
160+
if: always()
161+
run: |
162+
{
163+
if [ -f mcp-diff-report/report.md ]; then
164+
# A step summary holds at most 1 MiB.
165+
head -c 900000 mcp-diff-report/report.md
166+
if [ "$(wc -c < mcp-diff-report/report.md)" -gt 900000 ]; then
167+
echo ""
168+
echo "_The report is truncated here; the full report is in the run's \`mcp-diff-report\` artifact._"
169+
fi
170+
else
171+
echo "The interface diff produced no report; see the job log."
172+
fi
173+
echo ""
174+
echo "---"
175+
echo ""
176+
echo "ℹ️ **Interpreting Results**"
177+
echo ""
178+
echo "The Everything server is a reference implementation that exercises all MCP features."
179+
echo "Interface changes here may indicate:"
180+
echo "- New MCP protocol features being demonstrated"
181+
echo "- Updated tool schemas or descriptions"
182+
echo "- New resources, prompts, or capabilities"
183+
echo ""
184+
echo "Review changes to ensure they align with the intended protocol updates."
185+
} >> "$GITHUB_STEP_SUMMARY"
186+
187+
- name: Upload the report
188+
if: always()
189+
uses: actions/upload-artifact@v7
190+
with:
191+
name: mcp-diff-report
192+
path: mcp-diff-report/
193+
if-no-files-found: ignore
194+
195+
# Post (or update) a sticky PR comment so reviewers can see the diff without
196+
# navigating to the Actions tab. One comment per PR, found again by its
197+
# marker and edited on each push. This job checks nothing out and runs none
198+
# of the PR's code; it only reads the report the `diff` job uploaded.
199+
# Dependabot's PRs are same-repo but get a read-only token, so they are
200+
# skipped like fork PRs and keep the job summary and the artifact.
201+
comment:
202+
name: Post the diff on the PR
203+
needs: diff
204+
if: >-
205+
always() &&
206+
github.event_name == 'pull_request' &&
207+
github.event.pull_request.head.repo.full_name == github.repository &&
208+
github.event.pull_request.user.login != 'dependabot[bot]' &&
209+
(needs.diff.result == 'success' || needs.diff.result == 'failure')
210+
timeout-minutes: 5
211+
runs-on: ubuntu-latest
212+
permissions:
213+
pull-requests: write
214+
steps:
215+
- name: Download the report
216+
uses: actions/download-artifact@v8
217+
continue-on-error: true
218+
with:
219+
name: mcp-diff-report
220+
path: mcp-diff-report
221+
222+
- name: Post / update sticky PR comment
223+
env:
224+
GH_TOKEN: ${{ github.token }}
225+
REPO: ${{ github.repository }}
226+
PR: ${{ github.event.pull_request.number }}
227+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
228+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
229+
run: |
230+
marker='<!-- everything-mcp-diff -->'
231+
{
232+
echo "$marker"
233+
if [ -f mcp-diff-report/report.md ]; then
234+
# A comment holds at most 65536 characters.
235+
head -c 60000 mcp-diff-report/report.md
236+
if [ "$(wc -c < mcp-diff-report/report.md)" -gt 60000 ]; then
237+
echo ""
238+
echo "_The report is truncated here; the full report is in the run's \`mcp-diff-report\` artifact._"
239+
fi
240+
else
241+
echo "## \`everything\`: MCP interface diff"
242+
echo ""
243+
echo "❌ The diff job produced no report; see the run's log."
244+
fi
245+
echo ""
246+
echo "<sub>Updated by [this run]($RUN_URL) for \`$HEAD_SHA\`.</sub>"
247+
} > body.md
248+
id=$(gh api --paginate "repos/$REPO/issues/$PR/comments" \
249+
--jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"$marker\"))) | .id" | head -n 1)
250+
if [ -n "$id" ]; then
251+
gh api -X PATCH "repos/$REPO/issues/comments/$id" -F body=@body.md > /dev/null
252+
else
253+
gh api "repos/$REPO/issues/$PR/comments" -F body=@body.md > /dev/null
254+
fi

‎AGENTS.md‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ servers/
5252
│ └── time/ Py mcp-server-time PyPI Time and timezone conversion
5353
├── .claude/skills/ On-demand procedures (see the Skills index above)
5454
├── .changeset/ Pending changesets for the TypeScript servers, and the changesets config
55-
├── scripts/ The pre-push gate (gate-lease, smoke-servers, validate-py, coverage-py), its guards (verify-*),
55+
├── scripts/ The pre-push gate (gate-lease, smoke-servers, validate-py, coverage-py, interface-diff), its guards (verify-*),
5656
│ the skills tooling, release tooling (npm-publish-guard, prepare-python-release,
5757
│ pack-and-verify, release-manifest, release-notes), and the issue-filing sweeps
5858
│ (dependency-refresh, dependabot-alerts, sdk-watch)
@@ -61,8 +61,8 @@ servers/
6161
│ overview of how the rules, skills, gates and sweeps fit together
6262
├── .github/workflows/ typescript.yml, python.yml (per-package CI), release.yml (publishes on a GitHub Release),
6363
│ version-packages.yml (the changesets PR), prepare-python-release.yml (the CalVer PR),
64-
│ claude.yml (@claude mentions), and the scheduled sweeps that file issues:
65-
│ dependency-refresh.yml, dependabot-alerts.yml, sdk-watch.yml
64+
│ claude.yml (@claude mentions), everything-mcp-diff.yml (everything's interface diff on PRs),
65+
│ and the scheduled sweeps that file issues: dependency-refresh.yml, dependabot-alerts.yml, sdk-watch.yml
6666
├── .github/ISSUE_TEMPLATE/ Bug and feature issue forms; config.yml routes security and new servers away
6767
├── .github/pull_request_template.md The "issues, not PRs" banner that turns outside PRs away
6868
├── RELEASING.md How packages are versioned and published, and how to recover a failed publish
@@ -129,14 +129,15 @@ workspace's format check, lint, typecheck, build and tests), `coverage` (each
129129
TypeScript workspace's per-file coverage gate), `validate:py`
130130
(each Python server's locked sync, `ruff check`, `ruff format --check`,
131131
pyright, pytest and build), `coverage:py` (each Python server's per-file
132-
coverage gate), `verify:skills:cli`, and `smoke` (every server
133-
booted over each transport it implements). The stage-by-stage reference, and
134-
what CI runs where, is [`docs/quality-gate.md`](./docs/quality-gate.md);
132+
coverage gate), `verify:skills:cli`, `smoke` (every server booted over each
133+
transport it implements), and `interface-diff` (the `everything` server's MCP
134+
interface diffed against the base it branched from). The stage-by-stage
135+
reference, and what CI runs where, is [`docs/quality-gate.md`](./docs/quality-gate.md);
135136
diagnosing a red stage is the `pre-push-gate` skill.
136137

137138
- **`npm run validate` and the per-package commands above are the inner loop,
138-
not a substitute.** They skip the other language, the pinned skills validator
139-
and the boot smoke.
139+
not a substitute.** They skip the other language, the pinned skills validator,
140+
the boot smoke and the interface diff.
140141
- **Format before committing**: `npm run format` at the root (TypeScript), and
141142
`uv run --frozen ruff format .` in a Python server you changed. The gate only
142143
checks formatting; it never rewrites files.

0 commit comments

Comments
 (0)