name: Publish to MCP Registry
on:
push:
tags:
- "v*.*.*" # Triggers on version tags like v1.0.0
workflow_dispatch: # Allow manual triggering
jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write # Required for GitHub OIDC authentication
contents: write # Required to create GitHub Releases
env:
MCP_PUBLISHER_VERSION: "1.2.3"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test || echo "No tests found, skipping"
- name: Build package
run: npm run build
- name: Build Desktop Extension (.mcpb)
run: |
chmod +x scripts/build-mcpb.sh
./scripts/build-mcpb.sh
- name: Verify .mcpb file was created
run: |
if [ ! -f "hn-mcp.mcpb" ]; then
echo "Error: hn-mcp.mcpb not found!"
exit 1
fi
ls -lh hn-mcp.mcpb
echo "✅ All build artifacts ready"
- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install MCP Publisher
run: |
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
ARCH="amd64"
elif [ "$ARCH" = "aarch64" ]; then
ARCH="arm64"
fi
curl -L "https://github.com/modelcontextprotocol/registry/releases/download/v${{ env.MCP_PUBLISHER_VERSION }}/mcp-publisher_${{ env.MCP_PUBLISHER_VERSION }}_linux_${ARCH}.tar.gz" -o mcp-publisher.tar.gz
tar xzf mcp-publisher.tar.gz
chmod +x ./mcp-publisher
./mcp-publisher --version
- name: Login to MCP Registry
run: ./mcp-publisher login github-oidc
- name: Publish to MCP Registry
run: |
./mcp-publisher publish
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
echo "::error::MCP Publisher failed to publish the server (exit code: $EXIT_CODE)"
exit 1
fi
echo "✅ Successfully published to MCP Registry"
- name: Verify MCP Registry Publication
run: |
echo "⏳ Waiting 30 seconds for registry to update..."
sleep 30
echo "🔍 Checking registry for published server..."
RESPONSE=$(curl -s "https://registry.modelcontextprotocol.io/servers/io.github.karanb192/hn-mcp" || echo "")
if [ -z "$RESPONSE" ]; then
echo "::warning::Could not verify publication - registry may be updating"
else
echo "✅ Server found in registry!"
echo "$RESPONSE" | head -20
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Extract version
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Building Docker image version: $VERSION"
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
karanb192/hn-mcp:latest
karanb192/hn-mcp:${{ steps.version.outputs.VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: hn-mcp.mcpb
generate_release_notes: true
body: |
## Installation
### Claude Desktop (.mcpb file)
Download the `hn-mcp.mcpb` file from this release and install it in Claude Desktop.
### Claude Desktop (via config)
Add to your `claude_desktop_config.json`:
```json
{
"mcpServers": {
"hn": {
"command": "npx",
"args": ["hn-mcp"]
}
}
}
```
### npm
```bash
npm install -g hn-mcp
hn-mcp
```
### Docker
```bash
# HTTP mode
docker run -e HN_MCP_HTTP=true -p 3000:3000 karanb192/hn-mcp:${{ steps.version.outputs.VERSION }}
# stdio mode (for development)
docker run -it karanb192/hn-mcp:${{ steps.version.outputs.VERSION }}
```
### MCP Registry
This package is published to the [MCP Registry](https://registry.modelcontextprotocol.io/servers/io.github.karanb192/hn-mcp).
See [README](https://github.com/karanb192/hn-mcp) for more details.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}