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.
Recommended Architecture
- 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) orbearer(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.tsvercel.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_KEYRATE_LIMIT_REDIS_URL=rediss://<ACL-user>:<password>@...ALLOWED_ORIGINS=https://your-app-domainMCP_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=portkeyRATE_LIMIT_ENABLED=trueMCP_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=clerkCLERK_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_SUBJECTSorCLERK_ALLOWED_ORGANIZATION_IDS.CLERK_ALLOWED_ROLESandCLERK_REQUIRED_PERMISSIONScan 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=bearerMCP_AUTH_TOKEN=<long-random-secret>
Do not set:
MCP_TLS_KEY_PATHMCP_TLS_CERT_PATHMCP_TLS_CA_PATH
Vercel terminates HTTPS at the edge.
4. Deploy
Use Vercel dashboard or CLI:
vercel
vercel --prodAfter deploy, your endpoint is:
https://<your-project>.vercel.app/mcp
5. Post-Deploy Checks
Unauthenticated endpoints:
curl -sS https://<your-project>.vercel.app/health
curl -sS https://<your-project>.vercel.app/ready
curl -sS https://<your-project>.vercel.app/auth/infoSet 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:
MCP_TEST_BASE_URL=https://<your-project>.vercel.app \
MCP_TEST_BEARER_TOKEN=<token-if-using-bearer> \
npm run test:httpIf 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.
- Never commit secrets
- Keep
.envlocal only (already gitignored). - Never commit Vercel env exports.
- Never paste real keys in README, issues, or PR comments.
- Assume key leakage can happen
- Rotate leaked keys immediately in Portkey/Clerk/Redis.
- Prefer short-lived or scoped credentials where supported.
- Keep auth enabled in production
- Do not run
MCP_AUTH_MODE=nonein hosted environments. - Do not set
MCP_ALLOW_UNAUTHENTICATED_HTTP=truein hosted environments.
- Restrict origins
- Set exact domains in
ALLOWED_ORIGINS. - Avoid
*except temporary local debugging.
- Use least-privilege Portkey API scopes
- Only grant scopes this server actually needs for your workflows.
- Isolate Redis
- Require TLS (
rediss://) and an ACL user limited to the configured rate-limit prefix. - Use a dedicated namespace and credentials per environment.
- Enable repository protections
- Enable GitHub secret scanning and push protection.
- Require PR reviews before merge to
main.
- Keep dependencies current
- Run
npm auditregularly. - Patch
jose,express, andredisupdates promptly.
7. Limits and Expected Behavior
- Some Portkey endpoints can still return
403 AB03if key scopes are missing. - Vercel Functions are request-duration constrained; this repo sets
maxDurationinvercel.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:prodRATE_LIMIT_REDIS_KEY_PREFIX=portkey-admin-mcp:staging