Skip to main content
Glama
Cubiczan

governed-mcp-gateway

Cubiczan Agent Platform

Cubiczan/governed-mcp-gateway MCP server — quality and maintenance score on Glama

Identity, money, and evidence for agents that actually ship.

Three SKUs, one workspace. MCP clients keep a Bearer principal through tools/call and SSE. Spend cannot settle without a mandate and, over cap, a human second key. Board claims cannot seal without an agent, a CHP lock, and a hashed document.

Three SKUs: governed MCP gateway, spend mandate plane, CFO agent mesh

SKU

Port

Source

Job

Governed MCP Gateway

:7474

Cubiczan/governed-mcp-gateway

Principal on every tool call and SSE frame. Vaulted credential rotation. Tool allowlists. Schema token-tax ledger and pack / allow-by-need tools/list.

Agent Spend & Mandate Plane

:7475

this workspace

Propose → mandate → countersign → settle. Stripe by default; x402 is a rail.

Auditable CFO Agent Mesh

:7476

this workspace

Claim → agent → lock → document. ASC 842 / 606 / 718 engines. HMAC-chained evidence pack.

Shared primitives (packages/shared): CHP gate, HMAC ledger, HTTP/SSE helpers. Zero runtime npm dependencies. Stripe and x402 are rails — tests never call live networks.

Quickstart

npm install
npm test
npm run gateway   # :7474
npm run spend     # :7475
npm run cfo       # :7476

Demo Bearer keys (also in .env.example):

Role

Key

Gateway agent

mcp_agt_payops_demo

Gateway human

mcp_human_controller_demo

Gateway research (no stripe.charge)

mcp_agt_research_demo

Spend agent

spend_agt_payops_demo

Spend human

spend_human_controller_demo

CFO agent

cfo_agt_lease_demo

CFO human

cfo_human_controller_demo

Regenerate the README cards from live local APIs:

npm run shots

Related MCP server: production-grade-mcp-agentic-system

1. Governed MCP Gateway

Production MCP drops identity. listTools runs on the request thread; tools/call and SSE run somewhere else. This gateway resolves a Bearer credential to a Principal, injects it on every JSON-RPC call, and repeats it on every SSE frame. Named vault inputs rotate in place — github_token stays github_token.

Principal injected on tools/call

SSE repeats principal on every frame

Rotate github_token without a new input id

curl -sS -H "Authorization: Bearer mcp_agt_payops_demo" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"echo.ping","arguments":{"hello":"world"}}}' \
  http://127.0.0.1:7474/mcp

Method

Path

What

GET

/health /healthz

Liveness ({ ok, service, transport, mode }). No auth.

POST

/mcp

Streamable HTTP JSON-RPC initialize, tools/list (default: session pack), tools/call

GET

/mcp/sse?once=1

Local SSE notification with _meta.cubiczan.principal (not the Vercel path)

GET

/v1/context/tax

Schema token-tax estate + session report

POST

/v1/context/need

Admit allowlisted tools into the session pack

POST

/v1/credentials/:name/rotate

Human-only vault rotate; old hash dies

POST

/v1/credentials/verify

Check a secret against the current hash

Glama remote connector

Glama can health-check a stateless Streamable HTTP remote at https://$VERCEL_URL/mcp with Bearer auth. This is the hosted HTTPS path. Stdio (npm run mcp / Dockerfile CMD) remains the Glama Docker build path.

Vercel project settings (import this GitHub repo; do not invent a hostname):

Setting

Value

Root Directory

. (repository root — vercel.json + api/)

Framework Preset

Other (vercel.json sets "framework": null)

Fluid Compute

On ("fluid": true)

Node.js

20 or later

Install Command

npm ci && npm run build (vercel.json already sets this)

Build Command

npm run build (esbuild → dist/web.mjs; do not run tsc)

Output Directory

public (empty static dir for the Other preset; Fluid still serves /api)

npm run build runs scripts/build-vercel.mjs (esbuild). That emits dist/web.mjs. api/index.mjs imports that compiled file — it does not load TypeScript via runtime tsx. Demo allowlist and oversized-schema seed are inlined in that bundle so Fluid does not open test/fixtures/ (the function only includes dist/**). The Other preset still expects a static output folder after a custom buildCommand; public/ is that folder (outputDirectory: "public"). If the Vercel dashboard still has a Build Command of tsc, clear it or set it to npm run build so TS5097 does not come back. Dashboard overrides are not required if vercel.json is honored.

Environment variables (Vercel Project → Settings → Environment Variables). Rotate the demo values before a public URL:

Name

Local demo

Role

GATEWAY_AGENT_KEY

mcp_agt_payops_demo

Glama connector Bearer (PayOps allowlist)

GATEWAY_HUMAN_KEY

mcp_human_controller_demo

Vault / locks

GATEWAY_RESEARCH_KEY

mcp_agt_research_demo

Research allowlist (no stripe.charge)

SPEND_PLANE_URL

unset

Optional hook to :7475

Glama connector fields after deploy (replace $VERCEL_URL with the deployment host Vercel prints):

  • URL: https://$VERCEL_URL/mcp

  • Transport: Streamable HTTP

  • Authorization: Bearer $GATEWAY_AGENT_KEY

Local smoke (no public hostname):

npm run mcp:http:smoke
# or:
npm run gateway
curl -sS http://127.0.0.1:7474/health
curl -sS -H "Authorization: Bearer mcp_agt_payops_demo" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"smoke","version":"0"}}}' \
  http://127.0.0.1:7474/mcp

initialize does not mint Mcp-Session-Id. Pass params.pack / params.need on the same tools/list when you need more than the session pack. GET /mcp is 405 (no sticky SSE on the remote).


2. Agent Spend & Mandate Plane

Agents propose. Mandates authorize. A human countersigns when the amount is over the auto cap. The proposing agent cannot countersign itself. Settlement is a rail: Stripe meter event by default, x402 payment-required if you ask for it. No chain calls in this MVP.

Under-cap proposal auto-locks

Over-cap requires a human second key

Stripe meter vs x402 payment-required

curl -sS -H "Authorization: Bearer spend_agt_payops_demo" \
  -H "Content-Type: application/json" \
  -d '{"agent":"agt_payops","merchant":{"name":"Stripe","url":"https://stripe.com","country":"US"},"total":"12.00","rationale":"tool meter"}' \
  http://127.0.0.1:7475/v1/proposals

Method

Path

What

POST

/v1/mandates

Operator creates remaining-cents coverage

POST

/v1/proposals

Agent propose; lane auto | approval | blocked

POST

/v1/countersign

Human second key; agents are rejected

POST

/v1/settle

{ "rail": "stripe" } or "x402"


3. Auditable CFO Agent Mesh

A board claim is not done until it has an agent, a LOCKED CHP state, and at least one source document hash. Engines measure (ASC 842 lease rollforward, ASC 606 constrained POC, ASC 718 SBC). They do not decide facts of law. Token spend attaches as a source on the same HMAC-chained ledger.

Unsealed claim without documents

Sealed evidence pack

ASC 842 finance lease ends at 0.00

curl -sS -H "Authorization: Bearer cfo_agt_lease_demo" \
  -H "Content-Type: application/json" \
  -d '{"title":"AI spend is $12.00 this period","narrative":"Token ledger supports the board claim.","agentId":"agt_lease"}' \
  http://127.0.0.1:7476/v1/claims

Method

Path

What

POST

/v1/claims

Open a claim

POST

/v1/claims/:id/documents

Attach a named source; SHA-256 stored

POST

/v1/claims/:id/lock

Human lock → LOCKED

POST

/v1/engines/lease

ASC 842 classification + rollforward

GET

/v1/evidence/:id

Seal; 400 if no documents or not locked

Specs

OpenSpec changes: ship-three-sku-platform, tools-list-token-tax, glama-streamable-http-remote, vercel-compiled-fluid-entry, vercel-public-output-directory.

License

MIT

Available Tools

3 tools
context.inspectA

Read the current session pack and schema token-tax report for the authenticated principal. Returns the bytes→tokens heuristic, session tool names, savedTokens versus the full allowlist, and (unless includeEstate=false) the estate including oversized flags. Does not admit tools and does not execute other tools. Call this before context.need to see what is already loaded. Fail-closed: requires the same principal as the session.

ParametersJSON Schema
NameRequiredDescriptionDefault
sessionIdNoOptional session id; defaults to ses_<principalId> when omitted.
includeEstateNoWhen false, omit the full catalog estate and return only session tax. Default true.

TDQS

A4.4/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full behavioral burden. It discloses fail-closed authentication requirements, confirms no side effects ('Does not admit tools and does not execute other tools'), and specifies conditional output based on includeEstate. This is strong behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Four sentences with no filler. The main purpose is front-loaded, followed by return details, exclusions, a direct usage pointer, and the auth requirement. Every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no output schema and no annotations, the description explains the return contents, the conditional estate flag, the lack of side effects, and the auth constraint. It is nearly complete; only edge-case error behavior is not described, which is a minor gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds some context by tying includeEstate to the estate report and showing how the returned data varies, but it largely restates what the schema already documents.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: 'Read the current session pack and schema token-tax report.' It also explicitly differentiates itself by saying it 'does not admit tools and does not execute other tools,' and names context.need as the related sibling to compare against.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit usage guidance: 'Call this before context.need to see what is already loaded.' It also clarifies what the tool does not do, helping an agent avoid using it for admission or execution. It does not explicitly address echo.ping, but the context is clear enough.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

context.needA

Admit extra tools or a named pack into this session (allow-by-need). Always intersected with the principal allowlist — fail-closed. Research cannot admit stripe.charge. Does not run the admitted tools; call tools/list afterwards to see the new pack, or context.inspect to see tax. sessionId defaults to ses_. Denied names are returned in denied[] and recorded on the ledger.

ParametersJSON Schema
NameRequiredDescriptionDefault
packNoNamed pack to admit (catalog, core, payments, research). Intersected with the allowlist.
toolsNoConcrete tool names to admit (e.g. stripe.charge). Ignored when not allowlisted.
sessionIdNoOptional session id; defaults to ses_<principalId> when omitted.

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations present, the description carries the full behavioral burden and does so thoroughly: allowlist intersection, fail-closed behavior, the stripe.charge restriction for research, non-execution of admitted tools, denied[] output, ledger recording, and sessionId defaulting are all disclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is dense but every sentence earns its place. The core purpose is front-loaded, followed by restrictions, post-conditions, defaults, and failure behavior, all in a compact, readable form.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no output schema, the description explains key return behavior (denied[]) and points to tools/list and context.inspect for further observation. It does not specify the full success response shape, but the essential operational context is present.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description adds meaning beyond the schema by explaining the fail-closed intersection, the specific research/stripe.charge restriction, and the denied[]/ledger behavior tied to the tools parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb and resource: 'Admit extra tools or a named pack into this session (allow-by-need).' It clearly distinguishes what the tool does from the siblings context.inspect and echo.ping by framing it as an admission action rather than inspection or echo.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives clear context for when to use the tool: when extra tools or a pack need to be admitted. It also provides follow-up guidance (tools/list, context.inspect), though it does not explicitly enumerate when not to use it or systematically contrast it with alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

echo.pingA

Identity probe. Echoes the call arguments and the authenticated Principal the gateway injected onto this tools/call (id, kind, org). Use it to confirm Bearer identity survived onto the tool worker. Does not hit a network, mutate vault state, or charge. Idempotent except for an audit-ledger append. Not a substitute for context.inspect.

ParametersJSON Schema
NameRequiredDescriptionDefault
messageNoOptional ping payload echoed back in the result. Omit to send an empty ping.

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool does not hit the network, mutate vault state, or charge, and that it is idempotent except for an audit-ledger append. This gives an agent a clear behavioral safety profile without needing structured annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded with purpose, followed by usage guidance, side-effect transparency, and a sibling distinction. Every sentence earns its place and there is no redundant prose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-optional-parameter tool with no output schema, the description is complete: it explains what is echoed, what authentication context is returned, when to use it, and what side effects to expect. An agent has enough context to invoke it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There is only one optional parameter, message, and schema description coverage is 100%. The schema already explains that the message is echoed back and that omitting it sends an empty ping, so the description adds little beyond what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with 'Identity probe' and states precisely what the tool does: echoes call arguments and the authenticated Principal. It also distinguishes itself from the sibling context.inspect with the explicit 'Not a substitute for context.inspect' note, so an agent can tell them apart.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives an explicit use case: 'Use it to confirm Bearer identity survived onto the tool worker.' It also provides a clear when-not-to-use signal by stating it is not a substitute for context.inspect, naming the relevant alternative.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 3 tool updatesv0.1.0
    • First observedcontext.inspect
    • First observedcontext.need
    • First observedecho.ping

TDQS

A4.5/5.0

Scored across 3 tools

Disambiguation5/5

context.inspect is read-only session state, context.need is a mutating admission action, and echo.ping is an identity probe. The descriptions explicitly distinguish their purposes, so an agent should not confuse them.

Naming Consistency5/5

All tool names follow a consistent namespace.action pattern: context.inspect, context.need, and echo.ping. Even though the namespaces differ, the lowercase dot-separated verb suffix style is uniform across the set.

Tool Count5/5

Three tools is small but well-scoped for a governance gateway: inspect current state, request admission, and verify identity. Each tool provides a distinct, non-redundant operation that earns its place.

Completeness3/5

The core read and admit operations are covered, and built-in tools/list handles discovery, but there is no way to revoke, release, or reset previously admitted tools or packs. This creates a notable lifecycle gap for an over-admission scenario.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    MCP server that lets AI agents call APIs without ever seeing the credentials, using a local encrypted vault and per-secret allowlist policies for HTTP requests and subprocess environment variables.
    1
    AGPL 3.0
  • F
    license
    Not graded
    quality
    D
    maintenance
    A production-ready MCP server that authenticates agents via OAuth 2.1 Bearer tokens, validates JWTs with JWKS, enforces tool-level scopes and roles, and logs the full delegation chain.
    -