@agenttrust-sdk/mcp 0.2.6 → 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.
- package/dist/embedded-data/devnet-smoke.json +4 -4
- package/dist/embedded-docs/architecture.mdx +174 -0
- package/dist/embedded-docs/getting-started/quickstart.mdx +79 -56
- package/dist/embedded-docs/index.mdx +54 -37
- package/dist/embedded-docs/integration-guides/capability-namespaces.mdx +135 -8
- package/dist/embedded-docs/integration-guides/custom-attestor.mdx +169 -8
- package/dist/embedded-docs/integration-guides/dexter-adapter.mdx +76 -0
- package/dist/embedded-docs/integration-guides/facilitator-adapters.mdx +85 -41
- package/dist/embedded-docs/integration-guides/pay-sh-adapter.mdx +90 -54
- package/dist/embedded-docs/integration-guides/x402-facilitator.mdx +55 -24
- package/dist/embedded-docs/mcp/hosted-endpoint.mdx +197 -0
- package/dist/embedded-docs/mcp/index.mdx +108 -0
- package/dist/embedded-docs/mcp/install.mdx +183 -0
- package/dist/embedded-docs/mcp/prompts.mdx +90 -0
- package/dist/embedded-docs/mcp/resources.mdx +115 -0
- package/dist/embedded-docs/mcp/tools.mdx +156 -0
- package/dist/embedded-docs/programs/policy-vault/composer.mdx +117 -0
- package/dist/embedded-docs/programs/policy-vault/counterparty-tier-policy.mdx +81 -9
- package/dist/embedded-docs/programs/policy-vault/index.mdx +77 -47
- package/dist/embedded-docs/programs/policy-vault/kill-switch-policy.mdx +65 -8
- package/dist/embedded-docs/programs/policy-vault/require-validation-policy.mdx +76 -8
- package/dist/embedded-docs/programs/policy-vault/spending-policy.mdx +83 -8
- package/dist/embedded-docs/programs/policy-vault/velocity-policy.mdx +85 -8
- package/dist/embedded-docs/programs/trustgate.mdx +112 -30
- package/dist/embedded-docs/programs/validation-registry.mdx +139 -32
- package/dist/embedded-docs/reference/byte-offset-reference.mdx +102 -13
- package/dist/embedded-docs/reference/capability-namespaces.mdx +56 -0
- package/dist/embedded-docs/reference/changelog.mdx +230 -13
- package/dist/embedded-docs/reference/deny-reason-codes.mdx +86 -0
- package/dist/embedded-docs/reference/devnet-program-ids.mdx +50 -8
- package/dist/embedded-docs/reference/discriminator-constants.mdx +104 -10
- package/dist/embedded-docs/reference/mainnet-program-ids.mdx +89 -5
- package/dist/embedded-docs/reference/quantu-agent-registry.mdx +104 -9
- package/dist/embedded-docs/sdk/exports-reference.mdx +239 -0
- package/dist/embedded-docs/sdk/gate-payment.mdx +99 -14
- package/dist/embedded-docs/sdk/index.mdx +141 -40
- package/dist/embedded-docs/sdk/mount-trustgate.mdx +178 -8
- package/dist/embedded-docs/verification/adversarial-harness.mdx +88 -0
- package/dist/embedded-docs/verification/atomic-tx-invariant.mdx +141 -0
- package/dist/embedded-docs/verification/chained-validation.mdx +87 -0
- package/dist/embedded-docs/verification/devnet-smoke.mdx +85 -0
- package/dist/embedded-docs/verification/index.mdx +31 -0
- package/dist/embedded-docs/verification/kani-proofs.mdx +144 -0
- package/dist/embedded-docs/verification/live-evidence.mdx +180 -0
- package/dist/tools/write/emit-feedback.d.ts +6 -0
- package/dist/tools/write/emit-feedback.js +12 -1
- package/dist/tools/write/emit-feedback.js.map +1 -1
- package/package.json +16 -15
- package/scripts/install-claude-desktop.sh +0 -0
|
@@ -1,33 +1,52 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Pay.sh adapter
|
|
3
|
-
description:
|
|
3
|
+
description: Walk the live Pay.sh + AgentTrust integration end to end — challenge, retry, settle, feedback, with hosted-demo paths and the SERVICE-signed envelope contract.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Pay.sh is the first
|
|
7
|
-
|
|
8
|
-
Pay.sh launch reference: [Solana Foundation launch note](https://solana.com/news/solana-foundation-launches-pay-sh-in-collaboration-with-google-cloud).
|
|
6
|
+
Pay.sh is the Solana Foundation's first x402 facilitator, [launched 2026-05-05 with Google Cloud](https://solana.com/news/solana-foundation-launches-pay-sh-in-collaboration-with-google-cloud). AgentTrust ships day-one Pay.sh integration as the canonical `FacilitatorAdapter` implementation. Source: [`trustgate/server/src/facilitators/pay-sh/`](https://github.com/agenttrust-labs/agenttrust/tree/main/trustgate/server/src/facilitators/pay-sh).
|
|
9
7
|
|
|
10
8
|
## What the adapter does
|
|
11
9
|
|
|
12
|
-
| Stage | Pay.sh
|
|
13
|
-
|
|
10
|
+
| Stage | x402 / Pay.sh wire shape | AgentTrust action |
|
|
11
|
+
|---|---|---|
|
|
14
12
|
| Initial request | no payment proof | emit `402 Payment Required` with a base64 x402 v2 envelope |
|
|
15
|
-
| Challenge | `paymentRequirements.extra.agentTrust` | include payer agent, payee agent, payee recipient, policy ID, `issuedAt`,
|
|
16
|
-
| Retry | `PAYMENT-SIGNATURE` or `X-PAYMENT` | parse proof
|
|
17
|
-
| Policy | `VerifyContext` | run
|
|
13
|
+
| Challenge | `paymentRequirements.extra.agentTrust` | include payer agent, payee agent, payee recipient, policy ID, `issuedAt`, `serviceSignature` |
|
|
14
|
+
| Retry | `PAYMENT-SIGNATURE` or `X-PAYMENT` header | parse proof, rebuild `VerifyContext` |
|
|
15
|
+
| Policy | `VerifyContext` | run `gate_payment` decision |
|
|
18
16
|
| Allow | signed payment proof | validate transfer fields, emit feedback, forward resource |
|
|
19
|
-
| Deny | gate decision | return `402` with reason code
|
|
17
|
+
| Deny | gate decision | return `402` with reason code + reason name |
|
|
20
18
|
|
|
21
|
-
##
|
|
19
|
+
## Hit the live demo
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
[`demo.agenttrust.tech`](https://demo.agenttrust.tech) runs the full Pay.sh + AgentTrust pipeline against deployed devnet programs. With no payment proof:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
curl -i https://demo.agenttrust.tech/protected
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Returns `HTTP/2 402` with a SERVICE-signed `payment-required` envelope. With Pay.sh installed, let the CLI pay and retry:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pay --sandbox curl https://demo.agenttrust.tech/protected
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The demo seeds three deterministic counterparties. Drive each branch by passing the matching `X-Demo-Payer-Agent` header:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Allow path (tier 3)
|
|
37
|
+
PAYER=$(curl -s https://demo.agenttrust.tech/health | jq -r '.counterparties[2].agent')
|
|
38
|
+
pay --sandbox curl -H "X-Demo-Payer-Agent: $PAYER" https://demo.agenttrust.tech/protected
|
|
39
|
+
|
|
40
|
+
# Deny path (tier 0)
|
|
41
|
+
PAYER=$(curl -s https://demo.agenttrust.tech/health | jq -r '.counterparties[0].agent')
|
|
42
|
+
pay --sandbox curl -H "X-Demo-Payer-Agent: $PAYER" https://demo.agenttrust.tech/protected
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
| Counterparty tier | Decision |
|
|
46
|
+
|---:|---|
|
|
47
|
+
| 0 | `402 Deny — CounterpartyTierBelowMin` |
|
|
48
|
+
| 1 | `402 Deny — CounterpartyTierBelowMin` |
|
|
49
|
+
| 3 | `200 Allow + X-Payment-Receipt` |
|
|
31
50
|
|
|
32
51
|
## SERVICE-signed challenge
|
|
33
52
|
|
|
@@ -44,58 +63,49 @@ The SERVICE emits a signed challenge when it returns the Pay.sh `402` response.
|
|
|
44
63
|
- policy ID
|
|
45
64
|
- payment ID hash
|
|
46
65
|
|
|
47
|
-
`PaySh.parseRequest()` verifies that signature against the facilitator public key before
|
|
48
|
-
|
|
49
|
-
## Run the demo
|
|
66
|
+
`PaySh.parseRequest()` verifies that signature against the facilitator public key before accepting the request. This closes the race window where a forged `paymentRequirements` envelope could race a legitimate one.
|
|
50
67
|
|
|
51
|
-
|
|
52
|
-
pnpm --filter ./examples/pay-sh-demo dev
|
|
53
|
-
```
|
|
68
|
+
## Files to read in repo
|
|
54
69
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
| 0 | `402 Deny` with `CounterpartyTierBelowMin` |
|
|
64
|
-
| 1 | `402 Deny` with `CounterpartyTierBelowMin` |
|
|
65
|
-
| 3 | `200 Allow` with `X-Payment-Receipt` |
|
|
66
|
-
|
|
67
|
-
Get the exact payer agent keys:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
curl -s https://demo.agenttrust.tech/health | jq '.counterparties'
|
|
71
|
-
```
|
|
70
|
+
| File | Purpose |
|
|
71
|
+
|---|---|
|
|
72
|
+
| [`facilitators/pay-sh/index.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/trustgate/server/src/facilitators/pay-sh/index.ts) | The five-method `PaySh` class |
|
|
73
|
+
| [`facilitators/pay-sh/schemas.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/trustgate/server/src/facilitators/pay-sh/schemas.ts) | Strict Zod wire schemas |
|
|
74
|
+
| [`facilitators/pay-sh/sig.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/trustgate/server/src/facilitators/pay-sh/sig.ts) | SERVICE challenge signature helpers |
|
|
75
|
+
| [`facilitators/pay-sh/proof-validator.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/trustgate/server/src/facilitators/pay-sh/proof-validator.ts) | Replay, self-pay, amount, mint, recipient checks |
|
|
76
|
+
| [`facilitators/pay-sh/feedback.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/trustgate/server/src/facilitators/pay-sh/feedback.ts) | Idempotent feedback emission |
|
|
77
|
+
| [`examples/pay-sh-demo/src/middleware.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/examples/pay-sh-demo/src/middleware.ts) | Express bridge from Pay.sh retry to AgentTrust |
|
|
72
78
|
|
|
73
79
|
## Production wiring
|
|
74
80
|
|
|
75
|
-
The demo proves the pipeline without requiring devnet RPC in CI. The server package carries the real devnet
|
|
81
|
+
The demo proves the pipeline without requiring devnet RPC in CI. The server package carries the real devnet path: [`trustgate/server/src/chain.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/trustgate/server/src/chain.ts) loads deployed program IDLs, `/verify` simulates `gate_payment`, and `/settle` delegates proof validation plus feedback emission through the active adapter.
|
|
76
82
|
|
|
77
|
-
Production swaps three dependency seams:
|
|
83
|
+
Production swaps three dependency seams the demo stubs:
|
|
78
84
|
|
|
79
85
|
```ts
|
|
86
|
+
import { PaySh } from "./facilitators/pay-sh";
|
|
87
|
+
|
|
80
88
|
const adapter = new PaySh({
|
|
81
89
|
signingNetwork: "solana-devnet",
|
|
82
|
-
feePayer:
|
|
83
|
-
validateOnChainTx,
|
|
84
|
-
emitFeedbackCpi,
|
|
85
|
-
priorEmissionLookup,
|
|
86
|
-
replayCache,
|
|
87
|
-
signDecision,
|
|
90
|
+
feePayer: facilitator.publicKey,
|
|
91
|
+
validateOnChainTx, // makeValidateOnChainTx({ connection, … })
|
|
92
|
+
emitFeedbackCpi, // makeEmitFeedbackCpi({ connection, programIds, … })
|
|
93
|
+
priorEmissionLookup, // makePriorEmissionLookup({ connection, programId })
|
|
94
|
+
replayCache, // ReplayCache (in-memory by default)
|
|
95
|
+
signDecision, // signs canonical decision bytes with facilitator key
|
|
88
96
|
});
|
|
89
97
|
```
|
|
90
98
|
|
|
91
99
|
| Dependency | Production implementation |
|
|
92
|
-
|
|
100
|
+
|---|---|
|
|
93
101
|
| `validateOnChainTx` | parse the confirmed SPL transfer transaction from RPC |
|
|
94
102
|
| `emitFeedbackCpi` | build and send `trustgate::emit_feedback` through Anchor |
|
|
95
103
|
| `priorEmissionLookup` | read the `FeedbackEmissionLog` PDA by payment hash |
|
|
96
104
|
| `signDecision` | sign canonical decision bytes with the facilitator key |
|
|
97
105
|
|
|
98
|
-
|
|
106
|
+
The factories (`makeValidateOnChainTx`, `makeEmitFeedbackCpi`, `makePriorEmissionLookup`) are SDK exports — see [SDK → Exports reference](/sdk/exports-reference).
|
|
107
|
+
|
|
108
|
+
## Failure cases the adapter must keep
|
|
99
109
|
|
|
100
110
|
Do not remove these checks when adapting Pay.sh into a production server:
|
|
101
111
|
|
|
@@ -105,6 +115,32 @@ Do not remove these checks when adapting Pay.sh into a production server:
|
|
|
105
115
|
- reject `payTo` / `payeeRecipient` mismatch
|
|
106
116
|
- reject expired challenges
|
|
107
117
|
- reject replayed proof bindings
|
|
108
|
-
- reject transfer authority equal to facilitator fee payer
|
|
118
|
+
- reject transfer authority equal to facilitator fee payer (self-pay defense)
|
|
119
|
+
|
|
120
|
+
These are part of the adapter, not the route layer. The Pay.sh adapter's [`proof-validator.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/trustgate/server/src/facilitators/pay-sh/proof-validator.ts) is the reference implementation.
|
|
121
|
+
|
|
122
|
+
## Live evidence
|
|
123
|
+
|
|
124
|
+
Real atomic-settlement trace on devnet (2026-05-06):
|
|
125
|
+
|
|
126
|
+
| Step | Tx |
|
|
127
|
+
|---|---|
|
|
128
|
+
| Signed SPL `transferChecked` | [`5iV8EYmJh9XS…`](https://explorer.solana.com/tx/5iV8EYmJh9XSXkBQrrbQ5L9kmBQabD3G3RXVPsHn9PkWceTFoeRsUV4g5aLLzZyRjeBoFvK3Woxr2cZa5xeUwhVD?cluster=devnet) |
|
|
129
|
+
| `emit_feedback` PDA-signed CPI | [`jMobmWJUAXuL8…`](https://explorer.solana.com/tx/jMobmWJUAXuL8FmQujfxW9NmeMbzADUoABzqjiMeuc5m3YXyeuZeUw1ZJc29JGsqyWQGDY8q3vrtBdamhKXraag?cluster=devnet) |
|
|
130
|
+
| `FeedbackEmissionLog` PDA | [`HB4BBi9j…`](https://explorer.solana.com/address/HB4BBi9jaD3VPcZkQQaH3DxukSqBiXfW8RejtaLa8bF3?cluster=devnet) |
|
|
131
|
+
|
|
132
|
+
Full trace + reproduction commands: [Verification → Devnet smoke](/verification/devnet-smoke).
|
|
133
|
+
|
|
134
|
+
## Read next
|
|
109
135
|
|
|
110
|
-
|
|
136
|
+
<Cards>
|
|
137
|
+
<Card title="Facilitator adapters" href="/integration-guides/facilitator-adapters">
|
|
138
|
+
The five-method contract every adapter satisfies. Build your own.
|
|
139
|
+
</Card>
|
|
140
|
+
<Card title="Atomic-tx invariant" href="/verification/atomic-tx-invariant">
|
|
141
|
+
Why the gate, transfer, and feedback must execute as one Solana tx.
|
|
142
|
+
</Card>
|
|
143
|
+
<Card title="mountTrustGate" href="/sdk/mount-trustgate">
|
|
144
|
+
The SDK middleware that backs the adapter dispatch.
|
|
145
|
+
</Card>
|
|
146
|
+
</Cards>
|
|
@@ -1,39 +1,46 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: x402 facilitator
|
|
3
|
-
description: Add AgentTrust decisions to
|
|
2
|
+
title: x402 facilitator (generic)
|
|
3
|
+
description: Add AgentTrust decisions to any x402 facilitator without coupling to one vendor.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
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,
|
|
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
|
|
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:
|
|
30
|
-
facilitatorKeypair,
|
|
31
|
-
defaultPolicyId:
|
|
32
|
-
network:
|
|
33
|
-
atomicityEnforced:
|
|
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": "
|
|
45
|
-
"payeeAgentAsset": "
|
|
46
|
-
"amount":
|
|
47
|
-
"mint":
|
|
48
|
-
"policyId":
|
|
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
|
|
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:
|
|
80
|
+
X-Capability-Required: 366c075140aa69746625d4b733b55e267fc5c28387fd6d1c24901976ee3ddc42
|
|
81
|
+
X-Payment-Network: solana-devnet
|
|
73
82
|
```
|
|
74
83
|
|
|
75
|
-
|
|
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
|
-
|
|
86
|
+
## Settlement rule
|
|
78
87
|
|
|
79
|
-
|
|
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 <asset> 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>
|