guarded-config-mcp
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.
guarded-config-mcp
An MCP server that lets an AI agent change live SaaS configuration, but only what a human has approved, only once, and never over someone else's edit.
The configuration API in this repo is a mock (
src/guarded_config/mock_api/): a small FastAPI app with HR/payroll-style settings for two tenants, held in memory. It is not a real product.
What | 9 MCP tools: reads, dry-run proposals, approved applies, rollback, audit history, per-call cost |
Guards | fixed tenant · capability manifest · dry run · out-of-band human approval · apply-once claim · stale-version check · append-only audit · fail-fast startup |
Evidence | 158 tests on Windows + Linux · 26 guards broken on purpose and shown to fail · real-agent runs recorded |
Built with | Python, FastAPI, httpx, SQLite, MCP Python SDK v2, pytest |
Why
When an agent changes live configuration for a customer, one wrong call is enough to cause damage: the wrong tenant, a value that fails halfway through an onboarding, the same change applied twice, or someone's edit from a minute ago quietly overwritten. And "the agent says it worked" isn't proof. I wanted to work out what a server has to guarantee before I'd let an agent make writes at all.
Related MCP server: kube-handrail
How it works
sequenceDiagram
autonumber
actor Human
participant Agent as Agent (MCP client)
participant Server as Guarded MCP server
participant Store as SQLite (proposals, audit, costs)
participant API as MOCK config API
Agent->>Server: propose_change(leave.annual_days, 30)
Server->>API: GET current value + version
Server->>Store: proposal = pending (base_version 1)
Server-->>Agent: change_id (nothing changed yet)
Agent->>Server: apply_change(change_id)
Server-->>Agent: refused: not approved
Human->>Store: approver CLI approves change_id (as a named person)
Agent->>Server: apply_change(change_id)
Server->>Store: claim: approved → applying (one conditional UPDATE)
Server->>API: PUT value, expected_version = base_version
API-->>Server: 200 (or 409 if someone changed it since)
Server->>Store: applied / failed + audit event, same transaction
Server-->>Agent: applied once, version 2Approval lives only in the approver CLI. No MCP tool, argument or code path can approve or reject.
Guarantees
Guarantee | How | Decision |
Fixed tenant | Set at startup from | |
Only covered settings |
| |
Dry run first |
| |
Human approval, out of band | Only the approver CLI can move a proposal to approved | |
Apply once | One conditional UPDATE claims the proposal; a second apply finds nothing to claim | |
Never over a newer edit | The write carries the proposal's | |
No blind retries | Lost connection or unexpected status → stays | |
Trustworthy audit | Append-only (triggers refuse UPDATE/DELETE); each event commits in the same transaction as its state change | |
Safe rollback | A rollback is just another proposal, based on the version the change produced, so it needs approval and fails as stale if the setting moved | |
Fail fast | No tenant → exit 2; a database with a different layout version → refused at startup (server and CLI) | |
Cost per call | SDK middleware records time, bytes, mock HTTP calls and estimated tokens for every call; telemetry fails open, audit fails closed | |
Known build |
| — |
Tools
Tool | Does |
| What's covered, what's out of scope, and that the API is a mock |
| Read covered settings |
| Dry run: validate and record a pending proposal |
| A proposal and its audit history (this tenant only) |
| Apply a human-approved proposal, once |
| Propose undoing an applied change (needs approval too) |
| Per-tool calls, errors, time, mock HTTP calls, estimated tokens |
| Version, git commit, dirty flag, MCP SDK version |
Quickstart
Python 3.12+. Commands below are PowerShell; on macOS/Linux use .venv/bin/python.
git clone https://github.com/harshithaneelam/guarded-config-mcp.git
cd guarded-config-mcp
py -3.13 -m venv .venv # or: python3 -m venv .venv
.venv\Scripts\python.exe -m pip install -r requirements-lock.txt -e ".[dev]"
.venv\Scripts\python.exe -m pytest # 158 passedRun it with a real agent
Start the mock API and leave it running:
.venv\Scripts\python.exe -m uvicorn guarded_config.mock_api.app:create_app --factory --port 8765Copy
.mcp.json.exampleto.mcp.json(git-ignored), fill in the absolute paths, and open a new Claude Code session in the repo folder. Any MCP client that speaks stdio works.Talk to the agent in plain English, and approve as the human:
.venv\Scripts\python.exe -m guarded_config.approver --db guarded.db --tenant acme list .venv\Scripts\python.exe -m guarded_config.approver --db guarded.db --tenant acme approve CHANGE_ID --as "Your Name" .venv\Scripts\python.exe -m guarded_config.approver --db guarded.db --tenant acme audit .venv\Scripts\python.exe -m guarded_config.approver --db guarded.db --tenant acme costsReplace
CHANGE_IDwith the id the agent gives you (listshows them too).
What it looks like
From a recorded run with Claude Code as the client. The agent's replies are shortened; the full run is in docs/manual-checks.md.
You: Set annual leave to 30 days.
Agent: Annual leave isn't changed yet. I've only proposed the change; it's waiting for your approval.
Change: 24 (version 1) → 30 · Change ID: 6d71a202…
You: Apply it.
Agent: I can't apply it yet because the change hasn't been approved.
[human runs: approver approve 6d71a202… --as "Harshitha Neelam"]
You: Apply it.
Agent: Annual leave is now 30 days. I didn't rely on the apply tool's reply; reading it back from the
mock API gives value 30, version 2, and the audit trail records four events in order.
You: Undo that change.
Agent: I've only proposed the undo, and like any change it needs your approval.
[human approves the rollback]
Agent: Back to 24 days, at version 3. The version went up rather than back to 1.$ approver ... costs
tool calls errors avg_ms est_output_tokens mock_http_calls
get_setting 3 0 14.41 54 3
propose_change 1 0 13.68 72 1
apply_change 2 0 35.69 102 2
...
token_note: estimated as response bytes / 4; this server cannot see the model's real token usageMy 60-second demo script is in docs/demo.md.
Evidence
I made every guard fail on purpose before I trusted it. For each of the 26 breaks in docs/guard-checks.md, the guard was switched off with a throwaway edit, its test was shown failing for the right reason, and the code was restored. The ones that taught me the most:
Guard switched off | What happened |
A hidden write inside the dry run | The tool still replied "Nothing was changed" while the mock held the new value. Only reading the mock's own state caught it. |
The mock's compare-and-set lock | 16 of 16 concurrent writes succeeded, and the version still looked right (every writer computed 1 + 1). Fifteen lost writes only showed up when I counted the 200 responses. |
Write with a freshly read version instead of | A stale change overwrote someone else's edit. A rollback built from a fresh read did the same. |
Audit event outside the state change's transaction | An approval committed with no audit record. |
Tests: 158 (89 functions, some parametrised). I ran them on Windows and Linux; CI runs them on both for Python 3.12 and 3.13 on every push (badge above).
Races: claims, approve-vs-reject decisions and the mock's compare-and-set each run 20 rounds × 16 threads released together, with exactly one winner every round. Read-sleep-write versions lost 16 of 16.
Real agent: out-of-scope reads never reached the mock; an unapproved apply was refused; an approved change applied exactly once; a stale apply was refused and the other person's edit survived; rollback, audit and cost report all matched the session (docs/manual-checks.md).
Limits
The API is a mock, in memory, fresh each run. No real product, OAuth/OIDC, browser automation, Kubernetes or multi-process deployment.
Approval is out of band only from the MCP side (0007). An agent running as the same OS user with a shell could run the approver CLI. In my last run Claude Code, in Auto permission mode, started the mock API on its own and ran the CLI's read-only commands, but chose not to approve. That was the model's choice, not something the system enforces. In production, approvals belong in a separate service with authenticated approvers;
--asisn't authenticated here.Token counts are estimates (response bytes / 4); the server can't see the model's real usage, and every
cost_reportresult says so.Validation rules exist twice (server and mock). A drift test compares them on a table of sample values; values outside it aren't compared. The mock still validates on write.
Races were tested with threads in one process, not separate processes.
The SDK's middleware API is marked provisional in mcp 2.3.0; the lock file pins it and the cost tests would catch a change.
No migrations: a database with an older layout is refused at startup; delete it and start again.
Small things: approver names aren't trimmed inside a list (
" hr "≠"hr"); a body that isn't valid JSON gets a 422 before the mock's tenant check; stdio is the only transport.
How I built it
Claude Code wrote the code, one small step at a time (M0–M8 in PLAN.md), from prompts I wrote. Every prompt said what to build, what not to touch, which tests to write first, and to report the diff and test output. I planned each step and reviewed every report and diff with Claude in a separate chat before committing. Each design choice is a short record in docs/decisions/. The confident mistakes the agents made, and how they were caught, are in AGENT_LOG.md. CLAUDE.md holds the rules the coding agent worked under.
Project layout
src/guarded_config/
mock_api/ MOCK configuration API (FastAPI)
mcp_server/ guarded MCP server (server.py), store (store.py), stdio entrypoint
approver/ human-only approver CLI
tests/ 158 tests
docs/
decisions/ decision records 0001–0007
guard-checks.md every guard break with its failing output
manual-checks.md runs with a real MCP client
demo.md 60-second demo script
AGENT_LOG.md confident agent mistakes, how they were caught, the fixLicense
MIT © 2026 Harshitha Neelam
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
Supervised API-write gateway for AI agents with policy, human approval and execution receipts.
Authorize AI agent tool calls before they run: policy-as-code, human approval, signed receipts.
Permission checks, human approval cards, and signed audit trails for AI agent tool calls.
Zero-secret MCP gateway for AI agents: risk-scored, audited calls with human-in-the-loop approval.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables controlled AI-agent access to enterprise-shaped tools with a deny-by-default gated write path, human approval, dry-run execution, and append-only audit logging.1-
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to perform safe, auditable Kubernetes write actions such as scaling, restarting and rolling back Deployments through a plan → policy-check → approve → apply → audit flow, with server-side guards, single-use plans and scoped RBAC. Read-only planning and Prometheus SLO/alert tools support the same guarded workflow.Apache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to propose changes, obtain human or policy approval, and safely apply them with drift checks, idempotency, verified completion, compensation, and a tamper-evident ledger.35 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants to perform writes safely through a preview-confirm-execute flow, with least-privilege scoped API keys and an audit log of every call.Apache 2.0