Skill files2 files

references/

SKILL.md217 lines
1
---
2
name: protect-mcp-setup
3
description: Configure Cedar policy enforcement and Ed25519 signed receipts for Claude Code tool calls. Use when setting up projects that need cryptographic audit trails, policy-gated tool execution, or compliance-ready evidence of agent actions.
4
---
5
6
# protect-mcp — Policy Enforcement + Signed Receipts
7
8
Cryptographic governance for every Claude Code tool call. Each invocation is
9
evaluated against a Cedar policy and produces an Ed25519-signed receipt that
10
anyone can verify offline.
11
12
## Overview
13
14
Claude Code runs powerful tools: `Bash`, `Edit`, `Write`, `WebFetch`. By default
15
there is no audit trail, no policy enforcement, and no way to prove what was
16
decided after the fact. `protect-mcp` closes all three gaps:
17
18
- **Cedar policies** (AWS's open authorization engine) evaluate every tool call
19
before execution. Cedar deny is authoritative.
20
- **Ed25519 receipts** record the name of each tool that ran, signed with
21
your key.
22
- **Offline verification** via `npx @veritasacta/verify`. No server, no account,
23
no trust in the operator.
24
25
## Problem
26
27
AI agents make decisions that affect money, safety, and rights. The Claude Code
28
session log records what happened, but the log is:
29
30
- Mutable — anyone with access can edit it
31
- Unsigned — there is no way to prove integrity
32
- Operator-bound — verification requires trusting whoever holds the log
33
34
For compliance contexts (finance, healthcare, regulated research), this is not
35
sufficient. You need tamper-evident evidence that can be verified by third
36
parties without trusting you.
37
38
## Solution
39
40
Add `protect-mcp` to your Claude Code project:
41
42
```bash
43
# 1. Install the plugin (adds hooks + skill to your project)
44
claude plugin install wshobson/agents/protect-mcp
45
46
# 2. Create ./protect.cedar (see below). The plugin installs the hooks.
47
48
# 3. Create the signing key once (protect-mcp 0.32.5 sign does not create it).
49
# An existing key is never replaced. See references/receipt-format.md to rotate.
50
if [ ! -e ./protect-mcp.key ]; then
51
d=$(mktemp -d) && npx protect-mcp@0.32.5 init --dir "$d" && mv "$d/keys/gateway.json" ./protect-mcp.key
52
fi
53
chmod 600 ./protect-mcp.key
54
echo "/protect-mcp.key" >> .gitignore
55
56
# 4. Use Claude Code normally. Every tool call is now policy-evaluated
57
# and produces a signed receipt in ./receipts/
58
```
59
60
## Hook Configuration
61
62
Installing the plugin adds both hooks from `hooks/hooks.json`. Each hook runs a
63
script bundled with the plugin:
64
65
```json
66
{
67
"hooks": {
68
"PreToolUse": [
69
{
70
"matcher": ".*",
71
"hooks": [
72
{ "type": "command", "command": "\"${CLAUDE_PLUGIN_ROOT}\"/hooks/evaluate.sh" }
73
]
74
}
75
],
76
"PostToolUse": [
77
{
78
"matcher": ".*",
79
"hooks": [
80
{ "type": "command", "command": "\"${CLAUDE_PLUGIN_ROOT}\"/hooks/sign.sh" }
81
]
82
}
83
]
84
}
85
}
86
```
87
88
Claude Code passes the hook event to the command as JSON on stdin and does not
89
set `TOOL_NAME` or `TOOL_INPUT` variables. `evaluate.sh` reads `tool_name` and
90
`tool_input` from that payload and passes them to `protect-mcp` as flags; `sign.sh` reads
91
`tool_name` only, preserving tool-only receipt coverage. The signing hook
92
keeps stdout empty, checks the CLI summary, and reports signer failures on stderr. Set
93
`PROTECT_MCP_POLICY`, `PROTECT_MCP_RECEIPTS`, and `PROTECT_MCP_KEY` to change the
94
default paths. When `PROTECT_MCP_POLICY` is unset and `./protect.cedar` is missing, the
95
PreToolUse hook prints a warning to stderr and allows the call. When
96
`PROTECT_MCP_POLICY` names a file that does not exist, the hook denies the call.
97
98
### What each hook does
99
100
**PreToolUse** — Runs BEFORE the tool executes. Evaluates the tool call against
101
your Cedar policy file. If Cedar returns `deny`, the hook exits with code 2 and
102
Claude Code blocks the tool call entirely.
103
104
**PostToolUse** runs AFTER the tool completes. It signs a receipt that names
105
the tool and appends it to `./receipts/receipts.jsonl`. This hook does not
106
pass the tool input or output to the signer.
107
108
## Cedar Policy File
109
110
Create `./protect.cedar` at the project root:
111
112
```cedar
113
// Read-only tools: one rule can name several tools in `when`. Add WebFetch
114
// with your own URL rule.
115
permit (principal, action == Action::"MCP::Tool::call", resource) when {
116
resource == Tool::"Read" || resource == Tool::"Glob" || resource == Tool::"Grep"
117
};
118
119
// Safe commands only; git limited to read subcommands
120
permit (principal, action == Action::"MCP::Tool::call", resource == Tool::"Bash") when {
121
context has input && context.input has command &&
122
(context.input.command like "git status*" || context.input.command like "git diff*" ||
123
context.input.command like "git log*" || context.input.command like "git show*" ||
124
context.input.command like "npm*" || context.input.command like "ls*" ||
125
context.input.command like "cat*" || context.input.command like "echo*" ||
126
context.input.command like "pwd*" || context.input.command like "test*")
127
};
128
129
// No chaining (`&` also denies `2>&1`), `$` expansion, redirection (`>` or
130
// `<`, which covers `<(`), file output (`git diff --output`), or rm -rf
131
forbid (principal, action == Action::"MCP::Tool::call", resource == Tool::"Bash") when {
132
context has input && context.input has command &&
133
(context.input.command like "*;*" || context.input.command like "*&*" ||
134
context.input.command like "*|*" || context.input.command like "*$*" ||
135
context.input.command like "*`*" || context.input.command like "*>*" ||
136
context.input.command like "*<*" || context.input.command like "*\n*" ||
137
context.input.command like "*--output*" || context.input.command like "*rm -rf*")
138
};
139
140
// Writes only inside the project (paths are absolute), never via `..`
141
permit (principal, action == Action::"MCP::Tool::call", resource) when {
142
(resource == Tool::"Write" || resource == Tool::"Edit") &&
143
context has input && context.input has file_path &&
144
context.input.file_path like "/path/to/project/*"
145
};
146
forbid (principal, action == Action::"MCP::Tool::call", resource) when {
147
(resource == Tool::"Write" || resource == Tool::"Edit") &&
148
context has input && context.input has file_path &&
149
(context.input.file_path like "*/../*" || context.input.file_path like "*/..")
150
};
151
```
152
153
String matching is best-effort: `like` checks the raw string, not a
154
resolved path, and an `npm*` permit runs arbitrary code, so it is only as
155
safe as the project's scripts.
156
157
## Verification
158
159
Verify every receipt against the public key in `./protect-mcp.key`:
160
161
```bash
162
PUB=$(node -p 'JSON.parse(require("fs").readFileSync("./protect-mcp.key")).publicKey')
163
npx @veritasacta/verify@0.11.1 --replay-chain ./receipts/receipts.jsonl --key "$PUB"
164
# Exit 0 = every receipt verified
165
# Exit 1 = a receipt failed (tampered, wrong key, or malformed line)
166
# Exit 2 = the file could not be read
167
```
168
169
The plugin's slash commands do the same inside Claude Code. `/verify-receipt`
170
takes one receipt in its own file, e.g., from
171
`tail -n 1 ./receipts/receipts.jsonl > receipt.json`.
172
173
```
174
/verify-receipt receipt.json
175
/audit-chain --last 20
176
```
177
178
## Receipt Format
179
180
Each receipt is one line of `./receipts/receipts.jsonl`. See
181
[`references/receipt-format.md`](references/receipt-format.md) for a sample.
182
183
- **Ed25519** signatures (RFC 8032) over the canonical `payload`
184
- **JCS canonicalization** (RFC 8785) before signing
185
- **Signed public key** in the payload; supply a trusted key with `--key`
186
- **Hash link** to the previous receipt, checked during replay
187
188
The verifier detects broken links between surviving receipts, including
189
interior deletion or reordering. A truncated tail and deletion or reordering
190
within the legacy portion of a mixed log can go undetected. Editing signed
191
contents still fails signature verification. Keep an externally retained
192
checkpoint or copy to check completeness.
193
194
## Why This Matters
195
196
| Before | After |
197
|--------|-------|
198
| "Trust me, the agent only read files" | Cryptographically provable: every Read logged and signed |
199
| "The log shows it happened" | The receipt proves it happened, and no one can edit it |
200
| "You'd have to audit our system" | Anyone can verify every receipt offline |
201
| "Logs might be different by now" | Ed25519 signatures lock the record at signing time |
202
203
## Standards
204
205
- **Ed25519** — RFC 8032 (digital signatures)
206
- **JCS** — RFC 8785 (deterministic JSON canonicalization)
207
- **Cedar** — AWS's open authorization policy language
208
- **IETF draft** — [draft-farley-acta-signed-receipts](https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/)
209
210
## Related
211
212
- **npm**: [protect-mcp](https://www.npmjs.com/package/protect-mcp)
213
- **Verify CLI**: [@veritasacta/verify](https://www.npmjs.com/package/@veritasacta/verify)
214
- **Source**: [github.com/ScopeBlind/scopeblind-gateway](https://github.com/ScopeBlind/scopeblind-gateway)
215
- **Protocol**: [veritasacta.com](https://veritasacta.com)
216
- **Integrations**: Microsoft Agent Governance Toolkit (PR #667), AWS cedar-policy/cedar-for-agents (PR #64)
217

© Tom Farley · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 13,358 prompts

More by @OpenSourceBuffGuy

See all
Woman with towel turban cooking chicken in night kitchen prompt image

Woman with towel turban cooking chicken in night kitchen

Generates a realistic handheld camcorder-style vlog of a fitness influencer cooking a high-protein meal late at night, mixing selfie shots and jump-cut fixed angles.

video-prompt, wan, vlog, handheld, home-video, cooking, food-photography, nutrition, fitness, night-scene, cozy, soft-lighting, photorealistic, multi-shot, pov, ugc-video, short-form-video, camera-movement, casual, for-content-creators, long-form, guardrails, reference-image, candid

Cute 3D animals introduced one by one in meadow prompt image

Cute 3D animals introduced one by one in meadow

Generates a 50-second vertical 3D cartoon where eight friendly animals appear one by one in a meadow with a big word label above each.

video-prompt, seedance, animals, animation, 3d-render, cartoon, pixar-style, family-friendly, for-young-learners, early-years-education, education, vertical-format, text-rendering, multi-shot, scene-transitions, vibrant-colors, camera-movement, forest, whimsical, explainer-video, vocabulary, storybook, long-form

Heartbroken man kneels in rain as woman turns away prompt image

Heartbroken man kneels in rain as woman turns away

Draws a cinematic heartbreak scene of a man kneeling in a storm as a woman sits turned away, with symbolic keepsakes and split cool and warm lighting.

image-prompt, gemini, photorealistic, cinematic, rain, dramatic-lighting, poster, widescreen, moody, couple, man, woman, cityscape, night-scene, multi-panel, low-angle, still-life, romance, album-cover, for-artists, long-form, structured-output, negative-space, flowers

Reviews

Loading reviews…

Discussion

Loading comments…