DOCUMENTATION / PORTKEY ADMIN MCP

Docs for 0.16.6, the latest release

On this page

HTTP deployment

How to self-deploy this MCP server on Vercel. A proof of concept kept for reference; there is no hosted version.

Status (June 2026): This deployment path is a proof of concept kept for reference. There is no hosted version of this server and hosting is not currently a goal — the supported transport is stdio via npx. The steps below remain valid if you want to self-deploy.

This guide describes how to self-deploy this MCP server on Vercel.

This guide follows the SDK v2 implementation shipped in 0.15.0, not the 0.14.x session/replay implementation. No Vercel deployment of it has been verified. Use the guide from your installed release when operating 0.14.x. See compatibility and recovery before upgrading; the retirement and names-only warnings target 0.15.0.

  • Runtime: Vercel Node.js Function (api/index.ts)
  • Transport: Streamable HTTP (/mcp)
  • Request handling: stateless for modern and legacy clients
  • Redis: shared rate limiting only
  • Auth: clerk (preferred for teams) or bearer (internal-only)

Each POST is independent. GET replay, session IDs and DELETE session operations are retired in 0.15.0. After an interrupted mutation, inspect Portkey state before retrying; see the recovery guide. Forward MCP-Protocol-Version, Mcp-Method and Mcp-Name through any proxy. No idle change-notification streams are advertised.

1. Prerequisites

  • Portkey Admin API key with required scopes
  • Redis instance URL (for example Upstash Redis or another managed Redis service)
  • Vercel project connected to this repository
  • Optional but recommended: Clerk app for JWT auth

2. Verify Repo Files

These files should already exist:

  • api/index.ts
  • vercel.json

vercel.json rewrites these routes to the function:

  • /
  • /mcp
  • /health
  • /ready
  • /auth/info

3. Configure Vercel Environment Variables

Set these in Vercel Project Settings -> Environment Variables.

Required:

  • PORTKEY_API_KEY
  • RATE_LIMIT_REDIS_URL=rediss://<ACL-user>:<password>@...
  • ALLOWED_ORIGINS=https://your-app-domain
  • MCP_TRUST_PROXY=1 (adjust only if the verified Vercel proxy chain has a different exact hop count)
  • RATE_LIMIT_STORE=redis

Recommended:

  • MCP_READY_CHECK_MODE=portkey
  • RATE_LIMIT_ENABLED=true
  • MCP_MAX_SESSIONS=100 (per-instance concurrent MCP request bound)

The rate-limit URL also accepts MCP_REDIS_URL then REDIS_URL as fallbacks.

The shared limiter applies an IP bucket before authentication and a separate principal-plus-IP bucket after authentication.

Auth option A (recommended for teams): Clerk JWT

  • MCP_AUTH_MODE=clerk
  • CLERK_ISSUER=https://<your-clerk-domain>
  • CLERK_AUDIENCE=<your-audience> (required)
  • CLERK_JWKS_URL=... (optional; auto-derived from issuer if omitted)
  • At least one identity constraint: CLERK_ALLOWED_SUBJECTS or CLERK_ALLOWED_ORGANIZATION_IDS. CLERK_ALLOWED_ROLES and CLERK_REQUIRED_PERMISSIONS can narrow the policy but can't satisfy this on their own. Every configured constraint must match.

Auth option B (internal shared token):

  • MCP_AUTH_MODE=bearer
  • MCP_AUTH_TOKEN=<long-random-secret>

Do not set:

  • MCP_TLS_KEY_PATH
  • MCP_TLS_CERT_PATH
  • MCP_TLS_CA_PATH

Vercel terminates HTTPS at the edge.

4. Deploy

Use Vercel dashboard or CLI:

code
vercel
vercel --prod

After deploy, your endpoint is:

  • https://<your-project>.vercel.app/mcp

5. Post-Deploy Checks

Unauthenticated endpoints:

code
curl -sS https://<your-project>.vercel.app/health
curl -sS https://<your-project>.vercel.app/ready
curl -sS https://<your-project>.vercel.app/auth/info

Set MCP_PUBLIC_BASE_URL=https://<your-project>.vercel.app in Vercel so /auth/info and the built-in status page advertise a fixed deployment URL instead of deriving it from incoming request headers.

MCP endpoint check:

code
MCP_TEST_BASE_URL=https://<your-project>.vercel.app \
MCP_TEST_BEARER_TOKEN=<token-if-using-bearer> \
npm run test:http

If using Clerk auth, provide a valid Clerk JWT in:

  • MCP_TEST_AUTH_HEADER='Authorization: Bearer <clerk-jwt>'

6. Public Repo Security Checklist

Treat this as required before making the repo public.

  1. Never commit secrets
  • Keep .env local only (already gitignored).
  • Never commit Vercel env exports.
  • Never paste real keys in README, issues, or PR comments.
  1. Assume key leakage can happen
  • Rotate leaked keys immediately in Portkey/Clerk/Redis.
  • Prefer short-lived or scoped credentials where supported.
  1. Keep auth enabled in production
  • Do not run MCP_AUTH_MODE=none in hosted environments.
  • Do not set MCP_ALLOW_UNAUTHENTICATED_HTTP=true in hosted environments.
  1. Restrict origins
  • Set exact domains in ALLOWED_ORIGINS.
  • Avoid * except temporary local debugging.
  1. Use least-privilege Portkey API scopes
  • Only grant scopes this server actually needs for your workflows.
  1. Isolate Redis
  • Require TLS (rediss://) and an ACL user limited to the configured rate-limit prefix.
  • Use a dedicated namespace and credentials per environment.
  1. Enable repository protections
  • Enable GitHub secret scanning and push protection.
  • Require PR reviews before merge to main.
  1. Keep dependencies current
  • Run npm audit regularly.
  • Patch jose, express, and redis updates promptly.

7. Limits and Expected Behavior

  • Some Portkey endpoints can still return 403 AB03 if key scopes are missing.
  • Vercel Functions are request-duration constrained; this repo sets maxDuration in vercel.json.
  • WebSockets are not required for this server; use Streamable HTTP/SSE.

8. Team Operations

For team access:

  • Use one shared Vercel project per environment (staging, production).
  • Manage secrets in Vercel project envs, not in local files.
  • Keep each environment on a separate Portkey key and Redis namespace.

Suggested naming convention:

  • RATE_LIMIT_REDIS_KEY_PREFIX=portkey-admin-mcp:prod
  • RATE_LIMIT_REDIS_KEY_PREFIX=portkey-admin-mcp:staging

Based on the published 0.16.6 release. The source files are in the product repository.