Skip to content

Update MCP Registry #13

Update MCP Registry

Update MCP Registry #13

name: Update MCP Registry
on:
workflow_run:
workflows: ["Build and Push Docker Image"]
types:
- completed
jobs:
check-and-update-registry:
# Only run on tag pushes and if the docker workflow succeeded
if: |
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
startsWith(github.event.workflow_run.head_branch, 'v')
runs-on: ubuntu-latest
permissions:
id-token: write # Required for GitHub OIDC authentication with MCP Registry
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Wait for PyPI release to complete
uses: fountainhead/[email protected]
id: wait-for-pypi
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: "Build and publish Python distributions to PyPI"
ref: ${{ github.event.workflow_run.head_sha }}
timeoutSeconds: 600
intervalSeconds: 10
- name: Check PyPI release status
if: steps.wait-for-pypi.outputs.conclusion != 'success'
run: |
echo "PyPI release did not succeed. Status: ${{ steps.wait-for-pypi.outputs.conclusion }}"
exit 1
- name: Validate version consistency
id: version
env:
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
run: |
# Read versions from files
ROOT_VERSION=$(jq -r '.version' server.json)
# Only get versions from packages that have a version field (exclude null/empty)
PACKAGE_VERSIONS=$(jq -r '.packages[] | select(.version != null) | .version' server.json | sort -u)
PYPROJECT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
# Get tag from the triggering workflow (Docker), not current workflow
# Use environment variable to prevent code injection
TAG_VERSION=${HEAD_BRANCH#v}
echo "Version Check:"
echo " server.json root: $ROOT_VERSION"
echo " server.json packages:"
jq -r '.packages[] |
if .version != null then
" - \(.registryType):\(.identifier) = \(.version)"
else
" - \(.registryType):\(.identifier) (no version field)"
end' server.json
echo " pyproject.toml: $PYPROJECT_VERSION"
echo " Git tag: $TAG_VERSION"
echo ""
# Check if all package versions match root version (only for packages with version field)
MISMATCH=false
if [ -n "$PACKAGE_VERSIONS" ]; then
while IFS= read -r pkg_ver; do
if [ "$pkg_ver" != "$ROOT_VERSION" ]; then
echo "ERROR: Package version ($pkg_ver) doesn't match root version ($ROOT_VERSION)"
MISMATCH=true
fi
done <<< "$PACKAGE_VERSIONS"
fi
if [ "$MISMATCH" = true ]; then
echo ""
echo "Fix: Update server.json so all package versions match the root version"
exit 1
fi
# Check if root version matches tag
if [ "$ROOT_VERSION" != "$TAG_VERSION" ]; then
echo "ERROR: server.json version ($ROOT_VERSION) doesn't match tag ($TAG_VERSION)"
echo "Fix: Update server.json root version to match the tag"
exit 1
fi
# Warn if pyproject.toml doesn't match
if [ "$PYPROJECT_VERSION" != "$TAG_VERSION" ]; then
echo "WARNING: pyproject.toml version ($PYPROJECT_VERSION) doesn't match tag ($TAG_VERSION)"
echo "This may cause PyPI issues"
fi
# Check Docker image tags in OCI identifiers
echo ""
echo "Checking Docker image tags..."
OCI_PACKAGES=$(jq -r '.packages[] | select(.registryType == "oci") | .identifier' server.json)
if [ -n "$OCI_PACKAGES" ]; then
OCI_TAG_MISMATCH=false
while IFS= read -r oci_id; do
# Extract tag from identifier (everything after last :)
IMAGE_TAG="${oci_id##*:}"
echo " - Image: $oci_id"
echo " Tag: $IMAGE_TAG"
if [ "$IMAGE_TAG" != "$ROOT_VERSION" ]; then
echo " ERROR: Docker image tag ($IMAGE_TAG) doesn't match version ($ROOT_VERSION)"
OCI_TAG_MISMATCH=true
else
echo " Tag matches"
fi
done <<< "$OCI_PACKAGES"
if [ "$OCI_TAG_MISMATCH" = true ]; then
echo ""
echo "Fix: Update Docker image tags in server.json to match the version"
exit 1
fi
fi
echo ""
echo "All version checks passed!"
echo "version=$ROOT_VERSION" >> $GITHUB_OUTPUT
- name: Install MCP Publisher
run: |
curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher
- name: Login to MCP Registry
run: ./mcp-publisher login github-oidc
- name: Publish to MCP Registry
run: ./mcp-publisher publish
- name: Notify completion
if: success()
run: |
echo "MCP Registry updated successfully for version ${{ steps.version.outputs.version }}"
echo "Docker image: docker.io/couchbaseecosystem/mcp-server-couchbase:${{ steps.version.outputs.version }}"
echo "PyPI package: couchbase-mcp-server==${{ steps.version.outputs.version }}"