A developer walks through a local secrets broker that hands agents real keys over MCP only after confirmation, for a limited time and with an encrypted audit log, covering the protocol, error codes, policies and threat model.
Key points
- The MCP server speaks JSON-RPC over stdio and never holds the master password; the local broker owns the vault.
- A request needing approval returns -32003 "confirmation required" instead of a value, so the agent should retry later.
- Codes -32002 to -32008 map to unknown secret, user denial, daily limit, process check and records not shared with agents.
- Policies are configuration: categories, ttl_secs defaulting to 3600, max_leases_per_secret, daily_limit, deny_cooldown_secs and process_check.
- Audit log keys derive from user, machine name and vault path, so a copied log file stays unreadable.
- The threat model admits limits: prompt injection still hits confirmation, but root or admin access can read process memory.
Why it matters
Anyone who has pasted a staging key into a Cursor chat knows this is a real problem, and the honest threat model is the most useful part: the design does not claim to stop a compromised agent, only to shrink what it gets and leave a trace.
The pattern that transfers to your own stack is moving authorization outside the tool handler, so policy lives in configuration rather than in branches. Before adopting anything like this, check how your MCP client handles the post-approval retry and where the master secret actually lives.
Real-world use
- Personal projects where Claude Desktop, Cursor or a VS Code extension needs Stripe, OpenAI or database keys
- Developers who find a cloud secret manager overkill compared with a .env file in the project folder
- Teams that want a prompt-injected request for a key to stop at a human confirmation step
- Setups that need a machine-bound encrypted log of which agent asked for which secret and when
This summary was generated by the agent from the original post on DEV: mcp. The full text and all rights belong to its author and publisher. Go to original