|
| 1 | +name: Publish to MCP Registry |
| 2 | + |
| 3 | +# Publishes server.json to the Official MCP Registry (registry.modelcontextprotocol.io) as |
| 4 | +# io.github.tester-army/testerarmy, which feeds Glama, PulseMCP and the other aggregators. |
| 5 | +# |
| 6 | +# Authentication is GitHub Actions OIDC: the registry grants the io.github.<repository owner>/* |
| 7 | +# namespace to workflows running in this organisation's repositories. A personal |
| 8 | +# `mcp-publisher login github` only gets that namespace for org Owners (plain members are refused), |
| 9 | +# so this workflow is the route that needs nobody's personal login and no stored secret. |
| 10 | +# |
| 11 | +# Runs when server.json (or this file) lands on main, and on demand from the Actions tab. Manual |
| 12 | +# runs are limited to main because the registry authorises on the repository owner alone and never |
| 13 | +# looks at the branch: without the guard, any writer could publish an unreviewed branch under the |
| 14 | +# org name. The `mcp-registry-publish` environment exists so an org Owner can add a deployment |
| 15 | +# branch rule and a required reviewer in Settings > Environments without touching this file; until |
| 16 | +# then the `if:` below is the gate. |
| 17 | +# |
| 18 | +# The registry refuses a version it already has, so the job first checks whether server.json's |
| 19 | +# version is published and skips cleanly if so. To publish again, bump "version" in server.json |
| 20 | +# together with the plugin manifests; scripts/check-plugin-manifests.sh fails if they differ. |
| 21 | + |
| 22 | +on: |
| 23 | + push: |
| 24 | + branches: [main] |
| 25 | + paths: |
| 26 | + - "server.json" |
| 27 | + - ".github/workflows/publish-mcp-registry.yml" |
| 28 | + workflow_dispatch: |
| 29 | + |
| 30 | +permissions: |
| 31 | + contents: read |
| 32 | + |
| 33 | +jobs: |
| 34 | + publish: |
| 35 | + if: github.ref == 'refs/heads/main' |
| 36 | + runs-on: ubuntu-latest |
| 37 | + environment: mcp-registry-publish |
| 38 | + # One publish at a time; a parallel run for the same version would only fail. |
| 39 | + concurrency: publish-mcp-registry |
| 40 | + permissions: |
| 41 | + id-token: write # OIDC token exchanged with the registry |
| 42 | + contents: read |
| 43 | + env: |
| 44 | + # If "login github-oidc" fails with "invalid audience", the registry moved ahead of this |
| 45 | + # binary: bump to the latest release at https://github.com/modelcontextprotocol/registry/releases |
| 46 | + MCP_PUBLISHER_VERSION: "1.8.1" |
| 47 | + REGISTRY_URL: https://registry.modelcontextprotocol.io |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v5 |
| 50 | + |
| 51 | + - name: Install mcp-publisher (download checksum verified) |
| 52 | + run: | |
| 53 | + base="https://github.com/modelcontextprotocol/registry/releases/download/v${MCP_PUBLISHER_VERSION}" |
| 54 | + curl -fsSL --retry 3 "$base/mcp-publisher_linux_amd64.tar.gz" -o mcp-publisher_linux_amd64.tar.gz |
| 55 | + curl -fsSL --retry 3 "$base/registry_${MCP_PUBLISHER_VERSION}_checksums.txt" -o checksums.txt |
| 56 | + sha256sum --check --ignore-missing checksums.txt |
| 57 | + tar xzf mcp-publisher_linux_amd64.tar.gz mcp-publisher |
| 58 | + ./mcp-publisher --version |
| 59 | +
|
| 60 | + # The registry's own validator: schema plus the semantic rules the publish endpoint applies. |
| 61 | + - name: Validate server.json against the registry |
| 62 | + run: ./mcp-publisher validate server.json |
| 63 | + |
| 64 | + - name: Skip if this version is already published |
| 65 | + id: check |
| 66 | + run: | |
| 67 | + name=$(jq -r .name server.json) |
| 68 | + version=$(jq -r .version server.json) |
| 69 | + encoded=$(jq -rn --arg n "$name" '$n | @uri') |
| 70 | + if curl -fsS -o /dev/null "$REGISTRY_URL/v0/servers/$encoded/versions/$version"; then |
| 71 | + echo "::notice::$name@$version is already in the registry; bump version in server.json to publish again" |
| 72 | + echo "skip=true" >> "$GITHUB_OUTPUT" |
| 73 | + fi |
| 74 | +
|
| 75 | + - name: Log in with GitHub Actions OIDC |
| 76 | + if: steps.check.outputs.skip != 'true' |
| 77 | + run: ./mcp-publisher login github-oidc |
| 78 | + |
| 79 | + - name: Publish |
| 80 | + if: steps.check.outputs.skip != 'true' |
| 81 | + run: ./mcp-publisher publish server.json |
| 82 | + |
| 83 | + # Exact lookup: 404 (and a failed step) if the version is not there. |
| 84 | + - name: Confirm the registry entry |
| 85 | + run: | |
| 86 | + set -euo pipefail |
| 87 | + name=$(jq -r .name server.json) |
| 88 | + version=$(jq -r .version server.json) |
| 89 | + encoded=$(jq -rn --arg n "$name" '$n | @uri') |
| 90 | + entry=$(curl -fsS --retry 3 "$REGISTRY_URL/v0/servers/$encoded/versions/$version" \ |
| 91 | + | jq '{name: .server.name, version: .server.version, status: ._meta["io.modelcontextprotocol.registry/official"].status, isLatest: ._meta["io.modelcontextprotocol.registry/official"].isLatest, publishedAt: ._meta["io.modelcontextprotocol.registry/official"].publishedAt}') |
| 92 | + echo "$entry" |
| 93 | + { |
| 94 | + echo "### MCP Registry: $name@$version" |
| 95 | + echo '```json' |
| 96 | + echo "$entry" |
| 97 | + echo '```' |
| 98 | + echo "Glama connector page (claim it once it appears): https://glama.ai/mcp/connectors/$name" |
| 99 | + } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments