registry/cmd/publisher
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Radoslav Dimitrov 2a2bbfed84
Use constants instead of hardcoded strings (#330)
<!-- Provide a brief summary of your changes -->

## Motivation and Context
<!-- Why is this change needed? What problem does it solve? -->
The following PR updates some of the hardcoded references to public
constants.


## How Has This Been Tested?
<!-- Have you tested this in a real application? Which scenarios were
tested? -->
Locally
## Breaking Changes
<!-- Will users need to update their code or configurations? -->
No

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [ ] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [ ] My code follows the repository's style guidelines
- [ ] New and existing tests pass locally
- [ ] I have added appropriate error handling
- [ ] I have added or updated documentation as needed

## Additional context
<!-- Add any other context, implementation notes, or design decisions
-->

Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
2025-09-01 16:51:14 +01:00
..
auth Move publisher CLI from tools/ to cmd/ (#326) 2025-08-29 14:45:36 +01:00
commands Use constants instead of hardcoded strings (#330) 2025-09-01 16:51:14 +01:00
build.sh Move publisher CLI from tools/ to cmd/ (#326) 2025-08-29 14:45:36 +01:00
main.go Move publisher CLI from tools/ to cmd/ (#326) 2025-08-29 14:45:36 +01:00
README.md Move publisher CLI from tools/ to cmd/ (#326) 2025-08-29 14:45:36 +01:00

MCP Registry Publisher Tool

The MCP Registry Publisher Tool helps you publish Model Context Protocol (MCP) servers to the official registry. It follows a simple, npm-like workflow that's familiar to most developers.

Installation

# Build for current platform
./build.sh

# Build for all supported platforms (optional)
./build.sh --all

The compiled binary will be placed in the bin directory.

Quick Start

# 1. Create a template server.json file
mcp-publisher init

# 2. Edit server.json with your server details

# 3. Authenticate with the registry (one-time setup)
mcp-publisher login <method>

# 4. Publish your server
mcp-publisher publish

Commands

mcp-publisher init

Creates a template server.json file with smart defaults. This command automatically detects values from your environment when possible.

mcp-publisher init

Auto-detection sources:

  • Git remote origin for repository URL and server name
  • package.json for npm packages (name, description)
  • pyproject.toml for Python packages
  • Current directory for fallback naming

The generated file includes placeholder values that you should update before publishing.

mcp-publisher login <method>

Authenticates with the MCP registry. You'll only need to do this once - the tool saves your credentials locally.

# GitHub interactive authentication
mcp-publisher login github

# GitHub Actions OIDC (for CI/CD)
mcp-publisher login github-oidc

# DNS-based authentication
mcp-publisher login dns --domain example.com --private-key abc123...

# HTTP-based authentication  
mcp-publisher login http --domain example.com --private-key abc123...

Authentication Methods:

  • github: Interactive GitHub OAuth flow. Opens browser for authentication.
  • github-oidc: For GitHub Actions. Uses OIDC tokens automatically.
  • dns: Domain-based auth using DNS TXT records. Requires --domain and --private-key.
  • http: Domain-based auth using HTTPS endpoint. Requires --domain and --private-key.

mcp-publisher publish

Publishes your server.json file to the registry. You must be logged in first.

mcp-publisher publish

This command:

  • Validates your server.json file
  • Checks your authentication
  • Uploads the server configuration to the registry

mcp-publisher logout

Clears your saved authentication credentials.

mcp-publisher logout

GitHub Actions

For automated publishing from GitHub Actions:

name: Publish to MCP Registry
on:
  push:
    tags: ['v*']

jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      id-token: write  # Required for OIDC
      contents: read
    steps:
      - uses: actions/checkout@v4
      
      - name: Setup MCP Publisher
        run: |
          curl -LO https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher-linux-amd64
          chmod +x mcp-publisher-linux-amd64
          
      - name: Login to Registry
        run: ./mcp-publisher-linux-amd64 login github-oidc
        
      - name: Publish to Registry
        run: ./mcp-publisher-linux-amd64 publish

The login github-oidc command uses GitHub's OIDC tokens for authentication in CI environments.

Examples

Publishing an NPM-based server

# Create template server.json (auto-detects from package.json)
# Then edit server.json to add your specific details
mcp-publisher init

# Login (first time only)
mcp-publisher login github

# Publish
mcp-publisher publish

Publishing a Python server

# Create template server.json (auto-detects from pyproject.toml)
# Then edit server.json to add your specific details
mcp-publisher init

# Publish (assuming already logged in)
mcp-publisher publish

Publishing with DNS authentication

# Setup DNS TXT record first (see DNS Authentication section below)

# Login with DNS
mcp-publisher login dns --domain example.com --private-key YOUR_PRIVATE_KEY

# Publish
mcp-publisher publish

Authentication Details

DNS Authentication

For domain-based authentication using DNS:

  1. Generate an Ed25519 keypair:

    openssl genpkey -algorithm Ed25519 -out /tmp/key.pem && \
    echo "DNS TXT Record:" && \
    echo "  v=MCPv1; k=ed25519; p=$(openssl pkey -in /tmp/key.pem -pubout -outform DER | tail -c 32 | base64)" && \
    echo "" && \
    echo "Private key for login:" && \
    echo "  $(openssl pkey -in /tmp/key.pem -noout -text | grep -A3 "priv:" | tail -n +2 | tr -d ' :\n')" && \
    rm /tmp/key.pem
    
  2. Add the TXT record to your domain's DNS

  3. Login with:

    mcp-publisher login dns --domain example.com --private-key YOUR_PRIVATE_KEY
    

This grants publishing rights for example.com/* and *.example.com/* namespaces.

HTTP Authentication

For HTTP-based authentication:

  1. Generate an Ed25519 keypair (same as DNS)

  2. Host the public key at https://yoursite.com/.well-known/mcp-registry-auth:

    v=MCPv1; k=ed25519; p=YOUR_PUBLIC_KEY_BASE64
    
  3. Login with:

    mcp-publisher login http --domain example.com --private-key YOUR_PRIVATE_KEY
    

This grants publishing rights for the example.com/* namespace.

Troubleshooting

"Not authenticated" error: Run mcp-publisher login <method> to authenticate (e.g., mcp-publisher login github).

"Invalid server.json" error: Ensure your server.json file is valid. You can recreate it with mcp-publisher init.

GitHub Actions failing: Ensure your workflow has id-token: write permission and you're using mcp-publisher login github-oidc.