@haven_ai/mcp 0.1.0-alpha

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,154 @@
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
+ The server is intentionally local-only:
7
+
8
+ - It runs in the agent operator's environment, usually as a stdio subprocess.
9
+ - It reads `api_key` and `delegate_key` from a local credential file.
10
+ - It signs locally with the delegate key.
11
+ - Haven's backend receives API identity plus signed payloads. It never receives
12
+ the delegate key.
13
+
14
+ ## Credential file
15
+
16
+ Create a private JSON file from the values in the Haven agent handoff:
17
+
18
+ ```json
19
+ {
20
+ "api_key": "sk_agent_...",
21
+ "delegate_key": "0x...",
22
+ "agent_id": "agent-id",
23
+ "safe_address": "0xYourHavenWallet",
24
+ "api_url": "https://havenbackend.example"
25
+ }
26
+ ```
27
+
28
+ `delegate_key` is required. Without it the MCP server cannot sign locally.
29
+
30
+ ## Claude Desktop
31
+
32
+ ```json
33
+ {
34
+ "mcpServers": {
35
+ "haven": {
36
+ "command": "npx",
37
+ "args": ["@haven_ai/mcp", "--credentials", "/absolute/path/to/haven-agent.json"]
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ Environment variable form:
44
+
45
+ ```json
46
+ {
47
+ "mcpServers": {
48
+ "haven": {
49
+ "command": "npx",
50
+ "args": ["@haven_ai/mcp"],
51
+ "env": {
52
+ "HAVEN_CREDENTIALS": "/absolute/path/to/haven-agent.json"
53
+ }
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ ## Tools
60
+
61
+ - `haven_quote_x402`
62
+ - `haven_pay_x402_quote`
63
+ - `haven_resume_x402_payment`
64
+ - `haven_quote_mpp`
65
+ - `haven_pay_mpp_challenge`
66
+ - `haven_resume_mpp_payment`
67
+ - `haven_get_payment_status`
68
+ - `haven_get_resume_state`
69
+ - `haven_get_agent`
70
+ - `haven_get_allowances`
71
+ - `haven_list_receipts`
72
+
73
+ ## First-launch consent
74
+
75
+ The first time the MCP server runs against a credential file it refuses to
76
+ start until you've acknowledged what tools it exposes and what the agent can
77
+ actually spend.
78
+
79
+ On first launch you'll see something like this on stderr:
80
+
81
+ ```
82
+ Haven MCP server — first-launch consent
83
+ ────────────────────────────────────────────────────────────
84
+ Credential: sk_agent_ab…
85
+
86
+ Tools this server will expose to your agent runtime:
87
+ • haven_pay_x402_quote
88
+ Pay a previously inspected x402 quote …
89
+ • haven_get_allowances
90
+ Return configured and on-chain allowance state …
91
+
92
+
93
+ On-chain allowance (the real spend gate, Safe AllowanceModule):
94
+ • up to 50.000000 USDC per 1440 min
95
+
96
+ Consent hash: 6f4b…d1a2
97
+ ```
98
+
99
+ Acknowledge in one of two ways:
100
+
101
+ - **Sidecar file (recommended).** Re-run once with `--ack`:
102
+
103
+ ```sh
104
+ npx @haven_ai/mcp --credentials /absolute/path/to/haven-agent.json --ack
105
+ ```
106
+
107
+ This writes `haven-agent.json.ack.json` next to your credential. Future
108
+ launches pick it up automatically. When the tool set or your on-chain
109
+ allowance changes, the hash changes and you'll be re-prompted.
110
+
111
+ - **Environment variable.** Copy the printed hash and set
112
+ `HAVEN_MCP_ACK=<hash>` in the MCP client's `env` block. Useful for
113
+ Claude Desktop configs that prefer environment over filesystem state.
114
+
115
+ For CI or scripted setups, `HAVEN_MCP_ACK=skip` bypasses the gate entirely.
116
+ Do not set this for human-operated installs — the consent block is the only
117
+ place a wallet owner is shown the real on-chain allowance before tools go
118
+ live.
119
+
120
+ ## Audit log
121
+
122
+ Every MCP tool invocation tags the underlying Haven API call with
123
+ `X-Haven-MCP-Tool: <tool_name>`. The backend records one
124
+ `agent_tool_invocations` row per call (tool name, payment id when present,
125
+ result status, nextAction, error code, HTTP status, timestamp). The agent's
126
+ activity feed in the Haven dashboard surfaces these rows alongside payments
127
+ and approval requests, so the wallet owner can see exactly which tools the
128
+ agent called and what happened — even for read-only calls that don't move
129
+ money.
130
+
131
+ The audit log is informational. The on-chain Safe AllowanceModule remains
132
+ the only thing that can stop a spend; revoking the agent on-chain disables
133
+ every MCP tool that would settle, regardless of audit state.
134
+
135
+ ## Manual sanity test
136
+
137
+ 1. Start Claude Desktop or another MCP client with the config above.
138
+ 2. Call `haven_get_agent` and confirm it returns the expected Haven wallet and
139
+ delegate address.
140
+ 3. Call `haven_quote_x402` for a paid test URL.
141
+ 4. Call `haven_pay_x402_quote` with the returned quote.
142
+ 5. If the result has `nextAction: "wait_for_user_approval"`, approve in Haven,
143
+ then call `haven_resume_x402_payment` with the returned `resume_state` or
144
+ `payment_id`.
145
+
146
+ The MPP flow is equivalent: `haven_quote_mpp`, `haven_pay_mpp_challenge`, then
147
+ `haven_resume_mpp_payment` after approval when needed.
148
+
149
+ ## Non-custodial invariant
150
+
151
+ Do not run this as a hosted multi-tenant signer. The expected deployment is
152
+ `npx @haven_ai/mcp` running beside the agent runtime that owns the credential
153
+ file. Revoking the agent on-chain disables spending even if this MCP server is
154
+ still running.