Skip to content

MCP Hub API

The MCP Hub exposes two surfaces:

  • Hub admin API (https://mcp-hub.../admin/*) — internal-only, for install/restart/uninstall
  • Portal proxy (https://portal.../api/mcp-hub/*) — same shape, but the admin token stays server-side

All admin endpoints require X-Internal-Token matching the hub’s INTERNAL_SERVICE_TOKEN. The portal proxy forwards calls with its own MCP_HUB_ADMIN_TOKEN env, so UI clients never handle the hub token directly.

Hub endpoints

GET /health

Liveness + installed counts.

{
"status": "ok",
"service": "ltg-mcp-hub",
"version": "1.0.0",
"portalApi": "http://portal.railway.internal:3000",
"hostedCount": 3,
"running": 2,
"crashed": 0
}

GET /catalog

Built-in catalog of installable MCPs. No auth required.

{
"catalog": [
{
"slug": "pandoc",
"name": "Pandoc",
"description": "Convert documents between formats…",
"runtime": "python",
"installSpec": { "type": "uvx", "package": "mcp-pandoc" },
"suggestedToolPrefix": "pandoc_",
"tags": ["documents", "conversion"]
}
// …
]
}

POST /admin/install

Install a new MCP.

Request body:

{
slug?: string; // url-safe id; defaults to catalog entry's slug
name?: string;
catalogSlug?: string; // pick from the built-in catalog
installSpec?: { // OR provide a custom install spec
type: 'uvx' | 'npx' | 'pip' | 'npm' | 'github';
package: string;
command?: string; // override the whole command
args?: string[];
};
env?: Record<string, string>; // plaintext or @credential:<uuid> sentinel
toolPrefix?: string; // defaults to `${slug}_`
productId?: string; // optional, for legacy product gating
autoRegister?: boolean; // default true — create MCP Servers entry + discover
}

Response: 202 Accepted

{
"status": "installing",
"slug": "pandoc",
"hostedUrl": "http://mcp-hub.railway.internal:4000/hosted/pandoc/mcp"
}

The install proceeds in the background. Poll GET /admin/list or GET /admin/status/:slug to track progress. The record transitions installing → (test spawn) → stopped (or crashed on failure). If autoRegister=true, the hub then calls the portal’s POST /api/mcp-servers + POST /api/mcp-servers/:id/discover.

env sentinels:

{ "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "@credential:a8f3-…" } }

The hub resolves @credential:<uuid> values by calling GET /api/credentials/:id/reveal on the portal at spawn time. Plaintext never persists in the hub’s record.

GET /admin/list

Current hosted MCPs + their statuses.

{
"hosted": [
{
"slug": "pandoc",
"name": "Pandoc",
"installSpec": { "type": "uvx", "package": "mcp-pandoc" },
"status": "running",
"crashes": [],
"lastStarted": 1776887741478,
"lastUsed": 1776887741478,
"lastError": null
}
]
}

GET /admin/status/:slug

Single-record detail. Same shape as one entry from /admin/list.

POST /admin/restart/:slug

Kills the subprocess and respawns it. Resets crashes to empty.

Response:

{ "ok": true, "slug": "pandoc" }

POST /admin/uninstall/:slug

Stops the subprocess and removes the record from the hub pool. Does not remove the MCP Servers registry entry on the portal — call DELETE /api/mcp-servers/:id separately to clean that up.

Hosted MCP endpoint

POST /hosted/:slug/mcp

Streamable-HTTP MCP endpoint. Accepts initialize, tools/list, tools/call. The hub bridges each request to the subprocess’s stdio.

No auth required on this endpoint — it’s intended to be called only from the gateway over internal Railway networking. Customer-facing auth happens at the gateway layer.

GET /hosted/:slug/mcp

Returns 405 — streamable-HTTP MCP clients must use POST.

Portal proxy

The portal exposes /api/mcp-hub/* with matching semantics. Clients authenticated via the portal session (admin-only routes) can hit these — the portal forwards to the hub with its stored MCP_HUB_ADMIN_TOKEN:

Portal proxy Underlying hub endpoint
GET /api/mcp-hub/health GET /health
GET /api/mcp-hub/catalog GET /catalog
GET /api/mcp-hub/list GET /admin/list
GET /api/mcp-hub/status/:slug GET /admin/status/:slug
POST /api/mcp-hub/install POST /admin/install
POST /api/mcp-hub/restart/:slug POST /admin/restart/:slug
POST /api/mcp-hub/uninstall/:slug POST /admin/uninstall/:slug

Every install/restart/uninstall call is audit-logged on the portal as mcp_hub.install_requested, mcp_hub.restart, or mcp_hub.uninstall.

Environment variables

Hub service

Var Required Purpose
PORT No (default 4000) HTTP listen port
INTERNAL_SERVICE_TOKEN Yes Validates inbound /admin callers
PORTAL_INTERNAL_TOKEN Yes Outbound token the hub uses when calling portal endpoints (register, discover, vault reveal)
PORTAL_API_URL No (default http://portal.railway.internal:3000) Base URL for outbound portal calls
HUB_INTERNAL_URL No (default http://mcp-hub.railway.internal:4000) Written into McpServer.serverUrl at auto-register
RAILWAY_DOCKERFILE_PATH Recommended apps/mcp-hub/Dockerfile — forces correct Dockerfile on monorepo deploys
RAILWAY_ROOT_DIRECTORY Recommended apps/mcp-hub

Portal service (for hub proxy)

Var Required Purpose
MCP_HUB_URL No (default internal DNS) Where the portal reaches the hub
MCP_HUB_ADMIN_TOKEN Yes Token the portal sends to the hub — must match hub’s INTERNAL_SERVICE_TOKEN