|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | 3 | # Publish MCP Server to Registry |
4 | | -# Usage: ./script/publish-mcp-server [--init] [--validate] [--dry-run] |
| 4 | +# Usage: ./script/publish-mcp-server [--init] [--dry-run] |
5 | 5 |
|
6 | 6 | set -e |
7 | 7 |
|
8 | | -# Options |
| 8 | +# Parse command line options |
9 | 9 | INIT=false |
10 | | -## Always validate server.json and version |
11 | 10 | DRY_RUN=false |
12 | 11 |
|
13 | 12 | for arg in "$@"; do |
14 | 13 | case $arg in |
15 | 14 | --init) |
16 | 15 | INIT=true |
17 | 16 | ;; |
18 | | - # --validate flag removed; validation always runs |
19 | 17 | --dry-run) |
20 | 18 | DRY_RUN=true |
21 | 19 | ;; |
22 | 20 | esac |
23 | 21 | done |
24 | 22 |
|
25 | | -# Step 1: Ensure mcp-publisher is installed |
| 23 | +echo "🚀 Publishing GitHub MCP Server to Registry" |
| 24 | +echo "============================================" |
| 25 | + |
| 26 | +# Step 1: Ensure mcp-publisher CLI is installed |
| 27 | +echo "📦 Checking mcp-publisher installation..." |
26 | 28 | if ! command -v mcp-publisher &> /dev/null; then |
27 | | - echo "mcp-publisher not found. Installing with Homebrew..." |
| 29 | + echo "Installing mcp-publisher with Homebrew..." |
28 | 30 | if command -v brew &> /dev/null; then |
29 | 31 | brew install mcp-publisher |
30 | 32 | else |
31 | | - echo "Homebrew not found. Please install mcp-publisher manually:" |
| 33 | + echo "❌ Homebrew not found. Please install mcp-publisher manually:" |
32 | 34 | echo "curl -L \"https://github.com/modelcontextprotocol/registry/releases/download/v1.0.0/mcp-publisher_1.0.0_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz\" | tar xz mcp-publisher && sudo mv mcp-publisher /usr/local/bin/" |
33 | 35 | exit 1 |
34 | 36 | fi |
35 | 37 | fi |
| 38 | +echo "✅ mcp-publisher is available" |
36 | 39 |
|
37 | | -# Step 2: Initialize server.json if requested |
38 | | -if [ "$INIT" = true ]; then |
39 | | - echo "Initializing server.json..." |
40 | | - mcp-publisher init |
41 | | -fi |
42 | | - |
43 | | -# Step 3: Authenticate (GitHub for io.github.*) |
| 40 | +# Step 2: Authenticate with GitHub |
| 41 | +echo "" |
| 42 | +echo "🔐 Authenticating with MCP registry..." |
44 | 43 | if ! mcp-publisher whoami &> /dev/null; then |
45 | | - echo "Authenticating with MCP registry (GitHub)..." |
46 | 44 | mcp-publisher login github |
47 | 45 | fi |
| 46 | +echo "✅ Authentication successful" |
48 | 47 |
|
49 | | -# Step 4: Validate server.json schema |
50 | | -echo "Validating server.json version against latest release tag..." |
51 | | -# Get latest release tag |
| 48 | +# Step 3: Update version from latest git tag |
| 49 | +echo "" |
| 50 | +echo "🏷️ Updating server.json version..." |
52 | 51 | LATEST_TAG=$(git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$' | head -n 1) |
53 | 52 | if [ -z "$LATEST_TAG" ]; then |
54 | | - echo "❌ No release tag found. Cannot set version." |
| 53 | + echo "❌ No release tag found. Cannot determine version." |
55 | 54 | exit 1 |
56 | 55 | fi |
| 56 | + |
57 | 57 | TAG_VERSION=$(echo "$LATEST_TAG" | sed 's/^v//') |
58 | | -# Set server.json version and all package versions to latest tag |
59 | 58 | jq ".version = \"$TAG_VERSION\" | .packages[].version = \"$TAG_VERSION\"" server.json > server.json.tmp && mv server.json.tmp server.json |
60 | | -echo "Set server.json version and all package versions to $TAG_VERSION (from latest release tag $LATEST_TAG)." |
61 | | -# Show user and confirm |
62 | | -echo "Please confirm this is the correct version to publish: $TAG_VERSION (latest tag: $LATEST_TAG)" |
63 | | -read -p "Proceed with this version? (y/n) " -n 1 -r |
| 59 | + |
| 60 | +echo "✅ Updated server.json version to $TAG_VERSION (from git tag $LATEST_TAG)" |
| 61 | + |
| 62 | +# Step 4: User confirmation |
| 63 | +echo "" |
| 64 | +echo "📋 Version Summary:" |
| 65 | +echo " Latest git tag: $LATEST_TAG" |
| 66 | +echo " Server version: $TAG_VERSION" |
| 67 | +echo "" |
| 68 | +read -p "Proceed with publishing this version? (y/n) " -n 1 -r |
64 | 69 | echo |
65 | 70 | if [[ ! $REPLY =~ ^[Yy]$ ]]; then |
66 | | - echo "Publish cancelled by user." |
| 71 | + echo "❌ Publish cancelled by user." |
67 | 72 | exit 1 |
68 | 73 | fi |
69 | | -echo "✅ Confirmed. Proceeding with publish." |
70 | 74 |
|
71 | | -# Step 5: Publish |
| 75 | +# Step 5: Publish to registry |
| 76 | +echo "" |
72 | 77 | if [ "$DRY_RUN" = true ]; then |
73 | | - echo "DRY RUN: Skipping actual publish." |
| 78 | + echo "🧪 DRY RUN: Skipping actual publish step" |
74 | 79 | else |
75 | | - echo "Publishing MCP server..." |
| 80 | + echo "📤 Publishing to MCP registry..." |
76 | 81 | mcp-publisher publish |
| 82 | + echo "✅ Successfully published!" |
77 | 83 | fi |
78 | 84 |
|
79 | 85 | # Step 6: Verify publication |
| 86 | +echo "" |
| 87 | +echo "🔍 Verifying server in registry..." |
80 | 88 | SERVER_NAME=$(jq -r .name server.json) |
81 | | -echo "Verifying server in registry..." |
82 | 89 | curl -s "https://registry.modelcontextprotocol.io/v0/servers?search=$SERVER_NAME" | jq |
83 | 90 |
|
84 | | -echo "Done." |
| 91 | +echo "" |
| 92 | +echo "🎉 Done!" |
0 commit comments