This repository is a governance-oriented MCP gateway used to preserve Principal identity between an MCP client and service. It addresses the problem of "MCP losing identity in production": listTools runs on the request thread, while tools/call and SSE run elsewhere, so identity cannot persist throughout. The gateway parses Bearer credentials into a Principal, injects them into every JSON-RPC call, and repeatedly carries them on every SSE frame. Named vault inputs can be rotated in place, for example github_token is replaced while keeping the same name.
Main capabilities: principal injection, SSE frame identity preservation, vault credential rotation, tool allowlist. The repository also contains two other SKUs in the same workspace: the agent spend and authorization plane (Mandate), where the agent proposes first, Mandate authorizes, amounts above the automatic limit require a second human signature, and the proposing agent cannot self-sign; settlement goes through Stripe metering events or x402 payment requests, and the MVP does not make on-chain calls. And an auditable CFO agent grid, where ledger assertions must have an agent, LOCKED CHP status, and at least one source document hash. Shared primitives include the CHP gate, HMAC ledger, HTTP/SSE helpers, and zero runtime npm dependencies.
Usage: it can be connected via the Glama remote connector over Streamable HTTP, with the URL being https://$VERCEL_URL/mcp,授权使用 Bearer $GATEWAY_AGENT_KEY. When deploying to Vercel, import the GitHub repository, set the Build Command to npm run build (which runs scripts/build-vercel.mjs and uses esbuild to output dist/web.mjs), api/index.mjs references that compiled file, and does not load TypeScript via tsx at runtime; outputDirectory is "public". Environment variables need to be configured in the Vercel project settings and the demo values rotated. Locally, you can use npm run mcp or the Dockerfile CMD to follow the Stdio path.
Limitations: initialize does not generate an Mcp-Session-Id; GET /mcp returns 405, and there is no sticky SSE remotely; you need to upload params.pack / params.need on tools/list to get a larger pack beyond the session pack; the demo keys are examples only and should be rotated before exposing a public URL.