Adding MCP Servers
The LTG API Portal works as an MCP gateway — a single entry point that wraps many upstream MCP servers. Customers authenticate once with Authentik OAuth + their ltg_* API key, and get access to every wrapped MCP’s tools through one connection.
This guide walks you through adding a new MCP server to the platform end-to-end.
Architecture
Customer (Claude Desktop) │ │ mcp-remote → OAuth (Authentik) + X-API-Key: ltg_xxx ▼LTG MCP Gateway (apps/mcp-server) ← single entry point │ │ 1. Verify Authentik access token (who) │ 2. Validate ltg_xxx key (quota, rate limit, billing) │ 3. Route to upstream by tool prefix ▼Upstream MCPs (private Railway services) ├─ LogicMonitor MCP → lm_* tools ├─ Stripe MCP → stripe_* tools └─ Any new MCP → prefix_* toolsCustomers never see upstream URLs, bearer tokens, or credentials. Everything flows through our gateway with unified auth and usage tracking.
OAuth2 / Authentik — One Application, Every MCP
You do not register a new Authentik application per MCP. The gateway (apps/mcp-server) is the single OAuth2 client registered in Authentik. Everything wrapped behind it reuses that flow.
Authentik Application: "LTG MCP Gateway" ← one application, forever ├─ Client ID / Secret → held by apps/mcp-server ├─ Redirect URIs → https://mcp-server-production-ba1f.up.railway.app/callback └─ Scopes → openid profile emailWhen a customer connects via mcp-remote:
- OAuth (who): Claude Desktop → mcp-remote → Authentik login → access token issued to the gateway (not the upstream)
- API key (what plan):
X-API-Key: ltg_xxx→ validated against portal subscription (quota, rate limit, product entitlement) - Upstream bearer (server-side): gateway forwards with
Authorization: Bearer <MCP_BEARER_TOKEN>from the credentials vault
The upstream MCP never sees the Authentik token or the ltg_* key — only the server-side bearer. This means:
- ✅ No Authentik admin changes when adding an MCP
- ✅ No per-MCP client IDs, redirect URIs, or scopes
- ✅ Upstreams don’t need to support OAuth2 — plain bearer is enough
- ✅ Token rotation on one upstream doesn’t affect customers
- ✅ Revoking a customer = revoke their
ltg_*key, not their OAuth session
If you ever need to replace the gateway’s Authentik application (e.g. domain change), update the AUTHENTIK_* env vars on apps/mcp-server and restart — no upstream MCP is affected.
Requirements for the Upstream MCP
Any MCP you want to wrap needs:
- Streamable HTTP transport (preferred) or SSE
- Bearer token auth via
Authorization: Bearer <token>header - Health check endpoint (
/healthzor similar) - Dockerfile for Railway deployment
- Configurable via env vars for credentials
Most open-source MCPs already support all of these. If yours doesn’t, fork it and add a small Express wrapper.
Step 1 — Deploy the MCP to Railway
1a. Create a new Railway service
railway add --service my-mcpChoose “Empty Service” when prompted.
1b. Link it to the GitHub repo (or deploy from local)
Option A: GitHub source
- Railway dashboard → your service → Settings → Source → connect GitHub repo
- Set branch + root directory
- Railway auto-deploys on push
Option B: Deploy from local clone
git clone https://github.com/<owner>/<mcp-repo>.git /tmp/my-mcpcd /tmp/my-mcprailway link --project <project-id> --service my-mcprailway up -d1c. Set env vars
# Generate a secure bearer token — this is the upstream auth our gateway usesBEARER=$(openssl rand -base64 32)
railway variables --service my-mcp \ --set "MCP_TRANSPORT=streamable-http" \ --set "MCP_ADDRESS=0.0.0.0:\${PORT}" \ --set "MCP_ENDPOINT_PATH=/mcp" \ --set "MCP_BEARER_TOKEN=$BEARER" \ --set "MCP_READ_ONLY=true" \ --set "NODE_ENV=production" \ --set "PORT=3000"
# Plus whatever credentials the MCP needs (e.g. LM_COMPANY, LM_BEARER_TOKEN)railway variables --service my-mcp \ --set "MY_API_KEY=<from vendor>" \ --set "MY_API_SECRET=<from vendor>"1d. Keep it private
Do NOT generate a public domain. The upstream MCP should only be reachable from inside your Railway project via the internal DNS:
http://my-mcp.railway.internal:3000/mcpCustomers will connect through our MCP gateway, not the upstream directly. This keeps your bearer tokens and vendor credentials server-side.
1e. Verify
From any service in the same Railway project (e.g. the portal shell):
curl http://my-mcp.railway.internal:3000/healthz# → "ok"Step 2 — Store the Bearer Token in the Portal Credentials Vault
- Portal → Credentials → Add Credential
- Fill in:
- Name:
My MCP Gateway Token - Provider:
my-mcp - Grant Type:
bearer - Secret: the
MCP_BEARER_TOKENvalue from Step 1c
- Name:
The vault encrypts the secret at rest and shows a masked preview (abcd••••xyz). The actual value is only read by the gateway when forwarding requests.
Step 3 — Register the MCP in the Portal Registry
- Portal → MCP Servers → Register MCP Server
- Fill in:
| Field | Value |
|---|---|
| Name | My MCP |
| Description | Short description customers will see |
| Server URL | http://my-mcp.railway.internal:3000/mcp |
| Transport | STREAMABLE-HTTP |
| Auth Type | Bearer Token |
| API Key / Token | (paste the same MCP_BEARER_TOKEN value) |
-
Under Gateway Wrapping:
- ✅ Enable Gateway Wrapping
- Tool Prefix:
mymcp_(short namespace, trailing underscore) - Product ID: (optional) — link to a subscription product to gate access
-
Click Register Server
Step 4 — Discover Tools
On the MCP server detail page:
- Click Discover Tools
- Verify the tool count and spot-check a few names
- Status should flip from
UNKNOWN/OFFLINEtoONLINE
Tools are now cached in the portal and ready for the gateway to re-export.
Step 5 — (Optional) Create a Product for Resale
If you want to charge for this MCP as a distinct SKU:
- Portal → Products → Add Product
- Name it to match the
Product IDyou set in Step 3 (e.g.my-mcp) - Link it to pricing plans in Packages (e.g. Pro-only, Enterprise-only)
- Customers must subscribe to this product to use the wrapped tools
Without a product ID, all authenticated customers with any active subscription can use the tools.
Step 6 — Test from the Portal
On the MCP server detail page:
- Invoke Tool dropdown → pick a read-only tool (e.g.
list_resources) - Fill in required params
- Click Run Tool — real upstream data comes back
This confirms the portal can reach the upstream MCP with the stored credentials.
Step 7 — Test from Claude Desktop
Edit your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{ "mcpServers": { "ltg": { "command": "bash", "args": [ "-c", "exec npx -y mcp-remote@latest https://mcp-server-production-ba1f.up.railway.app/mcp --header 'X-API-Key: ltg_YOUR_KEY_HERE'" ] } }}Then:
- Restart Claude Desktop
- OAuth popup appears → sign in with Authentik
- List MCP tools — you should see your new
mymcp_*tools alongside the built-in portal/ConnectWise tools - Invoke a tool — it routes through our gateway → validates subscription → forwards to upstream → response returned
Step 8 — Verify Usage Tracking
Every gateway call counts against the customer’s ltg_* subscription:
- Portal → Usage page → see the call appear in Recent Requests
- Portal → Usage → click the subscription → see
/mcp/mymcp_<tool>in Top Endpoints - Customer’s
callCount/callCountTodayincrements - Plan rate limits and daily quotas enforced automatically
Monitoring
| Signal | Where to look |
|---|---|
| Upstream crashes / errors | Railway → your MCP service → Logs |
| Customer invocations | Portal → Audit Log → filter by mcp_server.tool_called |
| Usage breakdown | Portal → Usage → Top Endpoints |
| Per-subscription drill-in | Portal → Usage → click subscription row |
Troubleshooting
| Symptom | Likely Cause | Fix |
|---|---|---|
| Tool not discovered | Gateway Enabled unchecked, or status=offline |
Discover Tools again, verify upstream is running |
| 401 from upstream | MCP_BEARER_TOKEN mismatch |
Check credentials vault matches Railway env var |
Subscription required: ... |
Customer lacks the product | Subscribe them to the product, or remove Product ID |
| 429 rate limited | Plan quota exceeded | Upgrade plan or wait for reset |
| Tool name collision | Two upstreams exposing same name | Set distinct Tool Prefix values |
| Gateway not loading upstream | Background cache stale | Restart mcp-server, or wait 60s |
Updating an MCP
- Code updates: if connected to GitHub, Railway auto-redeploys on push. Otherwise run
railway up -dfrom the local clone. - Env var changes: Railway redeploys automatically on variable update.
- Token rotation: update both the Railway env var AND the credentials vault entry. Portal
mcp-serverpicks up the new credential within 60s. - New tools added upstream: click Refresh on the MCP server detail page to re-discover.
Pattern Summary
Adding a new MCP is now a repeatable 7-step process:
- Deploy MCP as a private Railway service with a bearer token
- Store the token in the portal Credentials Vault
- Register in MCP Servers with Gateway Wrapping enabled
- Discover tools
- (Optional) Create a Product for monetization
- Test via portal Invoke Tool
- Customers use it automatically through their existing Claude connection
No changes to customer configuration. No per-upstream OAuth flows. One API key, one subscription, one set of rate limits — every wrapped MCP inherits the same auth, billing, and observability.