@agenttrust-sdk/mcp 0.2.5 → 0.3.0

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.
Files changed (51) hide show
  1. package/dist/embedded-docs/architecture.mdx +174 -0
  2. package/dist/embedded-docs/getting-started/quickstart.mdx +79 -56
  3. package/dist/embedded-docs/index.mdx +54 -37
  4. package/dist/embedded-docs/integration-guides/capability-namespaces.mdx +135 -8
  5. package/dist/embedded-docs/integration-guides/custom-attestor.mdx +169 -8
  6. package/dist/embedded-docs/integration-guides/dexter-adapter.mdx +76 -0
  7. package/dist/embedded-docs/integration-guides/facilitator-adapters.mdx +85 -41
  8. package/dist/embedded-docs/integration-guides/pay-sh-adapter.mdx +90 -54
  9. package/dist/embedded-docs/integration-guides/x402-facilitator.mdx +55 -24
  10. package/dist/embedded-docs/mcp/hosted-endpoint.mdx +197 -0
  11. package/dist/embedded-docs/mcp/index.mdx +108 -0
  12. package/dist/embedded-docs/mcp/install.mdx +183 -0
  13. package/dist/embedded-docs/mcp/prompts.mdx +90 -0
  14. package/dist/embedded-docs/mcp/resources.mdx +115 -0
  15. package/dist/embedded-docs/mcp/tools.mdx +156 -0
  16. package/dist/embedded-docs/programs/policy-vault/composer.mdx +117 -0
  17. package/dist/embedded-docs/programs/policy-vault/counterparty-tier-policy.mdx +81 -9
  18. package/dist/embedded-docs/programs/policy-vault/index.mdx +77 -47
  19. package/dist/embedded-docs/programs/policy-vault/kill-switch-policy.mdx +65 -8
  20. package/dist/embedded-docs/programs/policy-vault/require-validation-policy.mdx +76 -8
  21. package/dist/embedded-docs/programs/policy-vault/spending-policy.mdx +83 -8
  22. package/dist/embedded-docs/programs/policy-vault/velocity-policy.mdx +85 -8
  23. package/dist/embedded-docs/programs/trustgate.mdx +112 -30
  24. package/dist/embedded-docs/programs/validation-registry.mdx +139 -32
  25. package/dist/embedded-docs/reference/byte-offset-reference.mdx +102 -13
  26. package/dist/embedded-docs/reference/capability-namespaces.mdx +56 -0
  27. package/dist/embedded-docs/reference/changelog.mdx +230 -13
  28. package/dist/embedded-docs/reference/deny-reason-codes.mdx +86 -0
  29. package/dist/embedded-docs/reference/devnet-program-ids.mdx +50 -8
  30. package/dist/embedded-docs/reference/discriminator-constants.mdx +104 -10
  31. package/dist/embedded-docs/reference/mainnet-program-ids.mdx +89 -5
  32. package/dist/embedded-docs/reference/quantu-agent-registry.mdx +104 -9
  33. package/dist/embedded-docs/sdk/exports-reference.mdx +239 -0
  34. package/dist/embedded-docs/sdk/gate-payment.mdx +99 -14
  35. package/dist/embedded-docs/sdk/index.mdx +141 -40
  36. package/dist/embedded-docs/sdk/mount-trustgate.mdx +178 -8
  37. package/dist/embedded-docs/verification/adversarial-harness.mdx +88 -0
  38. package/dist/embedded-docs/verification/atomic-tx-invariant.mdx +141 -0
  39. package/dist/embedded-docs/verification/chained-validation.mdx +87 -0
  40. package/dist/embedded-docs/verification/devnet-smoke.mdx +85 -0
  41. package/dist/embedded-docs/verification/index.mdx +31 -0
  42. package/dist/embedded-docs/verification/kani-proofs.mdx +144 -0
  43. package/dist/embedded-docs/verification/live-evidence.mdx +180 -0
  44. package/dist/tools/read/get-quantu-reputation.d.ts +50 -11
  45. package/dist/tools/read/get-quantu-reputation.js +75 -26
  46. package/dist/tools/read/get-quantu-reputation.js.map +1 -1
  47. package/dist/tools/write/emit-feedback.d.ts +6 -0
  48. package/dist/tools/write/emit-feedback.js +12 -1
  49. package/dist/tools/write/emit-feedback.js.map +1 -1
  50. package/package.json +16 -15
  51. package/scripts/install-claude-desktop.sh +0 -0
@@ -1,39 +1,46 @@
1
1
  ---
2
- title: x402 facilitator
3
- description: Add AgentTrust decisions to an x402 facilitator without coupling to one vendor.
2
+ title: x402 facilitator (generic)
3
+ description: Add AgentTrust decisions to any x402 facilitator without coupling to one vendor.
4
4
  ---
5
5
 
6
- This guide is for a facilitator that already accepts x402 payment requests and wants AgentTrust decisions before settlement. If you are using Pay.sh, start with the [Pay.sh adapter guide](/integration-guides/pay-sh-adapter). If you are adding a new facilitator, start with the [adapter pattern](/integration-guides/facilitator-adapters).
6
+ If you already accept x402 payment requests and want AgentTrust decisions before settlement, this is the guide. Generic shape facilitator-specific quirks live in the adapter, not in the route layer.
7
+
8
+ If you're using Pay.sh, [start there](/integration-guides/pay-sh-adapter). If you're adding a new facilitator from scratch, [start with the adapter contract](/integration-guides/facilitator-adapters).
7
9
 
8
10
  ## Integration points
9
11
 
10
12
  | Step | Facilitator action | AgentTrust call |
11
- | --- | --- | --- |
13
+ |---|---|---|
12
14
  | 1 | receive x402 request or retry proof | `FacilitatorAdapter.parseRequest` |
13
- | 2 | translate into payer, payee, mint, amount, and policy ID | `VerifyContext` |
14
- | 3 | check policy | `gate_payment` or `gatePayment()` |
15
+ | 2 | translate into payer, payee, mint, amount, policy ID | `VerifyContext` |
16
+ | 3 | check policy | `gate_payment` simulation or [`gatePayment()`](/sdk/gate-payment) |
15
17
  | 4 | return x402 denial or validation need | `adapter.formatChallenge` |
16
- | 5 | settle payment | one signed transaction path |
18
+ | 5 | settle payment | one signed transaction (gate + transfer + feedback) |
17
19
  | 6 | emit feedback | `adapter.emitFeedback` |
18
20
 
19
21
  ## Minimal Express mount
20
22
 
23
+ The published SDK is the easy path:
24
+
21
25
  ```ts
22
26
  import express from "express";
27
+ import { Keypair } from "@solana/web3.js";
23
28
  import { mountTrustGate } from "@agenttrust-sdk/trustgate/express";
24
29
 
25
30
  const app = express();
26
31
  app.use(express.json());
27
32
 
28
33
  await mountTrustGate(app, {
29
- rpcUrl: process.env.SOLANA_RPC_URL!,
30
- facilitatorKeypair,
31
- defaultPolicyId: 1,
32
- network: "solana-devnet",
33
- atomicityEnforced: true,
34
+ rpcUrl: process.env.SOLANA_RPC_URL!,
35
+ facilitatorKeypair: Keypair.fromSecretKey(/* facilitator key */),
36
+ defaultPolicyId: 1,
37
+ network: "solana-devnet",
38
+ atomicityEnforced: true,
34
39
  });
35
40
  ```
36
41
 
42
+ Routes added: `POST /verify`, `POST /settle`, `POST /dispute`, `GET /receipt/:hash`. Full reference: [SDK → mountTrustGate](/sdk/mount-trustgate).
43
+
37
44
  ## Verify request shape
38
45
 
39
46
  ```http
@@ -41,39 +48,63 @@ POST /verify
41
48
  Content-Type: application/json
42
49
 
43
50
  {
44
- "payerAgentAsset": "payer-agent-asset-pubkey",
45
- "payeeAgentAsset": "payee-agent-asset-pubkey",
46
- "amount": "1000000",
47
- "mint": "mint-pubkey",
48
- "policyId": 1
51
+ "payerAgentAsset": "<base58 pubkey>",
52
+ "payeeAgentAsset": "<base58 pubkey>",
53
+ "amount": "1000000",
54
+ "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
55
+ "policyId": 1
49
56
  }
50
57
  ```
51
58
 
52
- For Pay.sh, the adapter reads this context from `paymentRequirements.extra.agentTrust`, verifies `serviceSignature`, derives `paymentIdHash` from `extra.memo`, and rejects mismatched `payTo` / `payeeRecipient` values.
59
+ For Pay.sh, the adapter reads this context from `paymentRequirements.extra.agentTrust`, verifies `serviceSignature`, derives `paymentIdHash` from `extra.memo`, and rejects mismatched `payTo` / `payeeRecipient`.
53
60
 
54
61
  ## Denial response
55
62
 
56
63
  ```http
57
64
  HTTP/1.1 402 Payment Required
58
- X-Payment-Network: solana-devnet
59
65
  X-Agent-Trust-Decision: Deny
60
66
  X-Payment-Required: denied
61
67
  X-Payment-Reason-Code: 6
62
68
  X-Payment-Reason-Name: CounterpartyTierBelowMin
69
+ X-Payment-Network: solana-devnet
63
70
  ```
64
71
 
72
+ Reason codes are stable: 1..15. Full table: [Reference → DenyReason codes](/reference/deny-reason-codes).
73
+
65
74
  ## Validation response
66
75
 
67
76
  ```http
68
77
  HTTP/1.1 402 Payment Required
69
- X-Payment-Network: solana-devnet
70
78
  X-Agent-Trust-Decision: RequireValidation
71
79
  X-Payment-Required: validation
72
- X-Capability-Required: <32-byte-capability-hash>
80
+ X-Capability-Required: 366c075140aa69746625d4b733b55e267fc5c28387fd6d1c24901976ee3ddc42
81
+ X-Payment-Network: solana-devnet
73
82
  ```
74
83
 
75
- ## Settlement rule
84
+ The `X-Capability-Required` value is the 32-byte SHA-256 hash of the capability namespace name (e.g., `kyc.tier-1.v1`). Full lifecycle: [Capability namespaces](/integration-guides/capability-namespaces).
76
85
 
77
- The facilitator must keep the policy gate, token transfer, and feedback emission in one signed Solana path once the settlement builder is wired. The SDK makes that requirement explicit with `atomicityEnforced: true`.
86
+ ## Settlement rule
78
87
 
79
- Source: `trustgate/server/src/facilitators`, `trustgate/server/src/x402.ts`, `trustgate/sdk/src/express.ts`.
88
+ The facilitator must keep the policy gate, token transfer, and feedback emission in **one** signed Solana transaction. The SDK enforces this via the `atomicityEnforced: true` literal-type guard. Splitting them silently corrupts `VelocityLedger` when a Token-2022 mint's `TransferHook` extension reverts the transfer. Full proof: [Verification → Atomic-tx invariant](/verification/atomic-tx-invariant).
89
+
90
+ ## Sources
91
+
92
+ | File | Purpose |
93
+ |---|---|
94
+ | [`trustgate/server/src/x402.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/trustgate/server/src/x402.ts) | x402 wire envelope helpers |
95
+ | [`trustgate/sdk/src/express.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/trustgate/sdk/src/express.ts) | Published Express middleware |
96
+ | [`trustgate/server/src/facilitators/`](https://github.com/agenttrust-labs/agenttrust/tree/main/trustgate/server/src/facilitators) | Per-facilitator adapter implementations |
97
+
98
+ ## Read next
99
+
100
+ <Cards>
101
+ <Card title="Pay.sh adapter" href="/integration-guides/pay-sh-adapter">
102
+ The canonical implementation, end to end.
103
+ </Card>
104
+ <Card title="Facilitator adapters" href="/integration-guides/facilitator-adapters">
105
+ Five-method contract for new facilitators.
106
+ </Card>
107
+ <Card title="DenyReason codes" href="/reference/deny-reason-codes">
108
+ Complete table of reason codes 1..15 with remediation hints.
109
+ </Card>
110
+ </Cards>
@@ -0,0 +1,197 @@
1
+ ---
2
+ title: Hosted HTTP endpoint
3
+ description: The streamable-HTTP MCP transport at mcp.agenttrust.tech — semantics, healthz, session model, retry behaviour.
4
+ ---
5
+
6
+ [`mcp.agenttrust.tech`](https://mcp.agenttrust.tech) is the hosted MCP HTTP endpoint. Always-on, devnet-bound, free to hit, no install required for clients that speak `StreamableHTTPServerTransport`.
7
+
8
+ Hosted on Fly.io (Singapore region), `shared-cpu-1x@256MB`, two machines for HA, `min_machines_running = 1` so judges hitting the URL don't see a cold start. Source: [`mcp/`](https://github.com/agenttrust-labs/agenttrust/tree/main/mcp). Deployed via `flyctl deploy --config mcp/fly.toml`.
9
+
10
+ ## Healthz
11
+
12
+ ```bash
13
+ curl https://mcp.agenttrust.tech/healthz
14
+ ```
15
+
16
+ Returns:
17
+
18
+ ```json
19
+ {
20
+ "ok": true,
21
+ "service": "agenttrust-mcp",
22
+ "version": "0.2.6",
23
+ "network": "solana-devnet",
24
+ "rpcUrl": "https://api.devnet.solana.com",
25
+ "uptimeSeconds": 60978,
26
+ "activeSessions": 0,
27
+ "toolCount": 18
28
+ }
29
+ ```
30
+
31
+ Health probes use this URL — Fly.io marks the machine healthy when it returns `ok: true`. Use it as a smoke check from CI.
32
+
33
+ ## Transport
34
+
35
+ The endpoint speaks Model Context Protocol over `StreamableHTTPServerTransport`. The wire format is JSON-RPC 2.0; the MCP server uses HTTP POST for client-initiated messages and Server-Sent Events for server-initiated messages.
36
+
37
+ ### Initialize
38
+
39
+ ```http
40
+ POST / HTTP/1.1
41
+ Host: mcp.agenttrust.tech
42
+ Content-Type: application/json
43
+
44
+ {
45
+ "jsonrpc": "2.0",
46
+ "id": 1,
47
+ "method": "initialize",
48
+ "params": {
49
+ "protocolVersion": "2025-03-26",
50
+ "capabilities": {},
51
+ "clientInfo": { "name": "my-client", "version": "0.1.0" }
52
+ }
53
+ }
54
+ ```
55
+
56
+ Response includes a `Mcp-Session-Id` header. Subsequent requests echo that header to bind the session.
57
+
58
+ ```http
59
+ HTTP/1.1 200 OK
60
+ Content-Type: application/json
61
+ Mcp-Session-Id: 9f3a…
62
+
63
+ {
64
+ "jsonrpc": "2.0",
65
+ "id": 1,
66
+ "result": {
67
+ "protocolVersion": "2025-03-26",
68
+ "capabilities": { "tools": {}, "resources": {}, "prompts": {} },
69
+ "serverInfo": { "name": "agenttrust", "version": "0.2.6" }
70
+ }
71
+ }
72
+ ```
73
+
74
+ ### Tools / call
75
+
76
+ ```http
77
+ POST / HTTP/1.1
78
+ Host: mcp.agenttrust.tech
79
+ Content-Type: application/json
80
+ Mcp-Session-Id: 9f3a…
81
+
82
+ {
83
+ "jsonrpc": "2.0",
84
+ "id": 2,
85
+ "method": "tools/call",
86
+ "params": {
87
+ "name": "agenttrust_simulate_payment",
88
+ "arguments": {
89
+ "caller": "4tSEHc2vCLqnYd8nK9jRa44vnn8JnPxUgxheEmhWQhRG",
90
+ "payer_agent": "5PfaofvEUf3adtJwMho7zzbfvgxwxbvp2V5moqhtLK8y",
91
+ "payee_agent": "5PfaofvEUf3adtJwMho7zzbfvgxwxbvp2V5moqhtLK8y",
92
+ "amount": "1000000",
93
+ "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
94
+ "policy_id": 1
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ Response (truncated):
101
+
102
+ ```json
103
+ {
104
+ "jsonrpc": "2.0",
105
+ "id": 2,
106
+ "result": {
107
+ "content": [
108
+ {
109
+ "type": "text",
110
+ "text": "{ \"kind\": \"Allow\" }"
111
+ }
112
+ ]
113
+ }
114
+ }
115
+ ```
116
+
117
+ Same wire shape as the stdio transport. Same 18 tools, same Zod schemas, same response format.
118
+
119
+ ## Session model — current quirk
120
+
121
+ The hosted MCP wraps `StreamableHTTPServerTransport` in a singleton: one transport per Node process. The first connection establishes a session and is served normally; a second connection without `Mcp-Session-Id` (i.e., trying to start a parallel session) gets:
122
+
123
+ ```json
124
+ {
125
+ "jsonrpc": "2.0",
126
+ "id": <id>,
127
+ "error": { "code": -32600, "message": "Server already initialized" }
128
+ }
129
+ ```
130
+
131
+ Real MCP clients pass `Mcp-Session-Id` and reuse a session — this is mostly invisible during normal use. It surfaces as soon as a second client connects without coordinating session IDs.
132
+
133
+ Phase M flagged this as Bug #4. Fixing it requires restructuring the transport instantiation around a per-session map; tracked but not v1-blocking. Workaround: restart the Fly machine (`flyctl machines list --app agenttrust-mcp` → `flyctl machines restart …`) or wait for session timeout.
134
+
135
+ ## Auth
136
+
137
+ The hosted endpoint has no authentication for read tools. Write tools require a `KEYPAIR_B58` environment variable on the *server*; the hosted instance doesn't have one set, so write tools surface the standard `signer required` error.
138
+
139
+ For write-tool access from a hosted MCP context, run your own instance with your own keypair:
140
+
141
+ ```bash
142
+ flyctl deploy --config mcp/fly.toml --remote-only --app my-mcp \
143
+ --env RPC_URL=https://api.devnet.solana.com \
144
+ --env NETWORK=solana-devnet
145
+ flyctl secrets set KEYPAIR_B58=<base58-key> --app my-mcp
146
+ ```
147
+
148
+ ## RPC backend
149
+
150
+ The hosted MCP queries Solana via `https://api.devnet.solana.com` by default. For mainnet (when AgentTrust deploys there), set `RPC_URL` and `NETWORK=solana-mainnet` on the Fly app via `flyctl secrets set`.
151
+
152
+ For lower-latency setups, point at a private RPC (Helius, QuickNode, Triton):
153
+
154
+ ```bash
155
+ flyctl secrets set RPC_URL=https://devnet.helius-rpc.com/?api-key=… --app agenttrust-mcp
156
+ ```
157
+
158
+ ## CORS
159
+
160
+ The hosted endpoint accepts cross-origin requests from any origin (no auth, no cookies, public devnet data). The MCP wire format uses application/json POSTs which trigger preflight; the server returns the standard `Access-Control-Allow-*` headers.
161
+
162
+ ## Self-host
163
+
164
+ Run your own HTTP transport locally:
165
+
166
+ ```bash
167
+ MCP_TRANSPORT=http MCP_HTTP_PORT=8765 node ./mcp/dist/index.js
168
+ ```
169
+
170
+ Behind any reverse proxy (Caddy, nginx, Vercel, Fly.io) this surfaces as a public hosted endpoint. Same Zod schemas, same tool catalog. Caddyfile example:
171
+
172
+ ```
173
+ mcp.your-domain.tld {
174
+ reverse_proxy localhost:8765
175
+ }
176
+ ```
177
+
178
+ ## Validation
179
+
180
+ Phase M end-to-end test against the hosted endpoint:
181
+
182
+ | Check | Result |
183
+ |---|---|
184
+ | `GET /healthz` | 200, returns `version: "0.2.6"`, `toolCount: 18` |
185
+ | `POST /` initialize | 200, returns matching `serverInfo`, `Mcp-Session-Id` header set |
186
+ | `tools/list` | 18 tools, exact match with stdio |
187
+ | `tools/call agenttrust_simulate_payment` | `{ kind: "Allow" }` for the tier-3 demo agent |
188
+ | `tools/call agenttrust_get_policy` | matching PDA `975DgYCY…` between stdio and HTTP |
189
+
190
+ Full report: [`docs/proofs/phase-m-mcp-e2e.md`](https://github.com/agenttrust-labs/agenttrust/blob/main/docs/proofs/phase-m-mcp-e2e.md) §M2.
191
+
192
+ ## Source
193
+
194
+ - Server entry: [`mcp/src/index.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/mcp/src/index.ts)
195
+ - HTTP transport: [`mcp/src/server.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/mcp/src/server.ts)
196
+ - Fly config: [`mcp/fly.toml`](https://github.com/agenttrust-labs/agenttrust/blob/main/mcp/fly.toml)
197
+ - Dockerfile: [`mcp/Dockerfile`](https://github.com/agenttrust-labs/agenttrust/blob/main/mcp/Dockerfile)
@@ -0,0 +1,108 @@
1
+ ---
2
+ title: MCP server
3
+ description: Drop @agenttrust-sdk/mcp into Claude Desktop or Cursor and query the deployed AgentTrust programs in natural language. Eighteen tools, four resources, three prompts.
4
+ ---
5
+
6
+ `@agenttrust-sdk/mcp@0.2.6` is the Model Context Protocol server for AgentTrust. Stdio binary published on npm; hosted HTTP transport at [`mcp.agenttrust.tech`](https://mcp.agenttrust.tech). Eighteen tools split into ten read-only, five write (require a signing keypair), and three discovery / docs-search.
7
+
8
+ The MCP server is a thin façade over [`@agenttrust-sdk/trustgate`](/sdk). PDA derivation, IDL loading, and `gate_payment` simulation live in the SDK; the MCP server exposes them with stable Zod schemas to LLM clients.
9
+
10
+ Source: [`mcp/`](https://github.com/agenttrust-labs/agenttrust/tree/main/mcp). License: MIT.
11
+
12
+ ## What you get
13
+
14
+ | | Count | Where |
15
+ |---|---:|---|
16
+ | Tools | 18 | 10 read · 5 write · 3 discovery |
17
+ | Resources | 4 | devnet program manifest, docs corpus, demo source files |
18
+ | Prompts | 3 | `agenttrust_audit_payment`, `agenttrust_setup_agent`, `agenttrust_explain_failure` |
19
+ | Transports | 2 | stdio (default) · streamable HTTP |
20
+ | Networks | 2 | `solana-devnet` (default) · `solana-mainnet` (when deployed) |
21
+
22
+ ## Quick start — Claude Desktop
23
+
24
+ ```json
25
+ {
26
+ "mcpServers": {
27
+ "agenttrust": {
28
+ "command": "npx",
29
+ "args": ["-y", "@agenttrust-sdk/mcp"],
30
+ "env": {
31
+ "RPC_URL": "https://api.devnet.solana.com",
32
+ "NETWORK": "solana-devnet"
33
+ }
34
+ }
35
+ }
36
+ }
37
+ ```
38
+
39
+ Drop into `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows). Restart Claude Desktop. Eighteen tools become available in chat. Full setup including write-tool keypair, Cursor config, and HTTP transport: [Install](/mcp/install).
40
+
41
+ ## What it looks like in use
42
+
43
+ Once installed, ask Claude Desktop:
44
+
45
+ - *"What demo agents are available on AgentTrust?"* → `agenttrust_demo_state` returns three pre-warmed counterparties with asset pubkeys + Explorer URLs.
46
+ - *"Simulate a 5-USDC payment from the tier-3 demo agent to the tier-0 demo agent against policy 1. What does the gate decide?"* → `agenttrust_simulate_payment` returns `Deny / SpendingPerTxExceeded` with the decoded reason.
47
+ - *"Pull the policy for agent &lt;asset&gt; ID 1 and tell me the spending caps."* → `agenttrust_get_policy` returns the decoded `PolicyAccount` PDA — every spending cap, velocity threshold, counterparty tier requirement, and required capability hash.
48
+ - *"Why would a payment with reason code 6 fail, and how do I fix it?"* → `agenttrust_explain_decision` returns `CounterpartyTierBelowMin` with remediation hint.
49
+ - *"Search the AgentTrust docs for the validation registry data flow."* → `agenttrust_docs` returns ranked hits with excerpts.
50
+ - *"Walk me through adding a new x402 facilitator adapter."* → `agenttrust_facilitator_walkthrough` returns the canonical guide.
51
+
52
+ Phase P validated all 10 scenarios with a real LLM client (Claude `sonnet` via the official `claude` CLI) — 7/10 strict pass, 3 false negatives that the LLM recovered from via context-gathering. Full report: [`docs/proofs/phase-p-llm-routing.md`](https://github.com/agenttrust-labs/agenttrust/blob/main/docs/proofs/phase-p-llm-routing.md).
53
+
54
+ ## Hosted vs stdio
55
+
56
+ | Mode | When | Setup |
57
+ |---|---|---|
58
+ | **Stdio** (default) | Claude Desktop, Cursor, any local MCP client | `npx -y @agenttrust-sdk/mcp` — no install, no clone |
59
+ | **Hosted HTTP** | Cloud agents, OpenAI Agents SDK, any `StreamableHTTPServerTransport` client | `https://mcp.agenttrust.tech` — Fly.io, always-on, 0 cold starts |
60
+
61
+ Health check the hosted endpoint:
62
+
63
+ ```bash
64
+ curl https://mcp.agenttrust.tech/healthz
65
+ # → {"ok":true,"service":"agenttrust-mcp","version":"0.2.6","network":"solana-devnet","toolCount":18,…}
66
+ ```
67
+
68
+ Full hosted-endpoint reference: [Hosted endpoint](/mcp/hosted-endpoint).
69
+
70
+ ## Architecture
71
+
72
+ ```
73
+ mcp/src/
74
+ ├── index.ts — entry point + transport selector
75
+ ├── server.ts — MCP Server with tools/resources/prompts wired up
76
+ ├── config.ts — env parsing
77
+ ├── chain.ts — thin façade over @agenttrust-sdk/trustgate
78
+ ├── tools/
79
+ │ ├── read/ — 10 read tools
80
+ │ ├── write/ — 5 write tools
81
+ │ └── discovery/ — 3 discovery tools
82
+ ├── resources/
83
+ │ ├── docs.ts — MDX corpus indexer (path-traversal-safe)
84
+ │ └── programs.ts — devnet program manifest as JSON resource
85
+ └── prompts/
86
+ ├── audit-payment.ts
87
+ ├── setup-agent.ts
88
+ └── explain-failure.ts
89
+ ```
90
+
91
+ Chain logic — PDA derivation, IDL loading, `gate_payment` simulation — lives in `@agenttrust-sdk/trustgate`. The MCP server is a façade. If a helper is missing in the SDK, it lands in the SDK and re-exports through the MCP — never forks chain logic into `mcp/`.
92
+
93
+ ## Read next
94
+
95
+ <Cards>
96
+ <Card title="Install" href="/mcp/install">
97
+ Claude Desktop, Cursor, hosted HTTP, env vars, write-tool keypair.
98
+ </Card>
99
+ <Card title="Tools" href="/mcp/tools">
100
+ All 18 tools — 10 read, 5 write, 3 discovery — with input/output shape.
101
+ </Card>
102
+ <Card title="Resources" href="/mcp/resources">
103
+ Four MCP resource URIs — devnet program manifest, docs corpus mirror.
104
+ </Card>
105
+ <Card title="Prompts" href="/mcp/prompts">
106
+ Three guided workflows — audit a payment, set up an agent, explain a failure.
107
+ </Card>
108
+ </Cards>
@@ -0,0 +1,183 @@
1
+ ---
2
+ title: Install
3
+ description: Wire @agenttrust-sdk/mcp into Claude Desktop, Cursor, or any MCP-capable client — stdio or hosted HTTP.
4
+ ---
5
+
6
+ Three install paths: Claude Desktop (one command), Cursor, or any generic stdio MCP client. Plus the always-on hosted HTTP endpoint at [`mcp.agenttrust.tech`](https://mcp.agenttrust.tech) for cloud agents.
7
+
8
+ ## Claude Desktop (recommended)
9
+
10
+ Add to your config — `~/Library/Application Support/Claude/claude_desktop_config.json` on macOS, `%APPDATA%\Claude\claude_desktop_config.json` on Windows:
11
+
12
+ ```json
13
+ {
14
+ "mcpServers": {
15
+ "agenttrust": {
16
+ "command": "npx",
17
+ "args": ["-y", "@agenttrust-sdk/mcp"],
18
+ "env": {
19
+ "RPC_URL": "https://api.devnet.solana.com",
20
+ "NETWORK": "solana-devnet"
21
+ }
22
+ }
23
+ }
24
+ }
25
+ ```
26
+
27
+ Restart Claude Desktop. Eighteen tools are now available in chat. No clone, no local build.
28
+
29
+ ### Local clone (for development)
30
+
31
+ If you want to iterate on the MCP server's source, swap the `command`/`args`:
32
+
33
+ ```json
34
+ "command": "node",
35
+ "args": ["/absolute/path/to/agenttrust/mcp/dist/index.js"]
36
+ ```
37
+
38
+ Or run the helper that wires the local path automatically:
39
+
40
+ ```bash
41
+ mcp/scripts/install-claude-desktop.sh
42
+ ```
43
+
44
+ The script edits the Claude Desktop config in place. It backs up the prior config to `claude_desktop_config.json.bak.<timestamp>` so you can revert.
45
+
46
+ ## Cursor
47
+
48
+ Cursor's MCP config lives at `~/.cursor/mcp.json` (or per-workspace `.cursor/mcp.json`). Same shape as Claude Desktop:
49
+
50
+ ```json
51
+ {
52
+ "mcpServers": {
53
+ "agenttrust": {
54
+ "command": "npx",
55
+ "args": ["-y", "@agenttrust-sdk/mcp"]
56
+ }
57
+ }
58
+ }
59
+ ```
60
+
61
+ ## Generic stdio MCP client
62
+
63
+ The package ships a binary entry point. Once installed:
64
+
65
+ ```bash
66
+ pnpm add @agenttrust-sdk/mcp
67
+ node ./node_modules/@agenttrust-sdk/mcp/dist/index.js # stdio transport, default
68
+ ```
69
+
70
+ The server speaks MCP over stdin/stdout. Any compliant MCP client attaches by spawning this command.
71
+
72
+ ## Hosted HTTP endpoint
73
+
74
+ The public hosted MCP HTTP endpoint is **already live**:
75
+
76
+ ```
77
+ https://mcp.agenttrust.tech
78
+ ```
79
+
80
+ Health check:
81
+
82
+ ```bash
83
+ curl https://mcp.agenttrust.tech/healthz
84
+ # → {"ok":true,"service":"agenttrust-mcp","version":"0.2.6","network":"solana-devnet","toolCount":18,…}
85
+ ```
86
+
87
+ Hosted on Fly.io (Singapore region, shared-cpu-1x@256MB, always-on with auto-resume on idle). Use this URL in any MCP client that speaks `StreamableHTTPServerTransport` — no local install required. Full hosted-endpoint reference: [Hosted endpoint](/mcp/hosted-endpoint).
88
+
89
+ To run your own HTTP transport locally:
90
+
91
+ ```bash
92
+ MCP_TRANSPORT=http MCP_HTTP_PORT=8765 node ./mcp/dist/index.js
93
+ ```
94
+
95
+ Behind any reverse proxy (Caddy, nginx, Vercel, Fly.io) this surfaces as a public hosted endpoint.
96
+
97
+ ## Write tools — adding a keypair
98
+
99
+ The five write tools (`agenttrust_init_policy`, `agenttrust_set_killswitch`, `agenttrust_request_validation`, `agenttrust_respond_to_validation`, `agenttrust_emit_feedback`) require a signing keypair. Add `KEYPAIR_B58` to the `env` block:
100
+
101
+ ```json
102
+ {
103
+ "mcpServers": {
104
+ "agenttrust": {
105
+ "command": "npx",
106
+ "args": ["-y", "@agenttrust-sdk/mcp"],
107
+ "env": {
108
+ "RPC_URL": "https://api.devnet.solana.com",
109
+ "NETWORK": "solana-devnet",
110
+ "KEYPAIR_B58": "<base58-encoded 64-byte secret key>"
111
+ }
112
+ }
113
+ }
114
+ }
115
+ ```
116
+
117
+ Without `KEYPAIR_B58`, write tools surface a clear `signer required` error. Read and discovery tools never need it.
118
+
119
+ Convert a Solana CLI keypair to base58:
120
+
121
+ ```bash
122
+ solana-keygen recover --output-format json -k ~/.config/solana/id.json | jq -r '.privateKey' \
123
+ | python3 -c "import sys, base58, json; print(base58.b58encode(bytes(json.loads(sys.stdin.read()))).decode())"
124
+ ```
125
+
126
+ Or use the `bs58` CLI:
127
+
128
+ ```bash
129
+ cat ~/.config/solana/id.json | jq -r '.[0:64]' | npx bs58 encode
130
+ ```
131
+
132
+ ## Environment variables
133
+
134
+ | Var | Default | Effect |
135
+ |---|---|---|
136
+ | `RPC_URL` | devnet RPC | Solana RPC endpoint |
137
+ | `NETWORK` | `solana-devnet` | `solana-devnet` or `solana-mainnet`. Drives Quantu program IDs. |
138
+ | `KEYPAIR_B58` | unset | Base58-encoded 64-byte secret key. Required for write tools. |
139
+ | `MCP_TRANSPORT` | `stdio` | `stdio` or `http` |
140
+ | `MCP_HTTP_PORT` | `8765` | Port for HTTP transport |
141
+ | `POLICY_VAULT_PROGRAM_ID` | devnet ID | Override `policy_vault` program ID |
142
+ | `TRUSTGATE_PROGRAM_ID` | devnet ID | Override `trustgate` program ID |
143
+ | `VALIDATION_REGISTRY_PROGRAM_ID` | devnet ID | Override `validation_registry` program ID |
144
+ | `MCP_DEFAULT_FACILITATOR` | unset | Default facilitator name in tool replies |
145
+ | `MCP_DOCS_DIR` | repo `docs-site/content/docs` | Override the docs corpus root (tests) |
146
+ | `PAY_SH_DEMO_STATE_FILE` | bundled demo state | Override the demo state file |
147
+
148
+ ## Build + test from source
149
+
150
+ ```bash
151
+ git clone https://github.com/agenttrust-labs/agenttrust && cd agenttrust
152
+ pnpm install
153
+ pnpm --filter ./trustgate/sdk run build # MCP depends on the SDK build output
154
+ pnpm --filter ./mcp run build
155
+ pnpm --filter ./mcp test # 76 unit tests, no chain access
156
+ INTEGRATION=1 pnpm --filter ./mcp test:integration # devnet round-trip
157
+ ```
158
+
159
+ ## IDL fetch (verify on-chain truth)
160
+
161
+ All three Anchor IDLs are published on devnet:
162
+
163
+ ```bash
164
+ anchor idl fetch 8Y6fGeNEHgmWmbt8JsRcF72jxbeBfJhomMjG6SuoJQTR --provider.cluster devnet # policy_vault
165
+ anchor idl fetch HF8zHfoyA7b5mhLViopTnRMprc6ZT5KActHTdkFrih2N --provider.cluster devnet # trustgate
166
+ anchor idl fetch Cx4RFa6ysw3qXYhugPkF8pFSWBkmKq59h2dWgF2tKhtv --provider.cluster devnet # validation_registry
167
+ ```
168
+
169
+ The MCP server bundles snapshots at `mcp/src/idl/*.json` as a defensive fallback (saves an RPC round-trip on cold start; keeps the server bootable in offline / air-gapped harnesses). Latest evidence snapshot: [`docs/proofs/idl-on-chain.json`](https://github.com/agenttrust-labs/agenttrust/blob/main/docs/proofs/idl-on-chain.json).
170
+
171
+ ## Read next
172
+
173
+ <Cards>
174
+ <Card title="Tools" href="/mcp/tools">
175
+ Eighteen tools with input/output shape.
176
+ </Card>
177
+ <Card title="Hosted endpoint" href="/mcp/hosted-endpoint">
178
+ HTTP transport semantics, sessions, healthz schema.
179
+ </Card>
180
+ <Card title="Prompts" href="/mcp/prompts">
181
+ Three guided workflows for LLM clients.
182
+ </Card>
183
+ </Cards>