|
| 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 |
0 commit comments