Skip to content

Commit c04f40d

Browse files
committed
Add publish script and formed server file
1 parent 010cf9b commit c04f40d

File tree

3 files changed

+161
-1
lines changed

3 files changed

+161
-1
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ bin/
1717
.DS_Store
1818

1919
# binary
20-
github-mcp-server
20+
github-mcp-server
21+
22+
# Registry credentials - Created on publish
23+
.mcpregistry_github_token
24+
.mcpregistry_registry_token

script/publish-mcp-server

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
3+
# Publish MCP Server to Registry
4+
# Usage: ./script/publish-mcp-server [--init] [--validate] [--dry-run]
5+
6+
set -e
7+
8+
# Options
9+
INIT=false
10+
## Always validate server.json and version
11+
DRY_RUN=false
12+
13+
for arg in "$@"; do
14+
case $arg in
15+
--init)
16+
INIT=true
17+
;;
18+
# --validate flag removed; validation always runs
19+
--dry-run)
20+
DRY_RUN=true
21+
;;
22+
esac
23+
done
24+
25+
# Step 1: Ensure mcp-publisher is installed
26+
if ! command -v mcp-publisher &> /dev/null; then
27+
echo "mcp-publisher not found. Installing with Homebrew..."
28+
if command -v brew &> /dev/null; then
29+
brew install mcp-publisher
30+
else
31+
echo "Homebrew not found. Please install mcp-publisher manually:"
32+
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+
exit 1
34+
fi
35+
fi
36+
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.*)
44+
if ! mcp-publisher whoami &> /dev/null; then
45+
echo "Authenticating with MCP registry (GitHub)..."
46+
mcp-publisher login github
47+
fi
48+
49+
# Step 4: Validate server.json schema
50+
echo "Validating server.json version against latest release tag..."
51+
# Get latest release tag
52+
LATEST_TAG=$(git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$' | head -n 1)
53+
if [ -z "$LATEST_TAG" ]; then
54+
echo "❌ No release tag found. Cannot set version."
55+
exit 1
56+
fi
57+
TAG_VERSION=$(echo "$LATEST_TAG" | sed 's/^v//')
58+
# Set server.json version and all package versions to latest tag
59+
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
64+
echo
65+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
66+
echo "Publish cancelled by user."
67+
exit 1
68+
fi
69+
echo "✅ Confirmed. Proceeding with publish."
70+
71+
# Step 5: Publish
72+
if [ "$DRY_RUN" = true ]; then
73+
echo "DRY RUN: Skipping actual publish."
74+
else
75+
echo "Publishing MCP server..."
76+
mcp-publisher publish
77+
fi
78+
79+
# Step 6: Verify publication
80+
SERVER_NAME=$(jq -r .name server.json)
81+
echo "Verifying server in registry..."
82+
curl -s "https://registry.modelcontextprotocol.io/v0/servers?search=$SERVER_NAME" | jq
83+
84+
echo "Done."

server.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-09-16/server.schema.json",
3+
"name": "io.github.github/github-mcp-server",
4+
"description": "The GitHub MCP Server lets AI tools manage code, issues, PRs, and workflows via natural language.",
5+
"status": "active",
6+
"repository": {
7+
"url": "ssh://[email protected]/github/github-mcp-server",
8+
"source": "github"
9+
},
10+
"version": "0.15.0",
11+
"packages": [
12+
{
13+
"registryType": "oci",
14+
"registryBaseUrl": "https://docker.io",
15+
"identifier": "ghcr.io/github/github-mcp-server",
16+
"version": "0.15.0",
17+
"runtimeHint": "docker",
18+
"transport": {
19+
"type": "stdio"
20+
},
21+
"runtimeArguments": [
22+
{
23+
"type": "positional",
24+
"value": "run",
25+
"description": "The runtime command to execute"
26+
},
27+
{
28+
"type": "named",
29+
"name": "-i",
30+
"description": "Run container in interactive mode"
31+
},
32+
{
33+
"type": "named",
34+
"name": "--rm",
35+
"description": "Automatically remove the container when it exits"
36+
},
37+
{
38+
"type": "named",
39+
"name": "-e",
40+
"description": "Set an environment variable in the runtime"
41+
},
42+
{
43+
"type": "positional",
44+
"valueHint": "env_var_name",
45+
"value": "GITHUB_PERSONAL_ACCESS_TOKEN",
46+
"description": "Environment variable name"
47+
},
48+
{
49+
"type": "positional",
50+
"valueHint": "image_name",
51+
"value": "ghcr.io/github/github-mcp-server",
52+
"description": "The container image to run"
53+
}
54+
],
55+
"environmentVariables": [
56+
{
57+
"description": "Your GitHub personal access token with appropriate scopes.",
58+
"isRequired": true,
59+
"format": "string",
60+
"isSecret": true,
61+
"name": "GITHUB_PERSONAL_ACCESS_TOKEN"
62+
}
63+
]
64+
}
65+
],
66+
"remotes": [
67+
{
68+
"type": "streamable-http",
69+
"url": "https://api.githubcopilot.com/mcp/"
70+
}
71+
]
72+
}

0 commit comments

Comments
 (0)