From 59adaa9aa5aa74cfab126611b1f01b0af93373b7 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Mon, 28 Apr 2025 12:08:50 -0400 Subject: [PATCH] feat: add build script and update README for MCP Registry Publisher Tool --- .gitignore | 3 +- tools/publisher/README.md | 106 ++++++++++++++++++++++++++++++++++++++ tools/publisher/build.sh | 41 +++++++++++++++ 3 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 tools/publisher/README.md create mode 100755 tools/publisher/build.sh diff --git a/.gitignore b/.gitignore index f4b49c8..50e4641 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build/* data .env -.mcpregistry* \ No newline at end of file +.mcpregistry* +**/bin \ No newline at end of file diff --git a/tools/publisher/README.md b/tools/publisher/README.md new file mode 100644 index 0000000..23645d8 --- /dev/null +++ b/tools/publisher/README.md @@ -0,0 +1,106 @@ +# MCP Registry Publisher Tool + +The MCP Registry Publisher Tool is designed to publish Model Context Protocol (MCP) server details to an MCP registry. This tool currently only handles GitHub authentication via device flow and manages the publishing process. + +## Building the Tool + +You can build the publisher tool using the provided build script: + +```bash +# Make the build script executable +chmod +x build.sh + +# 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. + +## Usage + +```bash +# Basic usage +./bin/mcp-publisher --registry-url --mcp-file + +# Force a new login even if a token exists +./bin/mcp-publisher --registry-url --mcp-file --login +``` + +### Command-line Arguments + +- `--registry-url`: URL of the MCP registry (required) +- `--mcp-file`: Path to the MCP configuration file (required) +- `--login`: Force a new GitHub authentication even if a token already exists + +## Authentication + +The tool uses GitHub device flow authentication: +1. When first run (or with `--login` flag), the tool will initiate the GitHub device flow +2. You'll be provided with a URL and a code to enter +3. After successful authentication, the tool saves the token locally for future use + +_NOTE_ : Authentication is made on behalf of a GitHubApp which you must install on the repository you're publishing. + +## Example + +1. Prepare your `mcp.json` file with your server details: + +```json +{ + "name": "io.github.yourusername/your-repository", + "description": "Your MCP server description", + "version_detail": { + "version": "1.0.0" + }, + "registries": [ + { + "name": "npm", + "package_name": "your-npm-package", + "license": "MIT", + "command_arguments": { + "sub_commands": [ + { + "name": "start", + "description": "Start the server", + "named_arguments": null + } + ], + "positional_arguments": null, + "environment_variables": [ + { + "name": "PORT", + "description": "Port to run the server on", + "required": false + } + ], + "named_arguments": null + } + } + ], + "remotes": [ + { + "transporttype": "http", + "url": "http://yourdomain.com/api" + } + ] +} +``` + +2. Run the publisher tool: + +```bash +./bin/mcp-publisher --registry-url "https://mcp-registry.example.com" --mcp-file "./mcp.json" +``` + +3. Follow the authentication instructions in the terminal if prompted. + +4. Upon successful publication, you'll see a confirmation message. + +## Important Notes + +- The authentication token is saved in a file named `.mcpregistry_token` in the current directory +- The tool requires an active internet connection to authenticate with GitHub and communicate with the registry +- Make sure the repository and package mentioned in your `mcp.json` file exist and are accessible diff --git a/tools/publisher/build.sh b/tools/publisher/build.sh new file mode 100755 index 0000000..31eaaa1 --- /dev/null +++ b/tools/publisher/build.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Build script for MCP Registry Publisher Tool + +# Set variables +OUTPUT_DIR="./bin" +BINARY_NAME="mcp-publisher" + +# Create output directory if it doesn't exist +mkdir -p $OUTPUT_DIR + +# Print build information +echo "Building MCP Registry Publisher Tool..." + +# Build for current platform +echo "Building for $(go env GOOS)/$(go env GOARCH)..." +go build -o "$OUTPUT_DIR/$BINARY_NAME" . + +# Make the binary executable +chmod +x "$OUTPUT_DIR/$BINARY_NAME" + +echo "Build complete: $OUTPUT_DIR/$BINARY_NAME" + +# Optional: Build for multiple platforms +if [ "$1" == "--all" ]; then + echo "Building for all supported platforms..." + + # Linux AMD64 + GOOS=linux GOARCH=amd64 go build -o "$OUTPUT_DIR/${BINARY_NAME}-linux-amd64" . + + # MacOS AMD64 + GOOS=darwin GOARCH=amd64 go build -o "$OUTPUT_DIR/${BINARY_NAME}-darwin-amd64" . + + # MacOS ARM64 (Apple Silicon) + GOOS=darwin GOARCH=arm64 go build -o "$OUTPUT_DIR/${BINARY_NAME}-darwin-arm64" . + + # Windows AMD64 + GOOS=windows GOARCH=amd64 go build -o "$OUTPUT_DIR/${BINARY_NAME}-windows-amd64.exe" . + + echo "Multi-platform build complete in $OUTPUT_DIR/" +fi