Skip to main content
Glama
MCP Policy Gateway

MCP Policy Gateway

by gapview01
README.md
# MCP Policy Gateway

An MCP server that wraps everyday commercial tools with guardrails: allowlists, simulate-before-act, approval gates, a cost limit, and an audit trail.

A sales or operations assistant can draft a customer email, propose a spend, or update an account record. It cannot send or execute a material spend until policy passes and, above a set amount, a human approves.

This repo is a companion to [governed-agent-demo](https://github.com/gapview01/governed-agent-demo). That project is the control plane; this one shows how a commercial agent uses the same idea through MCP. All accounts and names are fictional. No API keys are required.

## Scenario

- Draft a customer email to Riverlane Coffee — allowed, counted toward a daily send cap
- Draft to a blocked domain — refused
- Propose an A$200 spend — simulated, auto-approved, executed only when you confirm
- Propose an A$800 campaign spend — simulated, held for approval, refused if you try to execute early

## Tools

| Tool | What it does |
|---|---|
| `draft_customer_email` | Drafts mail to a known fictional account. Enforces blocked domains and a daily cap of 5. |
| `propose_spend` | Simulates a spend. Auto-approves below A$500. Holds larger amounts. Execute is a separate step. |
| `update_account_record` | Updates an allowlisted field (`status`, `owner`, `segment`, `notes`). |
| `get_audit_log` | Returns every tool call, including blocked and waiting actions. |

Policy lives in [`policy/example.json`](policy/example.json).

## Quick start

```bash
npm install
npm test
npm run demo
```

The demo walks through a blocked email, an auto-approved spend and a spend that needs approval.

## Connect an MCP client

```bash
npm run mcp
```

Example Cursor / Claude Desktop snippet:

```json
{
  "mcpServers": {
    "mcp-policy-gateway": {
      "command": "npx",
      "args": ["tsx", "src/server.ts"],
      "cwd": "/path/to/mcp-policy-gateway"
    }
  }
}
```

The server speaks JSON-RPC 2.0, one message per line, on stdin/stdout. A spend that needs a human, then execution:

```json
{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"propose_spend","arguments":{"action":"propose","accountId":"acct-northshore","amount":800,"memo":"Spring catalogue campaign"}}}
{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"propose_spend","arguments":{"action":"decide","proposalId":"spend-........","approve":true,"execute":true}}}
```

## Design notes

- **Simulate-before-act** matters in a regulated business because a model can propose a spend that looks locally reasonable and still breach a daily cap, a counterpart deny list, or an approval threshold. The simulation is visible in the tool result and in the audit log, and it does not move funds.
- **The audit log** is the record you would hand to a risk, finance or customer-operations reviewer: what was proposed, what was blocked, who approved, and what actually executed.
- This is not a production CRM, payments or email integration.

## License

MIT. See [LICENSE](LICENSE).

TDQS

B3.4/5.0

Scored across 4 tools

Disambiguation4/5

Each tool targets a distinct resource: email drafting, spend proposal, account record update, and audit retrieval, so misselection risk is low. The only wrinkle is propose_spend folding propose/decide/execute into one action parameter, which blends several operations into a single tool and can make the approval flow less obvious.

Naming Consistency5/5

All four names follow a clean verb_noun snake_case pattern (draft_customer_email, propose_spend, update_account_record, get_audit_log). The convention is predictable and readable throughout.

Tool Count4/5

Four tools map neatly onto the gateway's governed actions plus an audit trail, so each earns its place. The surface is slightly thin, but nothing feels redundant or bolted on.

Completeness3/5

Governed write actions and observability via get_audit_log are covered, but there is no read/list tool for account records or accounts, so update_account_record has no corresponding read path. There is also no way to inspect policy rules or pending approvals except indirectly through the audit log.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues