Wielded Claude Code to do this; across many iterations and have reviewed all the code + largely rewritten the PR commentary here. This PR implements the server ID consistency changes from [#396](https://github.com/modelcontextprotocol/registry/issues/396). Our goal is to: - Rename `id` to `versionId` to make it clear that it is the ID for a specific version, not a server - Introduce `serverId` as a net new concept. This will be 1:1 with `name`. While not strictly necessary (we could just use name as a PK), the convention of having a UUID as an ID on our objects is just a helpful subjective architecture decision. Plus also leaves open the door to reconsidering the "should we allow renames" question. ## Key Changes ### 🗄️ Database Schema Changes - **Renamed**: `id` column → `version_id` (unique identifier for each server version) ### 📋 Metadata Structure Updates - **JSON Schema**: Updated `_meta.io.modelcontextprotocol.registry/official` to include: - `serverId`: Consistent ID across all versions of a server - `versionId`: Unique ID for this specific version (renamed from `id`) ### 🔧 API Endpoint Updates - **New endpoint structure**: Changed from version-ID-based to server-ID-based URLs: - `GET /v0/servers/{server_id}` - Get latest version of server - `GET /v0/servers/{server_id}?version=X.X.X` - Get specific version - `GET /v0/servers/{server_id}/versions` - List all versions of a server - `PUT /v0/servers/{server_id}?version=X.X.X` - Edit specific version - **Consistent URL patterns**: All server endpoints now use `server_id` as the primary identifier ### Database Migration Strategy The migration (`005_add_server_id_rename_version_id.sql`): 1. Adds new `version_id` column 2. Generates deterministic UUIDs for servers with the same name 3. Updates JSON metadata to add `serverId` and rename `id` to `versionId` 4. Copies existing `id` values to `version_id` column 5. Drops old `id` column and makes `version_id` the new primary key ## Testing Besides of course automated tests passing, I: 1. Set up my local db with the pre-005-migration state, imported all the production data 2. Ran the migration 3. Spot checked some diffs of the data that resulted -- ```json // before { "name": "io.github.ruvnet/ruv-swarm", "_meta": { "io.modelcontextprotocol.registry/official": { "id": "0a9cda7f-2b73-4839-844b-6582f335de42", "is_latest": false, "updated_at": "2025-09-10T17:21:34.92137012Z", "published_at": "2025-09-10T17:15:32.69690433Z" } }, "version": "1.0.18", "repository": { "url": "", "source": "" }, "description": "Neural network swarm orchestration with WebAssembly acceleration and MCP integration" } // after { "name": "io.github.ruvnet/ruv-swarm", "_meta": { "io.modelcontextprotocol.registry/official": { "serverId": "e8538952-96af-4a33-9e31-7fbed012521e", "is_latest": false, "versionId": "0a9cda7f-2b73-4839-844b-6582f335de42", "updated_at": "2025-09-10T17:21:34.92137012Z", "published_at": "2025-09-10T17:15:32.69690433Z" } }, "version": "1.0.18", "repository": { "url": "", "source": "" }, "description": "Neural network swarm orchestration with WebAssembly acceleration and MCP integration" } ``` Servers that have multiple versions stayed consistent in their `serverId`: ```json // First version { "name": "app.getdialer/dialer", "_meta": { "io.modelcontextprotocol.registry/official": { "serverId": "80f08bdb-f3e4-4f19-b072-1676ae49b663", "is_latest": false, "versionId": "04f25b17-331d-48d7-b08b-37baece208a7", "updated_at": "2025-09-09T00:16:49.162620072Z", "published_at": "2025-09-08T23:47:09.452137971Z" } }, "status": "active", "$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json", "remotes": [ { "url": "https://getdialer.app/mcp", "type": "streamable-http" }, { "url": "https://getdialer.app/sse", "type": "sse" } ], "version": "1.0.0", "repository": { "url": "", "source": "" }, "description": "An MCP server that provides your you make outbound phone calls using your own phone number" } // Second version { "name": "app.getdialer/dialer", "_meta": { "io.modelcontextprotocol.registry/official": { "serverId": "80f08bdb-f3e4-4f19-b072-1676ae49b663", "is_latest": true, "versionId": "faa26cb9-3aad-415e-aece-f715fff5fe5e", "updated_at": "2025-09-09T00:16:49.107842808Z", "published_at": "2025-09-09T00:16:49.107842808Z" } }, "status": "active", "$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json", "remotes": [ { "url": "https://getdialer.app/mcp", "type": "streamable-http" }, { "url": "https://getdialer.app/sse", "type": "sse" } ], "version": "1.0.1", "repository": { "url": "", "source": "" }, "description": "An MCP server that provides lets you make outbound phone calls using your own phone number" } ``` And I also tried publishing a test server anew; looked good: ```bash ⏺ Bash(curl -s "http://localhost:8080/v0/servers/102dc4e4-6ca8-40e6-aa11-cd45763d3352" | jq '.') ⎿ { "$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json", "name": "io.modelcontextprotocol.anonymous/test-claude-migration-server", "description": "A test server to verify the new migration and API endpoints work correctly", "status": "active", "repository": { "url": "https://github.com/example/test-claude-migration-server", "source": "github", "id": "example/test-claude-migration-server" }, "version": "1.0.0", "_meta": { "io.modelcontextprotocol.registry/official": { "serverId": "102dc4e4-6ca8-40e6-aa11-cd45763d3352", "versionId": "48c9cd55-7bc4-4ac2-896e-59e81eb653e4", "published_at": "2025-09-12T18:33:23.264203-07:00", "updated_at": "2025-09-12T18:33:23.264203-07:00", "is_latest": true } } } ⏺ Bash(curl -s "http://localhost:8080/v0/servers/102dc4e4-6ca8-40e6-aa11-cd45763d3352/versions" | jq '.') ⎿ { "servers": [ { "$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json", "name": "io.modelcontextprotocol.anonymous/test-claude-migration-server", "description": "A test server to verify the new migration and API endpoints work correctly", "status": "active", "repository": { "url": "https://github.com/example/test-claude-migration-server", "source": "github", "id": "example/test-claude-migration-server" }, "version": "1.0.0", "_meta": { "io.modelcontextprotocol.registry/official": { "serverId": "102dc4e4-6ca8-40e6-aa11-cd45763d3352", "versionId": "48c9cd55-7bc4-4ac2-896e-59e81eb653e4", "published_at": "2025-09-12T18:33:23.264203-07:00", "updated_at": "2025-09-12T18:33:23.264203-07:00", "is_latest": true } } } ], "metadata": { "count": 1 } } ``` Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Preeti Dewani <preetidewani1990@gmail.com> Co-authored-by: adam jones <adamj+git@anthropic.com> Co-authored-by: Adam Jones <adamj@anthropic.com>
225 lines
6.9 KiB
Shell
Executable file
225 lines
6.9 KiB
Shell
Executable file
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
echo "=================================================="
|
|
echo "MCP Registry Publish Endpoint Test Script"
|
|
echo "=================================================="
|
|
echo "This script expects the MCP Registry server to be running locally."
|
|
echo "Please ensure the server is started using one of the following methods:"
|
|
echo " • Docker Compose: docker compose up"
|
|
echo " • Direct execution: go run ./cmd/registry"
|
|
echo " • Built binary: ./build/registry"
|
|
echo ""
|
|
echo "REQUIRED: Set the BEARER_TOKEN environment variable with a valid GitHub token"
|
|
echo "Example: export BEARER_TOKEN=your_github_token_here"
|
|
echo "=================================================="
|
|
echo ""
|
|
|
|
# Default values
|
|
HOST="http://localhost:8080"
|
|
VERBOSE=false
|
|
|
|
# Display usage information
|
|
function show_usage {
|
|
echo "Usage: $0 [options]"
|
|
echo "Options:"
|
|
echo " -h, --host Base URL of the MCP Registry service (default: http://localhost:8080)"
|
|
echo " -v, --verbose Show verbose output including full request payload"
|
|
echo " --help Show this help message"
|
|
echo ""
|
|
echo "Environment Variables:"
|
|
echo " BEARER_TOKEN Required: GitHub token for authentication"
|
|
exit 1
|
|
}
|
|
|
|
# Check if bearer token is set
|
|
if [[ -z "$BEARER_TOKEN" ]]; then
|
|
echo "Error: BEARER_TOKEN environment variable is not set."
|
|
echo "Please set your GitHub token as an environment variable:"
|
|
echo " export BEARER_TOKEN=your_github_token_here"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if jq is installed
|
|
if ! command -v jq &> /dev/null; then
|
|
echo "Error: jq is required but not installed."
|
|
echo "Please install jq using your package manager, for example:"
|
|
echo " brew install jq (macOS)"
|
|
echo " apt-get install jq (Debian/Ubuntu)"
|
|
echo " yum install jq (CentOS/RHEL)"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if the API is running
|
|
echo "Checking if the MCP Registry API is running at $HOST..."
|
|
health_check=$(curl -s -o /dev/null -w "%{http_code}" "$HOST/v0/health" 2>/dev/null)
|
|
if [[ "$health_check" != "200" ]]; then
|
|
echo "Error: MCP Registry API is not running at $HOST (health check returned $health_check)"
|
|
echo "Please start the server using one of the methods mentioned above and try again."
|
|
exit 1
|
|
else
|
|
echo "✓ MCP Registry API is running at $HOST"
|
|
fi
|
|
|
|
# Parse command line arguments
|
|
while [[ "$#" -gt 0 ]]; do
|
|
case $1 in
|
|
-h|--host) HOST="$2"; shift ;;
|
|
-v|--verbose) VERBOSE=true ;;
|
|
--help) show_usage ;;
|
|
*) echo "Unknown parameter: $1"; show_usage ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
# Create a temporary file for our JSON payload
|
|
PAYLOAD_FILE=$(mktemp)
|
|
|
|
# Create sample server detail payload based on current model structure
|
|
cat > "$PAYLOAD_FILE" << EOF
|
|
{
|
|
"name": "io.github.example/test-mcp-server",
|
|
"description": "A test server for MCP Registry validation - published at $(date)",
|
|
"repository": {
|
|
"url": "https://github.com/example/test-mcp-server",
|
|
"source": "github",
|
|
"id": "example/test-mcp-server"
|
|
},
|
|
"version": "1.0.$(date +%s)",
|
|
"packages": [
|
|
{
|
|
"registryType": "npm",
|
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
"identifier": "test-mcp-server",
|
|
"version": "1.0.$(date +%s)",
|
|
"runtimeHint": "node",
|
|
"transport": {
|
|
"type": "stdio"
|
|
},
|
|
"runtimeArguments": [
|
|
{
|
|
"type": "positional",
|
|
"name": "config",
|
|
"description": "Configuration file path",
|
|
"format": "file_path",
|
|
"isRequired": false,
|
|
"default": "./config.json"
|
|
}
|
|
],
|
|
"environmentVariables": [
|
|
{
|
|
"name": "PORT",
|
|
"description": "Port to run the server on",
|
|
"format": "number",
|
|
"isRequired": false,
|
|
"default": "3000"
|
|
},
|
|
{
|
|
"name": "API_KEY",
|
|
"description": "API key for external service",
|
|
"format": "string",
|
|
"isRequired": true,
|
|
"isSecret": true
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
# Show the payload if verbose mode is enabled
|
|
if $VERBOSE; then
|
|
echo "Request Payload:"
|
|
cat "$PAYLOAD_FILE" | jq '.'
|
|
echo "-------------------------------------"
|
|
fi
|
|
|
|
# Test publish endpoint
|
|
echo "Testing publish endpoint: $HOST/v0/publish"
|
|
echo "Using Bearer Token: ${BEARER_TOKEN:0:10}..." # Show only first 10 chars for security
|
|
|
|
# Get response and status code in a single request
|
|
response_file=$(mktemp)
|
|
headers_file=$(mktemp)
|
|
|
|
# Execute curl with response body to file and headers+status to another file
|
|
curl -s -X POST \
|
|
-H "Content-Type: application/json" \
|
|
-H "Authorization: Bearer ${BEARER_TOKEN}" \
|
|
-d "@$PAYLOAD_FILE" \
|
|
-D "$headers_file" \
|
|
-o "$response_file" \
|
|
"$HOST/v0/publish"
|
|
|
|
# Read the response body
|
|
http_response=$(<"$response_file")
|
|
|
|
# Extract the status code from the headers file
|
|
status_code=$(head -n1 "$headers_file" | awk '{print $2}')
|
|
|
|
# Clean up temp files
|
|
rm "$response_file" "$headers_file"
|
|
|
|
echo "Status Code: $status_code"
|
|
|
|
# Check for status code in 2xx range (200, 201, 202, etc)
|
|
if [[ "${status_code:0:1}" == "2" ]]; then
|
|
# Parse JSON response with jq
|
|
echo "Response:"
|
|
echo "$http_response" | jq '.' 2>/dev/null || echo "$http_response"
|
|
|
|
# Check for server added message and extract UUID
|
|
message=$(echo "$http_response" | jq -r '.message // empty' 2>/dev/null)
|
|
server_id=$(echo "$http_response" | jq -r '.id // .server_id // empty' 2>/dev/null)
|
|
|
|
# Validate the response contains success indicators
|
|
success_indicators=0
|
|
|
|
if [[ ! -z "$message" && "$message" != "null" ]]; then
|
|
echo "✓ Success message received: $message"
|
|
if [[ "$message" == *"server"* && ("$message" == *"added"* || "$message" == *"published"* || "$message" == *"created"*) ]]; then
|
|
((success_indicators++))
|
|
echo "✓ Message indicates server was successfully added"
|
|
fi
|
|
fi
|
|
|
|
if [[ ! -z "$server_id" && "$server_id" != "null" && "$server_id" != "empty" ]]; then
|
|
echo "✓ Server UUID received: $server_id"
|
|
# Validate UUID format (basic check for UUID pattern)
|
|
if [[ "$server_id" =~ ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$ ]]; then
|
|
((success_indicators++))
|
|
echo "✓ Server ID appears to be a valid UUID format"
|
|
else
|
|
echo "⚠ Server ID format may not be a standard UUID: $server_id"
|
|
((success_indicators++)) # Still count as success if we got an ID
|
|
fi
|
|
fi
|
|
|
|
if [[ $success_indicators -ge 2 ]]; then
|
|
echo ""
|
|
echo "🎉 PUBLISH TEST PASSED!"
|
|
echo " ✓ Server successfully published with ID: $server_id"
|
|
echo " ✓ Success message: $message"
|
|
else
|
|
echo ""
|
|
echo "❌ PUBLISH TEST FAILED!"
|
|
echo " Expected: Success message about server being added AND a server UUID"
|
|
echo " Received: message='$message', id='$server_id'"
|
|
exit 1
|
|
fi
|
|
|
|
else
|
|
echo ""
|
|
echo "❌ PUBLISH TEST FAILED!"
|
|
echo " Expected: 2xx status code"
|
|
echo " Received: $status_code"
|
|
echo " Response:"
|
|
echo "$http_response" | jq '.' 2>/dev/null || echo "$http_response"
|
|
exit 1
|
|
fi
|
|
|
|
echo "-------------------------------------"
|
|
|
|
# Clean up temp file
|
|
rm "$PAYLOAD_FILE"
|