|
| 1 | +name: MCP Registry |
| 2 | + |
| 3 | +# Publish server.json to the official MCP registry |
| 4 | +# (registry.modelcontextprotocol.io) as io.github.arctop/seamless, which |
| 5 | +# PulseMCP and the other aggregators index downstream from. release.yml calls |
| 6 | +# this once a v* tag's release is published and its signatures verified. Run it |
| 7 | +# by hand to publish a release the automatic run missed: |
| 8 | +# `gh workflow run mcp-registry.yml -f tag=vX.Y.Z`. |
| 9 | +# |
| 10 | +# Auth is GitHub Actions OIDC, so there is no secret to keep or rotate: |
| 11 | +# `mcp-publisher login github-oidc` trades this job's short-lived ID token for a |
| 12 | +# registry JWT, and the registry grants io.github.<repository_owner>/* from the |
| 13 | +# token's repository_owner claim. That is why it works for an org namespace |
| 14 | +# where the interactive `login github` (a GitHub App) does not |
| 15 | +# (modelcontextprotocol/registry#1468). |
| 16 | +on: |
| 17 | + workflow_call: |
| 18 | + inputs: |
| 19 | + tag: |
| 20 | + description: Release tag to publish (vX.Y.Z) |
| 21 | + required: true |
| 22 | + type: string |
| 23 | + workflow_dispatch: |
| 24 | + inputs: |
| 25 | + tag: |
| 26 | + description: Release tag to publish (vX.Y.Z) |
| 27 | + required: true |
| 28 | + type: string |
| 29 | + |
| 30 | +# id-token: write is the OIDC token above; nothing here writes to the repo. |
| 31 | +permissions: |
| 32 | + contents: read |
| 33 | + id-token: write |
| 34 | + |
| 35 | +jobs: |
| 36 | + publish: |
| 37 | + # A fork's OIDC token names the fork's owner, which the registry refuses |
| 38 | + # for io.github.arctop/*, so a fork would only ever fail here. |
| 39 | + if: github.repository == 'arctop/seamless' |
| 40 | + runs-on: ubuntu-latest |
| 41 | + timeout-minutes: 10 |
| 42 | + defaults: |
| 43 | + run: |
| 44 | + shell: bash |
| 45 | + steps: |
| 46 | + # Third-party actions are pinned to full commit SHAs, as in release.yml. |
| 47 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 48 | + with: |
| 49 | + ref: refs/tags/${{ inputs.tag }} |
| 50 | + persist-credentials: false |
| 51 | + |
| 52 | + # Decide whether to publish. The tag reaches the script through env:, |
| 53 | + # never as an expression inside run:, so no input text is spliced into |
| 54 | + # shell source. |
| 55 | + # - server.json's version must be the tag's: the prep commit bumps it |
| 56 | + # (docs-check keeps the agent and server cards in step), and a release |
| 57 | + # cut without the bump must fail loudly, not publish the old version. |
| 58 | + # - Only a published, non-prerelease release goes out. The registry |
| 59 | + # ranks versions by semver, so a v0.8.0-rc.1 would become its latest; |
| 60 | + # and marking a release prerelease is how a bad one is yanked |
| 61 | + # (release.yml), which must keep it out of the registry too. |
| 62 | + # - A version the registry already serves is skipped, not re-sent (the |
| 63 | + # registry refuses a duplicate), so re-running this is safe. |
| 64 | + - name: Check the release and the registry |
| 65 | + id: gate |
| 66 | + env: |
| 67 | + TAG: ${{ inputs.tag }} |
| 68 | + GH_TOKEN: ${{ github.token }} |
| 69 | + run: | |
| 70 | + case "$TAG" in |
| 71 | + v[0-9]*.[0-9]*.[0-9]*) ;; |
| 72 | + *) echo "::error::tag must be vX.Y.Z, got $TAG"; exit 1 ;; |
| 73 | + esac |
| 74 | + name=$(jq -r .name server.json) |
| 75 | + version=$(jq -r .version server.json) |
| 76 | + if [ "$version" != "${TAG#v}" ]; then |
| 77 | + echo "::error::server.json version is $version at $TAG; the prep commit must bump it to ${TAG#v}" |
| 78 | + exit 1 |
| 79 | + fi |
| 80 | + state=$(gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json isDraft,isPrerelease -q '"\(.isDraft) \(.isPrerelease)"') |
| 81 | + if [ "$state" != "false false" ]; then |
| 82 | + echo "::notice::$TAG is a draft or prerelease (isDraft isPrerelease = $state); not publishing it" |
| 83 | + echo "publish=false" >> "$GITHUB_OUTPUT" |
| 84 | + exit 0 |
| 85 | + fi |
| 86 | + url="https://registry.modelcontextprotocol.io/v0/servers/$(jq -rn --arg n "$name" '$n|@uri')/versions/$version" |
| 87 | + code=$(curl -sS -o /dev/null -w '%{http_code}' --retry 5 --retry-all-errors "$url" || true) |
| 88 | + case "$code" in |
| 89 | + 200) echo "::notice::the registry already serves $name $version"; echo "publish=false" >> "$GITHUB_OUTPUT" ;; |
| 90 | + 404) echo "publish=true" >> "$GITHUB_OUTPUT" ;; |
| 91 | + *) echo "::error::registry lookup for $name $version returned HTTP $code"; exit 1 ;; |
| 92 | + esac |
| 93 | + echo "url=$url" >> "$GITHUB_OUTPUT" |
| 94 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
| 95 | +
|
| 96 | + # Pinned to a release and checked against the sha256 that release |
| 97 | + # publishes for this tarball (registry_<ver>_checksums.txt). Dependabot |
| 98 | + # cannot see this pin: bump the version and the hash together. |
| 99 | + - name: Install mcp-publisher |
| 100 | + if: steps.gate.outputs.publish == 'true' |
| 101 | + env: |
| 102 | + MCP_PUBLISHER_VERSION: v1.8.1 |
| 103 | + MCP_PUBLISHER_SHA256: a06c9096dcb9727c13555b6be26c7effa707b01f06a4c561ba7a3635443cf2cc |
| 104 | + run: | |
| 105 | + tarball=mcp-publisher_linux_amd64.tar.gz |
| 106 | + curl -fsSL --retry 5 --retry-all-errors -o "$RUNNER_TEMP/$tarball" \ |
| 107 | + "https://github.com/modelcontextprotocol/registry/releases/download/$MCP_PUBLISHER_VERSION/$tarball" |
| 108 | + echo "$MCP_PUBLISHER_SHA256 $RUNNER_TEMP/$tarball" | sha256sum -c - |
| 109 | + tar -xzf "$RUNNER_TEMP/$tarball" -C "$RUNNER_TEMP" mcp-publisher |
| 110 | +
|
| 111 | + # Login and publish back to back: the registry JWT expires within |
| 112 | + # minutes. publish reads server.json from the checkout. |
| 113 | + - name: Publish |
| 114 | + if: steps.gate.outputs.publish == 'true' |
| 115 | + run: | |
| 116 | + "$RUNNER_TEMP/mcp-publisher" login github-oidc |
| 117 | + "$RUNNER_TEMP/mcp-publisher" publish |
| 118 | +
|
| 119 | + - name: Verify the registry serves it |
| 120 | + if: steps.gate.outputs.publish == 'true' |
| 121 | + env: |
| 122 | + URL: ${{ steps.gate.outputs.url }} |
| 123 | + VERSION: ${{ steps.gate.outputs.version }} |
| 124 | + run: curl -fsS --retry 5 --retry-all-errors "$URL" | jq -e --arg v "$VERSION" '.server.version == $v' |
0 commit comments