Skip to content

Add create command to publisher CLI for generating server.json files #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ build/*
.mcpregistry*
**/bin
cmd/registry/registry
publisher
102 changes: 98 additions & 4 deletions tools/publisher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,23 @@ The compiled binary will be placed in the `bin` directory.

## Usage

The tool supports two main commands:

### Publishing a server

```bash
# Basic usage
./bin/mcp-publisher -registry-url <REGISTRY_URL> -mcp-file <PATH_TO_MCP_FILE>
./bin/mcp-publisher publish -registry-url <REGISTRY_URL> -mcp-file <PATH_TO_MCP_FILE>

# Force a new login even if a token exists
./bin/mcp-publisher -registry-url <REGISTRY_URL> -mcp-file <PATH_TO_MCP_FILE> -login
./bin/mcp-publisher publish -registry-url <REGISTRY_URL> -mcp-file <PATH_TO_MCP_FILE> -login
```

### Creating a server.json file

```bash
# Create a new server.json file
./bin/mcp-publisher create --name "io.github.owner/repo" --description "My server" --repo-url "https://github.com/owner/repo"
```

### Command-line Arguments
Expand All @@ -33,6 +44,87 @@ The compiled binary will be placed in the `bin` directory.
- `-login`: Force a new GitHub authentication even if a token already exists (overwrites existing token file)
- `-auth-method`: Authentication method to use (default: github-oauth)

## Creating a server.json file

The tool provides a `create` command to help generate a properly formatted `server.json` file. This command takes various flags to specify the server details and generates a complete server.json file that you can then modify as needed.

### Usage

```bash
./bin/mcp-publisher create [flags]
```

### Create Command Flags

#### Required Flags
- `--name`, `-n`: Server name (e.g., io.github.owner/repo-name)
- `--description`, `-d`: Server description
- `--repo-url`: Repository URL

#### Optional Flags
- `--version`, `-v`: Server version (default: "1.0.0")
- `--repo-source`: Repository source (default: "github")
- `--output`, `-o`: Output file path (default: "server.json")
- `--execute`, `-e`: Command to execute the server (generates runtime arguments)
- `--registry`: Package registry name (default: "npm")
- `--package-name`: Package name (defaults to server name)
- `--package-version`: Package version (defaults to server version)
- `--runtime-hint`: Runtime hint (e.g., "docker")
- `--env-var`: Environment variable in format NAME:DESCRIPTION (can be repeated)
- `--package-arg`: Package argument in format VALUE:DESCRIPTION (can be repeated)

### Create Examples

#### Basic NPX Server

```bash
./bin/mcp-publisher create \
--name "io.github.example/my-server" \
--description "My MCP server" \
--repo-url "https://github.com/example/my-server" \
--execute "npx @example/my-server --verbose" \
--env-var "API_KEY:Your API key for the service"
```

#### Docker Server

```bash
./bin/mcp-publisher create \
--name "io.github.example/docker-server" \
--description "Docker-based MCP server" \
--repo-url "https://github.com/example/docker-server" \
--runtime-hint "docker" \
--execute "docker run --mount type=bind,src=/data,dst=/app/data example/server" \
--env-var "CONFIG_PATH:Path to configuration file"
```

#### Server with Package Arguments

```bash
./bin/mcp-publisher create \
--name "io.github.example/full-server" \
--description "Complete server example" \
--repo-url "https://github.com/example/full-server" \
--execute "npx @example/server" \
--package-arg "-s:Specify services and permissions" \
--package-arg "--config:Configuration file path" \
--env-var "API_KEY:Service API key" \
--env-var "DEBUG:Enable debug mode"
```

The `create` command will generate a `server.json` file with:
- Proper structure and formatting
- Runtime arguments parsed from the `--execute` command
- Environment variables with descriptions
- Package arguments for user configuration
- All necessary metadata

After creation, you may need to manually edit the file to:
- Adjust argument descriptions and requirements
- Set environment variable optionality (`is_required`, `is_secret`)
- Add remote server configurations
- Fine-tune runtime and package arguments

## Authentication

The tool has been simplified to use **GitHub OAuth device flow authentication exclusively**. Previous versions supported multiple authentication methods, but this version focuses solely on GitHub OAuth for better security and user experience.
Expand All @@ -45,7 +137,9 @@ The tool has been simplified to use **GitHub OAuth device flow authentication ex

**Note**: Authentication is performed via GitHub OAuth App, which you must authorize for the respective resources (e.g., organization access if publishing organization repositories).

## Example
## Publishing Example

To publish an existing server.json file to the registry:

1. Prepare your `server.json` file with your server details:

Expand Down Expand Up @@ -90,7 +184,7 @@ The tool has been simplified to use **GitHub OAuth device flow authentication ex
2. Run the publisher tool:

```bash
./bin/mcp-publisher --registry-url "https://mcp-registry.example.com" --mcp-file "./server.json"
./bin/mcp-publisher publish --registry-url "https://mcp-registry.example.com" --mcp-file "./server.json"
```

3. Follow the authentication instructions in the terminal if prompted.
Expand Down
Loading
Loading