|
| 1 | +name: Claude Desktop extension |
| 2 | + |
| 3 | +# Builds the Claude Desktop extension (.mcpb) from manifest.json and attaches it to the GitHub |
| 4 | +# release, so Claude Desktop users can install the server with one click. Pull requests that touch |
| 5 | +# the manifest or this workflow only build and validate the bundle. Run it by hand with a tag |
| 6 | +# (workflow_dispatch) to attach a bundle to a release that is missing one. |
| 7 | + |
| 8 | +on: |
| 9 | + release: |
| 10 | + types: [published] |
| 11 | + pull_request: |
| 12 | + branches: [main] |
| 13 | + paths: |
| 14 | + - "manifest.json" |
| 15 | + - "icon.png" |
| 16 | + - ".github/workflows/mcpb.yml" |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + tag: |
| 20 | + description: "Release tag to build and attach the bundle to (for example v0.8.0)" |
| 21 | + required: true |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read |
| 25 | + |
| 26 | +concurrency: |
| 27 | + group: mcpb-${{ github.event.release.tag_name || inputs.tag || github.ref }} |
| 28 | + cancel-in-progress: false |
| 29 | + |
| 30 | +env: |
| 31 | + MCPB_VERSION: "2.1.2" |
| 32 | + |
| 33 | +jobs: |
| 34 | + build: |
| 35 | + runs-on: ubuntu-26.04 |
| 36 | + timeout-minutes: 15 |
| 37 | + steps: |
| 38 | + - name: Checkout code |
| 39 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 40 | + with: |
| 41 | + ref: ${{ github.event.release.tag_name || inputs.tag || github.ref }} |
| 42 | + persist-credentials: false |
| 43 | + |
| 44 | + - name: Setup Node.js |
| 45 | + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 |
| 46 | + with: |
| 47 | + node-version: 22.x |
| 48 | + package-manager-cache: false # release builds must not restore a cache a PR could have written |
| 49 | + |
| 50 | + - name: Check that the tag matches manifest.json |
| 51 | + if: github.event_name != 'pull_request' |
| 52 | + env: |
| 53 | + TAG: ${{ github.event.release.tag_name || inputs.tag }} |
| 54 | + run: | |
| 55 | + set -euo pipefail |
| 56 | + v=$(jq -r .version manifest.json) |
| 57 | + [ "$TAG" = "v$v" ] || { echo "::error::tag $TAG does not match manifest.json version $v"; exit 1; } |
| 58 | +
|
| 59 | + - name: Build |
| 60 | + run: | |
| 61 | + yarn install --frozen-lockfile |
| 62 | + yarn build |
| 63 | +
|
| 64 | + # Pack from a staging directory with only what the extension runs: the build output and |
| 65 | + # production dependencies, not the source tree, tests or dev dependencies. |
| 66 | + - name: Validate and pack the bundle |
| 67 | + run: | |
| 68 | + set -euo pipefail |
| 69 | + v=$(jq -r .version manifest.json) |
| 70 | + mkdir stage |
| 71 | + cp -r manifest.json icon.png package.json yarn.lock LICENSE README.md dist stage/ |
| 72 | + (cd stage && yarn install --production --frozen-lockfile --ignore-scripts --non-interactive) |
| 73 | + npx -y "@anthropic-ai/mcpb@${MCPB_VERSION}" validate stage/manifest.json |
| 74 | + npx -y "@anthropic-ai/mcpb@${MCPB_VERSION}" pack stage "localstack-mcp-server-${v}.mcpb" |
| 75 | + echo "MCPB_FILE=localstack-mcp-server-${v}.mcpb" >> "$GITHUB_ENV" |
| 76 | +
|
| 77 | + - name: Smoke-test the bundle |
| 78 | + run: | |
| 79 | + set -euo pipefail |
| 80 | + mkdir smoke && unzip -q "$MCPB_FILE" -d smoke |
| 81 | + printf '%s\n' \ |
| 82 | + '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"ci","version":"1"}}}' \ |
| 83 | + '{"jsonrpc":"2.0","method":"notifications/initialized"}' \ |
| 84 | + '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' \ |
| 85 | + | (cd smoke && timeout 20 node dist/cli.js || true) > smoke.out |
| 86 | + tools=$(grep '"id":2' smoke.out | jq '.result.tools | length') |
| 87 | + echo "tools/list returned $tools tools" |
| 88 | + [ "${tools:-0}" -gt 0 ] || { echo "::error::the packed server did not list any tools"; cat smoke.out; exit 1; } |
| 89 | +
|
| 90 | + - name: Upload the bundle as a workflow artifact |
| 91 | + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 92 | + with: |
| 93 | + name: mcpb |
| 94 | + path: ${{ env.MCPB_FILE }} |
| 95 | + if-no-files-found: error |
| 96 | + |
| 97 | + attach: |
| 98 | + needs: build |
| 99 | + if: github.event_name != 'pull_request' |
| 100 | + runs-on: ubuntu-26.04 |
| 101 | + timeout-minutes: 5 |
| 102 | + permissions: |
| 103 | + contents: write # upload the .mcpb to the release |
| 104 | + steps: |
| 105 | + - name: Download the bundle |
| 106 | + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 |
| 107 | + with: |
| 108 | + name: mcpb |
| 109 | + |
| 110 | + - name: Attach the bundle to the release |
| 111 | + env: |
| 112 | + GH_TOKEN: ${{ github.token }} |
| 113 | + GH_REPO: ${{ github.repository }} |
| 114 | + TAG: ${{ github.event.release.tag_name || inputs.tag }} |
| 115 | + run: gh release upload "$TAG" localstack-mcp-server-*.mcpb --clobber |
0 commit comments