governed-mcp-agent
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
governed-mcp-agent
Production security boundaries for tool-calling AI agents: a stateless Streamable HTTP MCP server (OAuth 2.1 + S256 PKCE + RFC 8707 audience binding), a two-phase HMAC proposal-gate executor ("the model proposes; it never commits"), a single-source Zod / provider-safe JSON Schema DSL, and a deterministic governance eval suite.
Extracted and distilled from production patterns built for real-world operational software (clean-room MIT-licensed reference implementation with zero proprietary data).
Why This Exists
Most LLM agent demos fail in production for three structural reasons:
Unbounded Write Authority: Giving a model direct write tools lets hallucinations, prompt injections, or retry loops mutate ledgers and databases silently.
Schema Drift Across LLM Providers: Hand-maintaining Zod validators separately from JSON Schema tool declarations leads to runtime 400 errors (when providers reject
minimum/maximum/pattern) and silent type mismatches.Insecure Remote MCP Plumbing: Shipping a local
stdioMCP script is easy; exposing a remote HTTP MCP server safely requires RFC 9728 / RFC 8414 discovery, mandatoryS256PKCE, RFC 8707resourceaudience validation, SHA-256 token digests, live permission re-evaluation, and metadata-only audit logs.
Related MCP server: Parimit
Architecture
flowchart LR
Client["MCP Client (Claude / Hosted AI)"] -->|1. Unauthenticated POST /mcp| Guard["McpBearerGuard (401 + WWW-Authenticate)"]
Guard -->|2. Discover RFC 9728 / 8414| OAuth["OAuth 2.1 Server (S256 PKCE + RFC 8707)"]
OAuth -->|3. Audience-bound Access Token| Guard
Guard -->|4. SHA-256 Digest + Live RBAC + Rate Limit| MCP["Streamable HTTP MCP Server (Scoped Reads)"]
Model["In-App Agent"] -->|propose()| Catalog["FieldSpec DSL (Zod + Provider-Safe JSON Schema)"]
Catalog -->|Read Tier| ReadExec["Deterministic Read + Amount Masking"]
Catalog -->|Write / Sensitive Tier| Mint["HKDF + HMAC Stateless Proposal Envelope"]
Mint -->|Human Reviews / Edits -> Confirm| Gate["ActionGate.confirm() (Verify + Live RBAC + Step-Up + Idempotency)"]
Gate --> WriteExec["Deterministic Write Executor + Audit Log"]Key Engineering Trade-offs
Pattern | Decision | Why It Matters in Production |
Two-Phase Proposal Envelope ( | Sign | Eliminates DB proposal tables and TTL sweeps while allowing operators to edit proposed quantities/dates before clicking Confirm. |
Single-Source FieldSpec DSL ( | One declaration emits both | Never emits |
OAuth 2.1 + RFC 8707 + RFC 9728 ( | Reject | Ensures |
Amount Masking & Excluded Intents ( | Strip sensitive valuation fields when | Staff without financial permissions still get stock counts without leaking unit prices; payment-execution intents are refused deterministically before reaching a proposal card. |
Quickstart
Requires Node.js 20+. Runs 100% locally with zero external databases or API keys required.
npm install
npm run typecheck
npm test
npm run evalTo start the local Streamable HTTP MCP server and OAuth 2.1 discovery endpoints:
npm run demo:serverProject Layout
src/
schema/field-spec.ts # Single-source Zod + provider-safe JSON Schema DSL
catalog/action-catalog.ts # Tiered action catalog (read / write / sensitive / excluded)
proposal/proposal-envelope.ts # HKDF-SHA256 + HMAC stateless proposal identity
proposal/action-gate.ts # Two-phase Propose -> Confirm gate with live RBAC & idempotency
mcp/token-guard.ts # SHA-256 token store, RFC 8707 check, rate limit, audit log
mcp/oauth.ts # OAuth 2.1 (S256 PKCE), RFC 9728 / 8414 discovery, refresh rotation
mcp/server.ts # Stateless Streamable HTTP MCP server (@modelcontextprotocol/sdk)
evals/cases.ts # Governance, masking, tamper, and schema-safety eval assertions
evals/runner.ts # CLI eval scorecard runner
tests/
field-spec.test.ts # Zod vs JSON Schema parity & forbidden-keyword checks
proposal-gate.test.ts # Tamper/expiry, edit-on-confirm, mid-flight revocation, idempotency
mcp-server.test.ts # End-to-end HTTP MCP + OAuth 2.1 S256 PKCE + 401/429/revocation
evals.test.ts # Eval harness assertionsAuthor
Pratik Kumar — Anthropic Claude Certified Developer · Agentic AI & Integration Engineer
LinkedIn · Credly Certification
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Governed access to sensitive data, secrets and APIs for AI agents. A signed proof for each decision.
Supervised API-write gateway for AI agents with policy, human approval and execution receipts.
OAuth 2.1 short-link tools for AI agents with scoped tokens, approvals, audit logs, and revocation.
Connect AI agents to bank accounts, transactions, balances, and investments.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to use payment APIs safely by gating every tool call through deterministic mandates, value checks, and an exactly-once ledger, so they cannot pay twice or exceed authorisation.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to propose structured payment intents, apply deterministic policy, require human approval, and record tamper-evident audit trails without connecting to live payment rails.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to access corporate HR and CRM APIs on behalf of a specific user through OAuth 2.1 token verification, deny-by-default RBAC, token exchange, audit logging, PII masking, and untrusted-output envelopes.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to query account balances, audit corporate ledgers, and prepare or execute banking transfers under strict whitelisting, spending caps, human approval, and emergency freeze controls.Business Source 1.1