@haven_ai/mcp 0.0.0-dev.202609031523.fd49e1a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,197 @@
1
+ # Haven MCP server
2
+
3
+ `@haven_ai/mcp` exposes Haven payment primitives as local MCP tools. It is a
4
+ thin wrapper around `@haven_ai/sdk`.
5
+
6
+ For Codex CLI and Claude Code setup, the Haven app leads with this local stdio
7
+ server so a normal restart can load Haven tools without shell environment
8
+ setup. Hosted MCP plus a separate local edge signer remains a fallback shape for
9
+ other runtimes.
10
+
11
+ The server is intentionally local-only:
12
+
13
+ - It runs in the agent operator's environment, usually as a stdio subprocess.
14
+ - It reads `api_key` and `delegate_key` from a local credential file.
15
+ - It signs locally with the delegate key.
16
+ - Haven's backend receives API identity plus signed payloads. It never receives
17
+ the delegate key.
18
+
19
+ ## Credential file
20
+
21
+ Create a private JSON file from the values in the Haven agent handoff:
22
+
23
+ ```json
24
+ {
25
+ "api_key": "sk_agent_...",
26
+ "delegate_key": "0x...",
27
+ "agent_id": "agent-id",
28
+ "safe_address": "0xYourHavenWallet",
29
+ "api_url": "https://havenbackend.example"
30
+ }
31
+ ```
32
+
33
+ `delegate_key` is required. Without it the MCP server cannot sign locally.
34
+
35
+ The Haven connector may also write split credentials:
36
+
37
+ ```sh
38
+ npx @haven_ai/mcp@alpha --identity ~/.haven/agents/<agent-id>/identity.json --signer ~/.haven/agents/<agent-id>/signer.json
39
+ ```
40
+
41
+ `identity.json` holds the local API key and setup metadata. `signer.json` holds
42
+ the delegate key. Both files stay on the user's machine.
43
+
44
+ ### Credential file permissions
45
+
46
+ The credential file contains a private key. Restrict it to your user
47
+ immediately after downloading:
48
+
49
+ - macOS / Linux: `chmod 600 /path/to/haven-agent.json`
50
+ - Windows (PowerShell): `icacls "path\to\haven-agent.json" /inheritance:r /grant:r "$env:UserName:R"`
51
+
52
+ On POSIX systems the MCP server checks the file's mode bits at load time and
53
+ prints a warning to stderr if it's readable beyond the owner (e.g. world-
54
+ or group-readable). It does not refuse to start — some controlled
55
+ deployments intentionally widen access — but unattended warnings are a
56
+ strong signal something needs tightening. Avoid storing credentials in
57
+ cloud-synced folders (iCloud, Dropbox, OneDrive) or shared dotfile
58
+ repositories.
59
+
60
+ ## Claude Desktop
61
+
62
+ ```json
63
+ {
64
+ "mcpServers": {
65
+ "haven": {
66
+ "command": "npx",
67
+ "args": ["@haven_ai/mcp", "--credentials", "/absolute/path/to/haven-agent.json"]
68
+ }
69
+ }
70
+ }
71
+ ```
72
+
73
+ Environment variable form:
74
+
75
+ ```json
76
+ {
77
+ "mcpServers": {
78
+ "haven": {
79
+ "command": "npx",
80
+ "args": ["@haven_ai/mcp"],
81
+ "env": {
82
+ "HAVEN_CREDENTIALS": "/absolute/path/to/haven-agent.json"
83
+ }
84
+ }
85
+ }
86
+ }
87
+ ```
88
+
89
+ ## Tools
90
+
91
+ - `haven_quote_x402`
92
+ - `haven_pay_x402_quote`
93
+ - `haven_resume_x402_payment`
94
+ - `haven_get_payment_status`
95
+ - `haven_get_resume_state`
96
+ - `haven_get_agent`
97
+ - `haven_get_allowances`
98
+ - `haven_discover_tools`
99
+ - `haven_submit_catalog_entry`
100
+ - `haven_list_receipts`
101
+
102
+ ## First-launch consent
103
+
104
+ The first time the MCP server runs against a credential file it refuses to
105
+ start until you've acknowledged what tools it exposes and what the agent can
106
+ actually spend.
107
+
108
+ On first launch you'll see something like this on stderr:
109
+
110
+ ```
111
+ Haven MCP server — first-launch consent
112
+ ────────────────────────────────────────────────────────────
113
+ Credential: sk_agent_ab…
114
+
115
+ Tools this server will expose to your agent runtime:
116
+ • haven_pay_x402_quote
117
+ Pay a previously inspected x402 quote …
118
+ • haven_get_allowances
119
+ Return configured and on-chain allowance state …
120
+
121
+
122
+ On-chain budget (the real spend gate — enforced by the agent's
123
+ signed delegation, not by Haven):
124
+ • up to 50.000000 USDC per 1440 min
125
+
126
+ Anything above the on-chain budget is declined before any money
127
+ moves — it is not queued, and no one is asked to review it. If the
128
+ agent needs more room, the wallet owner grants or raises the budget
129
+ in Haven. Revoking the agent on-chain disables every MCP tool that
130
+ would spend.
131
+
132
+ Consent hash: 6f4b…d1a2
133
+ ```
134
+
135
+ Acknowledge in one of two ways:
136
+
137
+ - **Sidecar file (recommended).** Re-run once with `--ack`:
138
+
139
+ ```sh
140
+ npx @haven_ai/mcp@alpha --credentials /absolute/path/to/haven-agent.json --ack
141
+ ```
142
+
143
+ This writes `haven-agent.json.ack.json` next to your credential. Future
144
+ launches pick it up automatically. When the tool set or your on-chain
145
+ allowance changes, the hash changes and you'll be re-prompted.
146
+ For split credentials, the sidecar is written next to `identity.json`.
147
+
148
+ - **Environment variable.** Copy the printed hash and set
149
+ `HAVEN_MCP_ACK=<hash>` in the MCP client's `env` block. Useful for
150
+ Claude Desktop configs that prefer environment over filesystem state.
151
+
152
+ For CI or scripted setups, `HAVEN_MCP_ACK=skip` bypasses the gate entirely.
153
+ Do not set this for human-operated installs — the consent block is the only
154
+ place a wallet owner is shown the real on-chain allowance before tools go
155
+ live.
156
+
157
+ ## Audit log
158
+
159
+ Every MCP tool invocation tags the underlying Haven API call with
160
+ `X-Haven-MCP-Tool: <tool_name>`. The backend records one
161
+ `agent_tool_invocations` row per call (tool name, payment id when present,
162
+ result status, nextAction, error code, HTTP status, timestamp). The agent's
163
+ activity feed in the Haven dashboard surfaces these rows alongside payments,
164
+ so the wallet owner can see exactly which tools the
165
+ agent called and what happened — even for read-only calls that don't move
166
+ money.
167
+
168
+ The audit log is informational. The agent's signed budget delegation — its
169
+ on-chain caveat enforcers — remains the only thing that can stop a spend;
170
+ revoking the agent on-chain disables every MCP tool that would settle,
171
+ regardless of audit state.
172
+
173
+ ## Manual sanity test
174
+
175
+ 1. Start Claude Desktop or another MCP client with the config above.
176
+ 2. Call `haven_get_agent` and confirm it returns the expected Haven wallet and
177
+ delegate address.
178
+ 3. Call `haven_quote_x402` for a paid test URL.
179
+ 4. Call `haven_pay_x402_quote` with the returned quote.
180
+ 5. The pay tool performs the merchant retry itself, so a successful call needs
181
+ no follow-up. If the call is declined for budget, raise the agent budget in
182
+ Haven and repeat from step 4 — Haven holds no approval queue, so there is
183
+ nothing to wait for. If the process crashes after payment, a later
184
+ `haven_get_payment_status` call may report
185
+ `nextAction: 'retry_original_x402_request'` — only then call
186
+ `haven_resume_x402_payment` with the preserved resume state or payment id;
187
+ do not call it speculatively.
188
+
189
+ The legacy MPP demo flow is retired (#1328) — pay through the x402 merchant
190
+ flow above instead.
191
+
192
+ ## Non-custodial invariant
193
+
194
+ Do not run this as a hosted multi-tenant signer. The expected deployment is
195
+ `npx @haven_ai/mcp@alpha` running beside the agent runtime that owns the credential
196
+ file. Revoking the agent on-chain disables spending even if this MCP server is
197
+ still running.