Skip to content

Commit a106f4d

Browse files
SeizyCclaude
andcommitted
ci: auto-publish MCP server to npm + Anthropic registry on mcp-v* tag
Drops the manual flow ('npm publish' + 'mcp-publisher login github' + 'mcp-publisher publish') used today for 0.1.1 in favor of a single `git tag mcp-v0.1.2 && git push --tags` that drives both publishes. Mechanics: · workflow rewrites mcp/package.json + mcp/server.json to the tag version before publishing so the version stays in one source of truth (the tag itself) · npm uses NPM_TOKEN secret (automation token, one-time repo setup) · MCP Registry uses GitHub OIDC — no secret · the workflow's id-token:write permission lets mcp-publisher exchange the OIDC credential for a registry JWT on the fly Tag format `mcp-v*` chosen so it can't collide with future CLI tags (which we'd ship as plain `v*`). Manual workflow_dispatch input also wired so we can re-publish a specific version from the Actions tab if the registry resets in preview (the docs explicitly warn it might). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ee835a2 commit a106f4d

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

.github/workflows/publish-mcp.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Publish commitshow-mcp to npm + the Anthropic MCP Registry on
2+
# every `mcp-v*` tag push. Tag format is `mcp-v0.1.2` (CLI tags use
3+
# `v*` separately so they don't collide).
4+
#
5+
# Auth model:
6+
# · npm — needs an automation token in the repo's NPM_TOKEN
7+
# secret (one-time setup; npm token create --type=automation)
8+
# · MCP — OIDC, no secret. The `id-token: write` permission below
9+
# lets `mcp-publisher login github-oidc` exchange the
10+
# workflow's OIDC credential for a registry JWT on the fly.
11+
#
12+
# Version sync: the workflow rewrites `mcp/package.json` and
13+
# `mcp/server.json` to match the tag, so a single `git tag mcp-v0.1.2
14+
# && git push --tags` drives both publishes from one source of truth.
15+
16+
name: Publish MCP server
17+
18+
on:
19+
push:
20+
tags: ["mcp-v*"]
21+
# Allow manual trigger from the Actions tab when something needs
22+
# re-publishing without a fresh tag (e.g. registry data reset).
23+
workflow_dispatch:
24+
inputs:
25+
version:
26+
description: "Version to publish (e.g. 0.1.2)"
27+
required: true
28+
type: string
29+
30+
jobs:
31+
publish:
32+
runs-on: ubuntu-latest
33+
permissions:
34+
id-token: write
35+
contents: read
36+
steps:
37+
- uses: actions/checkout@v5
38+
39+
- uses: actions/setup-node@v5
40+
with:
41+
node-version: "lts/*"
42+
registry-url: "https://registry.npmjs.org"
43+
44+
- name: Resolve version (tag or input)
45+
id: ver
46+
run: |
47+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
48+
echo "version=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
49+
else
50+
# tags/mcp-v0.1.2 → 0.1.2
51+
echo "version=${GITHUB_REF#refs/tags/mcp-v}" >> "$GITHUB_OUTPUT"
52+
fi
53+
54+
- name: Sync version into package.json + server.json
55+
working-directory: mcp
56+
run: |
57+
V="${{ steps.ver.outputs.version }}"
58+
jq --arg v "$V" '.version = $v' package.json > package.tmp && mv package.tmp package.json
59+
jq --arg v "$V" '.version = $v | .packages[0].version = $v' server.json > server.tmp && mv server.tmp server.json
60+
echo "Synced both to v$V"
61+
62+
- name: Install + build
63+
working-directory: mcp
64+
run: |
65+
npm ci
66+
npm run build
67+
68+
- name: Publish to npm
69+
working-directory: mcp
70+
run: npm publish --access public
71+
env:
72+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
73+
74+
- name: Install mcp-publisher
75+
run: |
76+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
77+
ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
78+
curl -fsSL "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_${OS}_${ARCH}.tar.gz" \
79+
| tar xz mcp-publisher
80+
sudo mv mcp-publisher /usr/local/bin/
81+
mcp-publisher --help
82+
83+
- name: Authenticate to MCP Registry (OIDC)
84+
working-directory: mcp
85+
run: mcp-publisher login github-oidc
86+
87+
- name: Publish to MCP Registry
88+
working-directory: mcp
89+
run: mcp-publisher publish

0 commit comments

Comments
 (0)