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>
474 lines
14 KiB
Markdown
474 lines
14 KiB
Markdown
# Publish Your MCP Server
|
|
|
|
Complete guide to publishing an MCP server to the registry.
|
|
|
|
> [!TIP]
|
|
> Using an agentic AI coding assistant? Just use this prompt:
|
|
> ```
|
|
> Read https://raw.githubusercontent.com/modelcontextprotocol/registry/refs/heads/main/docs/guides/publishing/publish-server.md and https://raw.githubusercontent.com/modelcontextprotocol/registry/refs/heads/main/docs/guides/publishing/github-actions.md. Evaluate the best way to publish this server to the registry (prefer automated CI flows over manual flows where possible), and implement that. If possible, validate the server.json against the $schema before telling the user you are done, using a proper json schema library or tool available on the user's machine. If you get stuck, guide the user through the parts of the publishing process they need to do (e.g. logging into the publisher CLI if doing manual pubishing).
|
|
> ```
|
|
|
|
## What You'll Learn
|
|
|
|
By the end of this tutorial, you'll have:
|
|
- Created a server.json file for your MCP server
|
|
- Authenticated with the registry
|
|
- Successfully published your server
|
|
- Verified your server appears in the registry
|
|
|
|
## Prerequisites
|
|
|
|
- An MCP server you've already built ([follow this guide if you don't have one already](https://modelcontextprotocol.io/quickstart/server))
|
|
|
|
## Deployment Options
|
|
|
|
You can make your MCP server available in multiple ways:
|
|
|
|
- **📦 Package deployment**: Published to registries (npm, PyPI, NuGet, Docker Hub, etc.) and run locally by clients
|
|
- **🌐 Remote deployment**: Hosted as a web service that clients connect to directly
|
|
- **🔄 Hybrid deployment**: Offer both package and remote options for maximum flexibility
|
|
|
|
Learn more about [MCP server architecture](https://modelcontextprotocol.io/docs/concepts/servers) in the official docs.
|
|
|
|
## Step 1: Install the Publisher CLI
|
|
|
|
<details>
|
|
<summary><strong>🍺 macOS/Linux/WSL: With Homebrew (recommended)</strong></summary>
|
|
|
|
Requires [Homebrew](https://brew.sh):
|
|
|
|
```bash
|
|
brew install mcp-publisher
|
|
```
|
|
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>⬇️ macOS/Linux/WSL: Pre-built binaries</strong></summary>
|
|
|
|
```bash
|
|
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/
|
|
```
|
|
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>🏗️ macOS/Linux/WSL: From source</strong></summary>
|
|
|
|
Requires Git, Make and Go 1.24+:
|
|
|
|
```bash
|
|
# Clone the registry repository
|
|
git clone https://github.com/modelcontextprotocol/registry
|
|
cd registry
|
|
make publisher
|
|
|
|
# The binary will be at bin/mcp-publisher
|
|
export PATH=$PATH:$(pwd)/bin
|
|
```
|
|
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>🪟 Windows PowerShell: Pre-built binaries</strong></summary>
|
|
|
|
```powershell
|
|
$arch = if ([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture -eq "Arm64") { "arm64" } else { "amd64" }; Invoke-WebRequest -Uri "https://github.com/modelcontextprotocol/registry/releases/download/v1.0.0/mcp-publisher_1.0.0_windows_$arch.tar.gz" -OutFile "mcp-publisher.tar.gz"; tar xf mcp-publisher.tar.gz mcp-publisher.exe; rm mcp-publisher.tar.gz
|
|
# Move mcp-publisher.exe to a directory in your PATH
|
|
```
|
|
|
|
</details>
|
|
|
|
## Step 2: Initialize Your server.json
|
|
|
|
Navigate to your server's directory and create a template:
|
|
|
|
```bash
|
|
cd /path/to/your/mcp-server
|
|
mcp-publisher init
|
|
```
|
|
|
|
This creates a `server.json` with auto-detected values. You'll see something like:
|
|
|
|
```json
|
|
{
|
|
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-09-16/server.schema.json",
|
|
"name": "io.github.yourname/your-server",
|
|
"description": "A description of your MCP server",
|
|
"version": "1.0.0",
|
|
"packages": [
|
|
{
|
|
"registryType": "npm",
|
|
"identifier": "your-package-name",
|
|
"version": "1.0.0"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
## Step 3: Configure Your Server Details
|
|
|
|
Edit the generated `server.json`:
|
|
|
|
### Choose Your Namespace
|
|
|
|
The `name` field determines authentication requirements:
|
|
|
|
- **`io.github.yourname/*`** - Requires GitHub authentication
|
|
- **`com.yourcompany/*`** - Requires DNS or HTTP domain verification
|
|
|
|
### Configure Deployment Methods
|
|
|
|
Configure your server to support packages, remotes, or both:
|
|
|
|
#### Package Deployment
|
|
|
|
Add package validation metadata to prove ownership of your packages.
|
|
|
|
|
|
<details>
|
|
<summary><strong>📦 NPM Packages</strong></summary>
|
|
|
|
### Requirements
|
|
Add an `mcpName` field to your `package.json`:
|
|
|
|
```json
|
|
{
|
|
"name": "your-npm-package",
|
|
"version": "1.0.0",
|
|
"mcpName": "io.github.username/server-name"
|
|
}
|
|
```
|
|
|
|
### How It Works
|
|
- Registry fetches `https://registry.npmjs.org/your-npm-package`
|
|
- Checks that `mcpName` field matches your server name
|
|
- Fails if field is missing or doesn't match
|
|
|
|
### Example server.json
|
|
```json
|
|
{
|
|
"name": "io.github.username/server-name",
|
|
"packages": [
|
|
{
|
|
"registryType": "npm",
|
|
"identifier": "your-npm-package",
|
|
"version": "1.0.0"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
The official MCP registry currently only supports the NPM public registry (`https://registry.npmjs.org`).
|
|
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>🐍 PyPI Packages</strong></summary>
|
|
|
|
### Requirements
|
|
Include your server name in your package README file using this format:
|
|
|
|
**MCP name format**: `mcp-name: io.github.username/server-name`
|
|
|
|
Add it to your README.md file (which becomes the package description on PyPI). This can be in a comment if you want to hide it from display elsewhere.
|
|
|
|
### How It Works
|
|
- Registry fetches `https://pypi.org/pypi/your-package/json`
|
|
- Passes if `mcp-name: server-name` is in the README content
|
|
|
|
### Example server.json
|
|
```json
|
|
{
|
|
"name": "io.github.username/server-name",
|
|
"packages": [
|
|
{
|
|
"registryType": "pypi",
|
|
"identifier": "your-pypi-package",
|
|
"version": "1.0.0"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
The official MCP registry currently only supports the official PyPI registry (`https://pypi.org`).
|
|
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>📋 NuGet Packages</strong></summary>
|
|
|
|
### Requirements
|
|
Include your server name in your package's README using this format:
|
|
|
|
**MCP name format**: `mcp-name: io.github.username/server-name`
|
|
|
|
Add a README file to your NuGet package that includes the server name. This can be in a comment if you want to hide it from display elsewhere.
|
|
|
|
### How It Works
|
|
- Registry fetches README from `https://api.nuget.org/v3-flatcontainer/{id}/{version}/readme`
|
|
- Passes if `mcp-name: server-name` is found in the README content
|
|
|
|
### Example server.json
|
|
```json
|
|
{
|
|
"name": "io.github.username/server-name",
|
|
"packages": [
|
|
{
|
|
"registryType": "nuget",
|
|
"identifier": "Your.NuGet.Package",
|
|
"version": "1.0.0"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
The official MCP registry currently only supports the official NuGet registry (`https://api.nuget.org`).
|
|
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>🐳 Docker/OCI Images</strong></summary>
|
|
|
|
### Requirements
|
|
Add an annotation to your Docker image:
|
|
|
|
```dockerfile
|
|
LABEL io.modelcontextprotocol.server.name="io.github.username/server-name"
|
|
```
|
|
|
|
### How It Works
|
|
- Registry authenticates with container registries using token-based authentication:
|
|
- **Docker Hub**: Uses `auth.docker.io` token service
|
|
- **GitHub Container Registry**: Uses `ghcr.io` token service
|
|
- Fetches image manifest using Docker Registry v2 API
|
|
- Checks that `io.modelcontextprotocol.server.name` annotation matches your server name
|
|
- Fails if annotation is missing or doesn't match
|
|
|
|
### Example server.json (Docker Hub)
|
|
```json
|
|
{
|
|
"name": "io.github.username/server-name",
|
|
"packages": [
|
|
{
|
|
"registryType": "oci",
|
|
"registryBaseUrl": "https://docker.io",
|
|
"identifier": "yourusername/your-mcp-server",
|
|
"version": "1.0.0"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
### Example server.json (GitHub Container Registry)
|
|
```json
|
|
{
|
|
"name": "io.github.username/server-name",
|
|
"packages": [
|
|
{
|
|
"registryType": "oci",
|
|
"registryBaseUrl": "https://ghcr.io",
|
|
"identifier": "yourusername/your-mcp-server",
|
|
"version": "1.0.0"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
The identifier is `namespace/repository`, and version is the tag and optionally digest.
|
|
|
|
The official MCP registry currently supports Docker Hub (`https://docker.io`) and GitHub Container Registry (`https://ghcr.io`).
|
|
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>📁 MCPB Packages</strong></summary>
|
|
|
|
### Requirements
|
|
**MCP reference** - MCPB package URLs must contain "mcp" somewhere within them, to ensure the correct artifact has been uploaded. This may be with the `.mcpb` extension or in the name of your repository.
|
|
|
|
**File integrity** - MCPB packages must include a SHA-256 hash for file integrity verification. This is required at publish time and MCP clients will validate this hash before installation.
|
|
|
|
### How to Generate File Hashes
|
|
Calculate the SHA-256 hash of your MCPB file:
|
|
|
|
```bash
|
|
openssl dgst -sha256 server.mcpb
|
|
```
|
|
|
|
### Example server.json
|
|
```json
|
|
{
|
|
"name": "io.github.username/server-name",
|
|
"packages": [
|
|
{
|
|
"registryType": "mcpb",
|
|
"identifier": "https://github.com/you/your-repo/releases/download/v1.0.0/server.mcpb",
|
|
"fileSha256": "fe333e598595000ae021bd27117db32ec69af6987f507ba7a63c90638ff633ce"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
### File Hash Validation
|
|
- **Authors** are responsible for generating correct SHA-256 hashes when creating server.json
|
|
- **MCP clients** validate the hash before installing packages to ensure file integrity
|
|
- **The official registry** stores hashes but does not validate them
|
|
- **Subregistries** may choose to implement their own validation. This enables them to perform security scanning on MCPB files, and ensure clients get the same security scanned content.
|
|
|
|
The official MCP registry currently only supports artifacts hosted on GitHub or GitLab releases.
|
|
|
|
</details>
|
|
|
|
#### Remote Deployment
|
|
|
|
Add the `remotes` field to your `server.json` (can coexist with `packages`):
|
|
|
|
<details>
|
|
<summary><strong>🌐 Remote Server Configuration</strong></summary>
|
|
|
|
### Requirements
|
|
|
|
- **Service endpoint**: Your MCP server must be accessible at the specified URL
|
|
- **Transport protocol**: Choose from `sse` (Server-Sent Events) or `streamable-http`
|
|
- **URL validation**: For domain namespaces only (see URL requirements below)
|
|
|
|
### Example server.json
|
|
|
|
```json
|
|
{
|
|
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-09-16/server.schema.json",
|
|
"name": "com.yourcompany/api-server",
|
|
"description": "Cloud-hosted MCP server for API operations",
|
|
"version": "2.0.0",
|
|
"remotes": [
|
|
{
|
|
"type": "sse",
|
|
"url": "https://mcp.yourcompany.com/sse"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
### Multiple Transport Options
|
|
|
|
You can offer multiple connection methods:
|
|
|
|
```json
|
|
{
|
|
"remotes": [
|
|
{
|
|
"type": "sse",
|
|
"url": "https://mcp.yourcompany.com/sse"
|
|
},
|
|
{
|
|
"type": "streamable-http",
|
|
"url": "https://mcp.yourcompany.com/http"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
### URL Validation Requirements
|
|
|
|
- For `com.yourcompany/*` namespaces: URLs must be on `yourcompany.com` or its subdomains
|
|
- For `io.github.username/*` namespaces: No URL restrictions (but you must authenticate via GitHub)
|
|
|
|
### Authentication Headers (Optional)
|
|
|
|
Configure headers that clients should send when connecting:
|
|
|
|
```json
|
|
{
|
|
"remotes": [
|
|
{
|
|
"type": "sse",
|
|
"url": "https://mcp.yourcompany.com/sse",
|
|
"headers": [
|
|
{
|
|
"name": "X-API-Key",
|
|
"description": "API key for authentication",
|
|
"isRequired": true,
|
|
"isSecret": true
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
</details>
|
|
|
|
## Step 4: Authenticate
|
|
|
|
Choose your authentication method based on your namespace:
|
|
|
|
### GitHub Authentication (for io.github.* namespaces)
|
|
|
|
```bash
|
|
mcp-publisher login github
|
|
```
|
|
|
|
This opens your browser for OAuth authentication.
|
|
|
|
### DNS Authentication (for custom domains)
|
|
|
|
```bash
|
|
# Generate keypair
|
|
openssl genpkey -algorithm Ed25519 -out key.pem
|
|
|
|
# Get public key for DNS record
|
|
echo "yourcompany.com. IN TXT \"v=MCPv1; k=ed25519; p=$(openssl pkey -in key.pem -pubout -outform DER | tail -c 32 | base64)\""
|
|
|
|
# Add the TXT record to your DNS, then login
|
|
mcp-publisher login dns --domain yourcompany.com --private-key $(openssl pkey -in key.pem -noout -text | grep -A3 "priv:" | tail -n +2 | tr -d ' :\n')
|
|
```
|
|
|
|
## Step 5: Publish Your Server
|
|
|
|
With authentication complete, publish your server:
|
|
|
|
```bash
|
|
mcp-publisher publish
|
|
```
|
|
|
|
You'll see output like:
|
|
```
|
|
✓ Successfully published
|
|
```
|
|
|
|
## Step 6: Verify Publication
|
|
|
|
Check that your server appears in the registry by searching for it:
|
|
|
|
```bash
|
|
curl "https://registry.modelcontextprotocol.io/v0/servers?search=io.github.yourname/weather-server"
|
|
```
|
|
|
|
You should see your server metadata returned in the JSON response.
|
|
|
|
## Troubleshooting
|
|
|
|
**"Package validation failed"** - Ensure your package includes the required validation metadata (mcpName field, README mention, or Docker label).
|
|
|
|
**"Authentication failed"** - Verify you've correctly set up DNS records or are logged into the right GitHub account.
|
|
|
|
**"Namespace not authorized"** - Your authentication method doesn't match your chosen namespace format.
|
|
|
|
## Examples
|
|
|
|
See these real-world examples of published servers:
|
|
- [NPM, Docker and MCPB example](https://github.com/domdomegg/airtable-mcp-server)
|
|
- [NuGet example](https://github.com/domdomegg/time-mcp-nuget)
|
|
- [PyPI example](https://github.com/domdomegg/time-mcp-pypi)
|
|
|
|
## Next Steps
|
|
|
|
- **Update your server**: Publish new versions with updated server.json files
|
|
- **Set up CI/CD**: Automate publishing with [GitHub Actions](github-actions.md)
|
|
- **Learn more**: Understand [server.json format](../../reference/server-json/generic-server-json.md) in depth
|
|
- **More examples**: See [remote server configurations](../../reference/server-json/generic-server-json.md#remote-server-example) and [hybrid deployments](../../reference/server-json/generic-server-json.md#server-with-remote-and-package-options) in the schema documentation
|
|
|
|
## What You've Accomplished
|
|
|
|
You've successfully published your first MCP server to the registry! Your server is now discoverable by MCP clients and can be installed by users worldwide.
|