### Set Up Development Environment Source: https://github.com/samanhappy/mcphub/blob/main/docs/development/contributing.mdx Follow these bash commands to clone the repository, install dependencies, configure environment variables, and start the development server. ```bash # 1. Fork and clone the repository git clone https://github.com/YOUR_USERNAME/mcphub.git cd mcphub # 2. Add upstream remote git remote add upstream https://github.com/samanhappy/mcphub.git # 3. Install dependencies pnpm install # 4. Set up environment cp .env.example .env.development # 5. Start development environment docker-compose -f docker-compose.dev.yml up -d pnpm run migrate pnpm run seed # 6. Start development server pnpm run dev ``` -------------------------------- ### Discovering and installing marketplace servers Source: https://github.com/samanhappy/mcphub/blob/main/docs/features/cli.mdx Illustrates browsing the mcphub marketplace for servers, getting detailed information, and installing them into the active hub or a client configuration file. ```bash # Browse the active profile's hub mcphub discover --search github --limit 10 ``` ```bash mcphub discover info amap-maps ``` ```bash mcphub discover categories ``` ```bash mcphub discover tags ``` ```bash # Install into the active hub (POST /api/servers) mcphub install amap-maps --env AMAP_MAPS_API_KEY=... ``` ```bash # Install from a different hub into the active one mcphub install some-server --remote https://hub.example.com --yes ``` ```bash # Dry-run: just print the mcpServers snippet mcphub install amap-maps --dry-run ``` ```bash # Install into a Claude Desktop / OpenClaw-style config file mcphub install amap-maps --to file --out ~/Library/Application\ Support/Claude/claude_desktop_config.json ``` -------------------------------- ### Manual PostgreSQL Database and User Setup Source: https://github.com/samanhappy/mcphub/blob/main/docs/configuration/database-configuration.mdx Install PostgreSQL and create a new database and user for MCPHub using psql commands. ```bash # Install PostgreSQL (if not already installed) sudo apt-get install postgresql postgresql-contrib # Create database and user sudo -u postgres psql <[optional scope]: # Features git commit -m "feat(auth): add JWT token refresh functionality" git commit -m "feat(ui): implement server status dashboard" # Bug fixes git commit -m "fix(api): resolve memory leak in server manager" git commit -m "fix(db): handle connection timeout gracefully" # Documentation git commit -m "docs(api): add examples for server endpoints" git commit -m "docs(readme): update installation instructions" # Refactoring git commit -m "refactor(services): extract auth logic into separate module" # Tests git commit -m "test(api): add integration tests for server management" # Chores git commit -m "chore(deps): update dependencies to latest versions" ``` -------------------------------- ### Stream Logs Example Event Source: https://github.com/samanhappy/mcphub/blob/main/docs/api-reference/logs.mdx This is an example of a log entry received when streaming logs in real-time via Server-Sent Events (SSE). Each 'log' event contains a single new log entry. ```text data: {"type":"log","log":{"timestamp":"2023-10-27T10:00:05.000Z","level":"debug","message":"Processing request for /api/some-endpoint","service":"mcp-server"}} ``` -------------------------------- ### Run MCPHub with Default Docker Configuration Source: https://github.com/samanhappy/mcphub/blob/main/docs/quickstart.mdx Use this command to quickly start MCPHub with its default settings using Docker. Ensure port 3000 is available on your host machine. ```bash # Run with default configuration docker run -p 3000:3000 samanhappy/mcphub ``` -------------------------------- ### GET /api/logs Source: https://github.com/samanhappy/mcphub/blob/main/docs/api-reference/logs.mdx Retrieves all stored logs. ```APIDOC ## GET /api/logs ### Description Retrieves all stored logs. ### Method GET ### Endpoint /api/logs ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (array) - An array of log objects. - **timestamp** (string) - The time the log was generated. - **level** (string) - The severity level of the log (e.g., info, warn, error). - **message** (string) - The log message. - **service** (string) - The service that generated the log. ### Response Example ```json { "success": true, "data": [ { "timestamp": "2023-10-27T10:00:00.000Z", "level": "info", "message": "Server started successfully.", "service": "system" } ] } ``` ``` -------------------------------- ### Add Slack Integration Server Source: https://github.com/samanhappy/mcphub/blob/main/docs/quickstart.mdx Set up the Slack integration server, including the command, arguments, and required environment variables for authentication. ```json { "name": "slack", "command": "npx", "args": ["-y", "@modelcontextprotocol/server-slack"], "env": { "SLACK_BOT_TOKEN": "your-bot-token", "SLACK_TEAM_ID": "your-team-id" } } ``` -------------------------------- ### GET /api/groups Source: https://github.com/samanhappy/mcphub/blob/main/docs/api-reference/groups.mdx Retrieves a list of all server groups. ```APIDOC ## GET /api/groups ### Description Retrieves a list of all server groups. ### Method GET ### Endpoint /api/groups ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (array) - An array of group objects. - **id** (string) - The unique identifier for the group. - **name** (string) - The name of the group. - **description** (string) - A description of the group. - **servers** (array) - A list of server names in the group. - **owner** (string) - The owner of the group. #### Response Example ```json { "success": true, "data": [ { "id": "group-1", "name": "My Group", "description": "A collection of servers.", "servers": ["server1", "server2"], "owner": "admin" } ] } ``` ``` -------------------------------- ### Get a Server Source: https://github.com/samanhappy/mcphub/blob/main/docs/api-reference/servers.mdx Reads a single server's configuration. ```APIDOC ## GET /api/servers/:name ### Description Returns the configuration of a single server, including upstream tools/prompts/resources when connected. ### Method GET ### Endpoint /api/servers/:name ### Parameters #### Path Parameters - **name** (string) - Required - The name of the server to retrieve. ### Response Returns `404` if the server is not configured. ``` -------------------------------- ### Toggle mcphub server Source: https://github.com/samanhappy/mcphub/blob/main/docs/features/cli.mdx Enable or disable a server. Use `--on` to enable. ```bash mcphub servers toggle fetch --on ``` -------------------------------- ### GET /api/auth/user Source: https://github.com/samanhappy/mcphub/blob/main/docs/api-reference/auth.mdx Retrieves the profile of the currently authenticated user. ```APIDOC ## GET /api/auth/user ### Description Retrieves the profile of the currently authenticated user. ### Method GET ### Endpoint /api/auth/user ### Parameters #### Header Parameters - **Authorization** (string, required): Bearer Token required. ### Response #### Success Response (200) - **success** (boolean) - **user** (object) #### Response Example { "success": true, "user": { "username": "admin", "isAdmin": true, "permissions": { ... } } } ``` -------------------------------- ### Server Configuration with Environment Variables Source: https://github.com/samanhappy/mcphub/blob/main/docs/features/server-management.mdx Define server commands and environment variables for configuration. Supports variable expansion for dynamic values. ```json { "server-name": { "command": "python", "args": ["server.py"], "env": { "API_KEY": "${YOUR_API_KEY}", "DEBUG": "true", "MAX_CONNECTIONS": "10" } } } ``` -------------------------------- ### Run Docker with Custom Configuration File Source: https://github.com/samanhappy/mcphub/blob/main/docs/installation.mdx Deploy MCPHub using a custom JSON configuration file mounted into the container. Create the 'mcp_settings.json' file before running the command. ```bash # Create your configuration file cat > mcp_settings.json << 'EOF' { "mcpServers": { "fetch": { "command": "uvx", "args": ["mcp-server-fetch"] }, "playwright": { "command": "npx", "args": ["@playwright/mcp@latest", "--headless"] } } } EOF # Run with mounted config docker run -d \ --name mcphub \ -p 3000:3000 \ -v $(pwd)/mcp_settings.json:/app/mcp_settings.json \ samanhappy/mcphub:latest ``` -------------------------------- ### Get All Servers Source: https://github.com/samanhappy/mcphub/blob/main/docs/api-reference/servers.mdx Retrieves a list of all configured MCP servers and their status. ```APIDOC ## GET /api/servers ### Description Retrieves a list of all configured MCP servers, including their status and available tools. ### Method GET ### Endpoint /api/servers ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (array) - An array of server objects. - **name** (string) - The name of the server. - **status** (string) - The current status of the server (e.g., "connected"). - **tools** (array) - A list of tools available on the server. - **name** (string) - The name of the tool. - **description** (string) - The description of the tool. - **config** (object) - The server configuration. - **type** (string) - The type of server configuration (e.g., "stdio"). - **command** (string) - The command to execute for `stdio` type. - **args** (array of strings) - Arguments for the command. ### Response Example { "success": true, "data": [ { "name": "example-server", "status": "connected", "tools": [ { "name": "tool1", "description": "Description of tool 1" } ], "config": { "type": "stdio", "command": "node", "args": ["server.js"] } } ] } ``` -------------------------------- ### Troubleshoot Docker Container Startup Issues Source: https://github.com/samanhappy/mcphub/blob/main/docs/installation.mdx If a Docker container fails to start, check its logs using 'docker logs' or run it interactively for debugging purposes. ```bash # Check container logs docker logs mcphub # Run interactively for debugging docker run -it --rm samanhappy/mcphub /bin/bash ``` -------------------------------- ### Find a tool using mcphub tools list and jq Source: https://github.com/samanhappy/mcphub/blob/main/docs/features/cli.mdx Demonstrates a common agent workflow: first list tools, then filter them using `jq` to find a specific tool. ```bash mcphub tools list --json | jq '.[] | select(.name | contains("fetch"))' ``` -------------------------------- ### Development Environment Variables Source: https://github.com/samanhappy/mcphub/blob/main/docs/configuration/environment-variables.mdx Basic environment variables for a development setup. ```env NODE_ENV=development PORT=3000 JWT_SECRET=dev-secret-key ``` -------------------------------- ### Get a specific mcphub server Source: https://github.com/samanhappy/mcphub/blob/main/docs/features/cli.mdx Retrieve details for a specific server by its name. ```bash mcphub servers get ``` -------------------------------- ### Add Web Fetch Server Source: https://github.com/samanhappy/mcphub/blob/main/docs/quickstart.mdx Configure the web fetch server by specifying its name, command, and arguments. ```json { "name": "fetch", "command": "uvx", "args": ["mcp-server-fetch"] } ``` -------------------------------- ### Build MCPHub with Extended Features Source: https://github.com/samanhappy/mcphub/blob/main/docs/configuration/docker-setup.mdx Build a Docker image with additional tools like Docker Engine and browsers for Playwright by setting the INSTALL_EXT=true build argument. This image is larger but offers extended capabilities. ```bash docker build --build-arg INSTALL_EXT=true -t mcphub:extended . ``` -------------------------------- ### Get Available Servers Source: https://github.com/samanhappy/mcphub/blob/main/docs/api-reference/openapi.mdx Retrieves a list of connected MCP server names. ```bash curl "http://localhost:3000/api/openapi/servers" ``` -------------------------------- ### GET /api/groups/:id Source: https://github.com/samanhappy/mcphub/blob/main/docs/api-reference/groups.mdx Retrieves details for a specific group by its ID or name. ```APIDOC ## GET /api/groups/:id ### Description Retrieves details for a specific group by its ID or name. ### Method GET ### Endpoint /api/groups/:id ### Parameters #### Path Parameters - **:id** (string) - Required - The ID or name of the group. ``` -------------------------------- ### Autonomous agent recipe for mcphub Source: https://github.com/samanhappy/mcphub/blob/main/docs/features/cli.mdx Shows how an agent can drive the discover-call loop using mcphub commands with JSON output, including setting environment variables for URL and token. ```bash export MCPHUB_URL=http://localhost:3000 export MCPHUB_TOKEN=$JWT # 1. enumerate tools mcphub tools list --json > tools.json # 2. pick one and read its schema mcphub tools get fetch_url --json > schema.json # 3. build a payload from the schema and invoke mcphub call fetch_url --params-json "$(jq -n '{url:"https://example.com"}')" --json ``` -------------------------------- ### GET /api/logs/stream Source: https://github.com/samanhappy/mcphub/blob/main/docs/api-reference/logs.mdx Streams logs in real-time using Server-Sent Events (SSE). ```APIDOC ## GET /api/logs/stream ### Description Streams logs in real-time using Server-Sent Events (SSE). The connection will remain open, and new log entries will be sent as they occur. ### Method GET ### Endpoint /api/logs/stream ### Response Format The stream sends events with a `data` field containing a JSON object. The first event has `type: 'initial'` and contains all historical logs. Subsequent events have `type: 'log'` and contain a single new log entry. ### Example Event ``` data: {"type":"log","log":{"timestamp":"2023-10-27T10:00:05.000Z","level":"debug","message":"Processing request for /api/some-endpoint","service":"mcp-server"}} ``` ``` -------------------------------- ### GET /api/users Source: https://github.com/samanhappy/mcphub/blob/main/docs/api-reference/users.mdx Lists all users. The 'password' field is stripped from every record in the response. ```APIDOC ## GET /api/users ### Description Lists all users. The `password` field is stripped from every record. ### Method GET ### Endpoint /api/users ### Response #### Success Response (200) - **data** (array) - An array of user objects, each containing `username` and `isAdmin`. ### Response Example ```json { "success": true, "data": [ { "username": "admin", "isAdmin": true }, { "username": "alice", "isAdmin": false } ] } ``` ``` -------------------------------- ### Add mcphub server inline Source: https://github.com/samanhappy/mcphub/blob/main/docs/features/cli.mdx Add a new server configuration by providing its details directly as arguments. ```bash mcphub servers add fetch \ --type stdio --command uvx \ --arg mcp-server-fetch \ --env USER_AGENT=mcphub ``` -------------------------------- ### Build and Run MCPHub from Source Source: https://github.com/samanhappy/mcphub/blob/main/docs/configuration/docker-setup.mdx Clone the MCPHub repository, build a local Docker image, and run the container. This method is suitable for development when you need to modify the source code. ```bash git clone https://github.com/your-username/mcphub.git cd mcphub docker build -t mcphub:local . docker run -d \ --name mcphub \ -p 3000:3000 \ -v $(pwd)/mcp_settings.json:/app/mcp_settings.json \ mcphub:local ``` -------------------------------- ### Register User Request Example Source: https://github.com/samanhappy/mcphub/blob/main/docs/api-reference/auth.mdx Send a POST request to the /api/auth/register endpoint with username, password, and optional isAdmin flag to create a new user. ```json { "username": "newuser", "password": "password123", "isAdmin": false } ``` -------------------------------- ### Define Private Group Source: https://github.com/samanhappy/mcphub/blob/main/docs/features/group-management.mdx Example JSON configuration for a private group, visible only to specified members. ```json { "name": "internal-tools", "accessLevel": "private", "members": ["user1", "user2"], "servers": ["internal-api", "database"] } ``` -------------------------------- ### Define Public Group Source: https://github.com/samanhappy/mcphub/blob/main/docs/features/group-management.mdx Example JSON configuration for a public group, accessible to all authenticated users. ```json { "name": "public-tools", "accessLevel": "public", "servers": ["fetch", "calculator"] } ``` -------------------------------- ### Configure Server with Manual Client Provisioning Source: https://github.com/samanhappy/mcphub/blob/main/docs/features/oauth.mdx Configure servers that do not support dynamic registration, such as GitHub's MCP endpoint. You must manually create an OAuth App with the provider and supply the client ID and secret. ```json { "mcpServers": { "github": { "type": "sse", "url": "https://api.githubcopilot.com/mcp/", "oauth": { "clientId": "${GITHUB_OAUTH_APP_ID}", "clientSecret": "${GITHUB_OAUTH_APP_SECRET}", "scopes": ["replace-with-provider-scope"], "resource": "https://api.githubcopilot.com" } } } } ``` -------------------------------- ### Login Request Example Source: https://github.com/samanhappy/mcphub/blob/main/docs/api-reference/auth.mdx Send a POST request to the /api/auth/login endpoint with username and password to authenticate. ```json { "username": "admin", "password": "your-admin-password" } ``` -------------------------------- ### Scripting and CI with mcphub JSON output Source: https://github.com/samanhappy/mcphub/blob/main/docs/features/cli.mdx Demonstrates using mcphub commands with the --json flag and environment variables for seamless integration into scripting and CI/CD pipelines. ```bash export MCPHUB_URL=https://hub.example.com export MCPHUB_TOKEN=$CI_HUB_TOKEN mcphub servers list --json | jq '.[] | select(.status != "connected") | .name' ``` -------------------------------- ### List mcphub tools in JSON format Source: https://github.com/samanhappy/mcphub/blob/main/docs/features/cli.mdx Retrieve a machine-readable list of tools without schemas. ```bash mcphub tools list --json ``` -------------------------------- ### GET /api/users/:username Source: https://github.com/samanhappy/mcphub/blob/main/docs/api-reference/users.mdx Retrieves a single user by their username. Returns a 404 if the user does not exist. ```APIDOC ## GET /api/users/:username ### Description Gets a single user by their username. Returns `404` if the user does not exist. ### Method GET ### Endpoint /api/users/:username ### Parameters #### Path Parameters - **username** (string) - Required - The username of the user to retrieve. ### Response #### Success Response (200) - **data** (object) - The user object, containing `username` and `isAdmin`. ### Response Example ```json { "success": true, "data": { "username": "alice", "isAdmin": false } } ``` ``` -------------------------------- ### Exporting mcphub settings Source: https://github.com/samanhappy/mcphub/blob/main/docs/features/cli.mdx Shows how to export the mcphub configuration, either to a specified output file or by redirecting standard output. ```bash mcphub export --out backup.json ``` ```bash mcphub export > backup.json ```