@agenttrust-sdk/mcp 0.1.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/LICENSE +21 -0
- package/README.md +233 -0
- package/dist/chain.d.ts +41 -0
- package/dist/chain.js +164 -0
- package/dist/chain.js.map +1 -0
- package/dist/config.d.ts +35 -0
- package/dist/config.js +99 -0
- package/dist/config.js.map +1 -0
- package/dist/idl/policy_vault.json +1723 -0
- package/dist/idl/trustgate.json +623 -0
- package/dist/idl/validation_registry.json +1052 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +123 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/audit-payment.d.ts +10 -0
- package/dist/prompts/audit-payment.js +55 -0
- package/dist/prompts/audit-payment.js.map +1 -0
- package/dist/prompts/explain-failure.d.ts +7 -0
- package/dist/prompts/explain-failure.js +57 -0
- package/dist/prompts/explain-failure.js.map +1 -0
- package/dist/prompts/index.d.ts +3 -0
- package/dist/prompts/index.js +12 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/setup-agent.d.ts +6 -0
- package/dist/prompts/setup-agent.js +43 -0
- package/dist/prompts/setup-agent.js.map +1 -0
- package/dist/prompts/types.d.ts +23 -0
- package/dist/prompts/types.js +6 -0
- package/dist/prompts/types.js.map +1 -0
- package/dist/resources/docs.d.ts +23 -0
- package/dist/resources/docs.js +147 -0
- package/dist/resources/docs.js.map +1 -0
- package/dist/resources/programs.d.ts +14 -0
- package/dist/resources/programs.js +69 -0
- package/dist/resources/programs.js.map +1 -0
- package/dist/server.d.ts +19 -0
- package/dist/server.js +136 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/common.d.ts +18 -0
- package/dist/tools/common.js +77 -0
- package/dist/tools/common.js.map +1 -0
- package/dist/tools/discovery/docs.d.ts +48 -0
- package/dist/tools/discovery/docs.js +200 -0
- package/dist/tools/discovery/docs.js.map +1 -0
- package/dist/tools/discovery/explain-decision.d.ts +28 -0
- package/dist/tools/discovery/explain-decision.js +144 -0
- package/dist/tools/discovery/explain-decision.js.map +1 -0
- package/dist/tools/discovery/facilitator-walkthrough.d.ts +30 -0
- package/dist/tools/discovery/facilitator-walkthrough.js +117 -0
- package/dist/tools/discovery/facilitator-walkthrough.js.map +1 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.js +55 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/read/demo-state.d.ts +48 -0
- package/dist/tools/read/demo-state.js +129 -0
- package/dist/tools/read/demo-state.js.map +1 -0
- package/dist/tools/read/get-feedback-log.d.ts +28 -0
- package/dist/tools/read/get-feedback-log.js +51 -0
- package/dist/tools/read/get-feedback-log.js.map +1 -0
- package/dist/tools/read/get-killswitch.d.ts +38 -0
- package/dist/tools/read/get-killswitch.js +63 -0
- package/dist/tools/read/get-killswitch.js.map +1 -0
- package/dist/tools/read/get-policy.d.ts +51 -0
- package/dist/tools/read/get-policy.js +71 -0
- package/dist/tools/read/get-policy.js.map +1 -0
- package/dist/tools/read/get-quantu-reputation.d.ts +39 -0
- package/dist/tools/read/get-quantu-reputation.js +65 -0
- package/dist/tools/read/get-quantu-reputation.js.map +1 -0
- package/dist/tools/read/get-validation-attestation.d.ts +45 -0
- package/dist/tools/read/get-validation-attestation.js +76 -0
- package/dist/tools/read/get-validation-attestation.js.map +1 -0
- package/dist/tools/read/get-velocity.d.ts +31 -0
- package/dist/tools/read/get-velocity.js +50 -0
- package/dist/tools/read/get-velocity.js.map +1 -0
- package/dist/tools/read/list-facilitators.d.ts +31 -0
- package/dist/tools/read/list-facilitators.js +60 -0
- package/dist/tools/read/list-facilitators.js.map +1 -0
- package/dist/tools/read/list-policies.d.ts +33 -0
- package/dist/tools/read/list-policies.js +49 -0
- package/dist/tools/read/list-policies.js.map +1 -0
- package/dist/tools/read/simulate-payment.d.ts +44 -0
- package/dist/tools/read/simulate-payment.js +54 -0
- package/dist/tools/read/simulate-payment.js.map +1 -0
- package/dist/tools/types.d.ts +31 -0
- package/dist/tools/types.js +12 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/write/emit-feedback.d.ts +55 -0
- package/dist/tools/write/emit-feedback.js +83 -0
- package/dist/tools/write/emit-feedback.js.map +1 -0
- package/dist/tools/write/init-policy.d.ts +133 -0
- package/dist/tools/write/init-policy.js +124 -0
- package/dist/tools/write/init-policy.js.map +1 -0
- package/dist/tools/write/request-validation.d.ts +39 -0
- package/dist/tools/write/request-validation.js +69 -0
- package/dist/tools/write/request-validation.js.map +1 -0
- package/dist/tools/write/respond-to-validation.d.ts +47 -0
- package/dist/tools/write/respond-to-validation.js +81 -0
- package/dist/tools/write/respond-to-validation.js.map +1 -0
- package/dist/tools/write/set-killswitch.d.ts +34 -0
- package/dist/tools/write/set-killswitch.js +70 -0
- package/dist/tools/write/set-killswitch.js.map +1 -0
- package/package.json +72 -0
- package/scripts/install-claude-desktop.sh +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AgentTrust contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# `@agenttrust-sdk/mcp`
|
|
2
|
+
|
|
3
|
+
Model Context Protocol (MCP) server for AgentTrust. Drop the binary
|
|
4
|
+
into Claude Desktop, Cursor, or any MCP client and interact with the
|
|
5
|
+
deployed AgentTrust programs through natural language.
|
|
6
|
+
|
|
7
|
+
> Reads devnet by default. Mainnet is one env var away once mainnet
|
|
8
|
+
> deployment lands.
|
|
9
|
+
|
|
10
|
+
## Tool inventory
|
|
11
|
+
|
|
12
|
+
### Read (no signer required)
|
|
13
|
+
|
|
14
|
+
| Tool | What it returns |
|
|
15
|
+
|--|--|
|
|
16
|
+
| `agenttrust_get_policy` | Decoded `PolicyAccount` PDA for `(agent_asset, policy_id)` — every spending cap, velocity threshold, counterparty tier requirement, and required capability hash. |
|
|
17
|
+
| `agenttrust_list_policies` | All policies registered for an agent (lightweight summary; use `get_policy` for full decode). |
|
|
18
|
+
| `agenttrust_simulate_payment` | Read-only `gate_payment` simulation. Returns `Allow`, `Deny(reasonCode)`, or `RequireValidation(capabilityHash)`. |
|
|
19
|
+
| `agenttrust_get_killswitch` | `KillSwitchState` + `PolicyAuthority` for an agent. |
|
|
20
|
+
| `agenttrust_get_velocity` | `VelocityLedger` for `(agent, policy_id)` — sliding-window cumulative spend. |
|
|
21
|
+
| `agenttrust_get_feedback_log` | `FeedbackEmissionLog` by `payment_id_hash` (32-byte hex). |
|
|
22
|
+
| `agenttrust_get_quantu_reputation` | Quantu `atom_stats` decoded — tier (0..3), feedback count, risk score, confidence. |
|
|
23
|
+
| `agenttrust_get_validation_attestation` | Every `ValidationAttestation` for `(subject_asset, capability_hash)`. |
|
|
24
|
+
| `agenttrust_list_facilitators` | Active facilitator adapters (Pay.sh / Dexter / atxp / MCPay) + ship status. |
|
|
25
|
+
| `agenttrust_demo_state` | Three pre-warmed devnet counterparties used by `examples/pay-sh-demo`. |
|
|
26
|
+
|
|
27
|
+
### Write (require `KEYPAIR_B58` env)
|
|
28
|
+
|
|
29
|
+
| Tool | Effect |
|
|
30
|
+
|--|--|
|
|
31
|
+
| `agenttrust_init_policy` | Create `PolicyAccount` + `VelocityLedger` for the signer's agent. |
|
|
32
|
+
| `agenttrust_set_killswitch` | Pause / unpause the agent's `KillSwitchState` (lead-only multisig in v1). |
|
|
33
|
+
| `agenttrust_request_validation` | Open a `ValidationRequest` PDA. |
|
|
34
|
+
| `agenttrust_respond_to_validation` | Attestor writes a `ValidationAttestation` PDA. |
|
|
35
|
+
| `agenttrust_emit_feedback` | Facilitator-only `emit_feedback` CPI (signer must equal facilitator). |
|
|
36
|
+
|
|
37
|
+
Every write tool surfaces the resulting `txSignature` + Solana Explorer URL
|
|
38
|
+
in its response.
|
|
39
|
+
|
|
40
|
+
### Discovery
|
|
41
|
+
|
|
42
|
+
| Tool | What it does |
|
|
43
|
+
|--|--|
|
|
44
|
+
| `agenttrust_docs` | Full-text search the docs corpus at `docs-site/content/docs/`. Returns ranked hits with excerpts. |
|
|
45
|
+
| `agenttrust_facilitator_walkthrough` | Per-adapter integration walkthrough by name. Falls back to the generic adapters guide for unknown names. |
|
|
46
|
+
| `agenttrust_explain_decision` | Translate a `DenyReason` code (1..15) into the enum name + remediation hint. |
|
|
47
|
+
|
|
48
|
+
### Resources
|
|
49
|
+
|
|
50
|
+
| URI | MIME | Content |
|
|
51
|
+
|--|--|--|
|
|
52
|
+
| `agenttrust://devnet/programs` | `application/json` | Deployed program IDs + Explorer URLs for the active cluster. |
|
|
53
|
+
| `agenttrust://docs/<rel-path>` | `text/markdown` | Each MDX page in the docs corpus exposed individually. |
|
|
54
|
+
| `agenttrust://examples/pay-sh-demo/...` | `text/x-typescript` / `text/markdown` | Pay.sh demo source files. |
|
|
55
|
+
| `agenttrust://examples/attestor-demo/...` | `text/x-typescript` / `text/markdown` | Attestor demo source files. |
|
|
56
|
+
|
|
57
|
+
### Prompts (guided workflows)
|
|
58
|
+
|
|
59
|
+
| Prompt | What it walks the user through |
|
|
60
|
+
|--|--|
|
|
61
|
+
| `agenttrust_audit_payment` | Simulate a payment, read the policy, read the payee's reputation, surface the decision. |
|
|
62
|
+
| `agenttrust_setup_agent` | Bootstrap an agent's PolicyAuthority → KillSwitch → first PolicyAccount. |
|
|
63
|
+
| `agenttrust_explain_failure` | Given a failed payment's reason code, explain root cause + remediation. |
|
|
64
|
+
|
|
65
|
+
## Install
|
|
66
|
+
|
|
67
|
+
### Claude Desktop
|
|
68
|
+
|
|
69
|
+
Add to your config (`~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
70
|
+
on macOS, `%APPDATA%\Claude\claude_desktop_config.json` on Windows):
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"mcpServers": {
|
|
75
|
+
"agenttrust": {
|
|
76
|
+
"command": "node",
|
|
77
|
+
"args": ["/absolute/path/to/agenttrust/mcp/dist/index.js"],
|
|
78
|
+
"env": {
|
|
79
|
+
"RPC_URL": "https://api.devnet.solana.com",
|
|
80
|
+
"NETWORK": "solana-devnet"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Or run the helper:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
mcp/scripts/install-claude-desktop.sh
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The script edits the Claude Desktop config in place. It backs up the
|
|
94
|
+
prior config to `claude_desktop_config.json.bak.<timestamp>` so you can
|
|
95
|
+
revert if needed.
|
|
96
|
+
|
|
97
|
+
For write tools, add `KEYPAIR_B58` to the `env` block:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
"env": {
|
|
101
|
+
"RPC_URL": "https://api.devnet.solana.com",
|
|
102
|
+
"NETWORK": "solana-devnet",
|
|
103
|
+
"KEYPAIR_B58": "<base58-encoded 64-byte secret key>"
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Cursor
|
|
108
|
+
|
|
109
|
+
Cursor's MCP config lives at `~/.cursor/mcp.json` (or per-workspace
|
|
110
|
+
`.cursor/mcp.json`). Same shape as Claude Desktop:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"mcpServers": {
|
|
115
|
+
"agenttrust": {
|
|
116
|
+
"command": "node",
|
|
117
|
+
"args": ["/absolute/path/to/agenttrust/mcp/dist/index.js"]
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Generic stdio MCP client
|
|
124
|
+
|
|
125
|
+
The package ships a binary entry point. Once built:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
pnpm --filter ./mcp run build
|
|
129
|
+
node ./mcp/dist/index.js # stdio transport, default
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The server speaks MCP over stdin/stdout; any compliant MCP client
|
|
133
|
+
attaches by spawning this command.
|
|
134
|
+
|
|
135
|
+
### Hosted HTTP transport
|
|
136
|
+
|
|
137
|
+
Set `MCP_TRANSPORT=http` and `MCP_HTTP_PORT=8765`:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
MCP_TRANSPORT=http MCP_HTTP_PORT=8765 node ./mcp/dist/index.js
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The server listens on `http://0.0.0.0:8765` using
|
|
144
|
+
`StreamableHTTPServerTransport`. Behind a reverse proxy (Caddy, nginx,
|
|
145
|
+
Vercel) this surfaces as a public hosted endpoint.
|
|
146
|
+
|
|
147
|
+
> A hosted Vercel deployment URL is **not yet shipped**. The streamable-HTTP
|
|
148
|
+
> transport surface is present and exercised in CI, but a public hosted
|
|
149
|
+
> endpoint requires a Vercel project + DNS. Track this as a follow-up.
|
|
150
|
+
|
|
151
|
+
## Environment
|
|
152
|
+
|
|
153
|
+
| Var | Default | Effect |
|
|
154
|
+
|--|--|--|
|
|
155
|
+
| `RPC_URL` | devnet RPC | Solana RPC endpoint. |
|
|
156
|
+
| `NETWORK` | `solana-devnet` | `solana-devnet` or `solana-mainnet`. Drives Quantu program IDs. |
|
|
157
|
+
| `KEYPAIR_B58` | unset | Base58-encoded 64-byte secret key. Required for write tools. |
|
|
158
|
+
| `MCP_TRANSPORT` | `stdio` | `stdio` or `http`. |
|
|
159
|
+
| `MCP_HTTP_PORT` | `8765` | Port for HTTP transport. |
|
|
160
|
+
| `POLICY_VAULT_PROGRAM_ID` | devnet ID | Override the policy_vault program ID. |
|
|
161
|
+
| `TRUSTGATE_PROGRAM_ID` | devnet ID | Override the trustgate program ID. |
|
|
162
|
+
| `VALIDATION_REGISTRY_PROGRAM_ID` | devnet ID | Override the validation_registry program ID. |
|
|
163
|
+
| `MCP_DEFAULT_FACILITATOR` | unset | Default facilitator name surfaced in tool replies. |
|
|
164
|
+
| `MCP_DOCS_DIR` | repo `docs-site/content/docs` | Override the docs corpus root (tests). |
|
|
165
|
+
| `PAY_SH_DEMO_STATE_FILE` | `examples/pay-sh-demo/devnet-counterparties.json` | Override the demo state file. |
|
|
166
|
+
|
|
167
|
+
## Example natural-language prompts
|
|
168
|
+
|
|
169
|
+
Once installed, try these in Claude Desktop:
|
|
170
|
+
|
|
171
|
+
- "Use AgentTrust to look up the three pre-warmed devnet counterparties."
|
|
172
|
+
- "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?"
|
|
173
|
+
- "Pull the policy for agent <asset> ID 1 and tell me the spending caps."
|
|
174
|
+
- "Why would a payment with reason code 6 fail, and how do I fix it?"
|
|
175
|
+
- "Search the AgentTrust docs for the validation registry data flow."
|
|
176
|
+
- "Walk me through adding a new x402 facilitator adapter."
|
|
177
|
+
|
|
178
|
+
## IDL fetch
|
|
179
|
+
|
|
180
|
+
All three Anchor IDLs are published on devnet. Re-verify any time with:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
anchor idl fetch 8Y6fGeNEHgmWmbt8JsRcF72jxbeBfJhomMjG6SuoJQTR --provider.cluster devnet # policy_vault
|
|
184
|
+
anchor idl fetch HF8zHfoyA7b5mhLViopTnRMprc6ZT5KActHTdkFrih2N --provider.cluster devnet # trustgate
|
|
185
|
+
anchor idl fetch Cx4RFa6ysw3qXYhugPkF8pFSWBkmKq59h2dWgF2tKhtv --provider.cluster devnet # validation_registry
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The MCP server bundles snapshots at `src/idl/*.json` as a defensive
|
|
189
|
+
fallback (saves an RPC round-trip on cold start; keeps the server bootable
|
|
190
|
+
in offline / air-gapped harnesses). The latest evidence snapshot is in
|
|
191
|
+
[`../docs/proofs/idl-on-chain.json`](../docs/proofs/idl-on-chain.json) —
|
|
192
|
+
includes SHA256 hashes + instruction counts for each IDL.
|
|
193
|
+
|
|
194
|
+
## Build + test
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
pnpm install
|
|
198
|
+
pnpm --filter ./trustgate/sdk run build # MCP depends on the SDK build output
|
|
199
|
+
pnpm --filter ./mcp run build
|
|
200
|
+
pnpm --filter ./mcp test # unit tests (no chain access)
|
|
201
|
+
INTEGRATION=1 pnpm --filter ./mcp test:integration # devnet round-trip
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Architecture
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
mcp/src/
|
|
208
|
+
index.ts — entry point + transport selector
|
|
209
|
+
server.ts — MCP Server with tools/resources/prompts wired up
|
|
210
|
+
config.ts — env parsing
|
|
211
|
+
chain.ts — thin façade over @agenttrust-sdk/trustgate
|
|
212
|
+
tools/
|
|
213
|
+
types.ts — shared Tool<TInput, TOutput> shape
|
|
214
|
+
common.ts — pubkey / hex helpers + Zod schemas
|
|
215
|
+
index.ts — aggregates ALL_TOOLS
|
|
216
|
+
read/ — 10 read tools
|
|
217
|
+
write/ — 5 write tools
|
|
218
|
+
discovery/ — 3 discovery tools
|
|
219
|
+
resources/
|
|
220
|
+
docs.ts — MDX corpus indexer + path-traversal-safe demo readers
|
|
221
|
+
programs.ts — devnet program manifest as JSON resource
|
|
222
|
+
prompts/
|
|
223
|
+
types.ts — shared Prompt shape
|
|
224
|
+
audit-payment.ts
|
|
225
|
+
setup-agent.ts
|
|
226
|
+
explain-failure.ts
|
|
227
|
+
index.ts — aggregates ALL_PROMPTS
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Chain logic — PDA derivation, IDL loading, `gate_payment` simulation —
|
|
231
|
+
lives in `@agenttrust-sdk/trustgate`. The MCP server is a façade. If a
|
|
232
|
+
helper is missing in the SDK, add it to the SDK and re-export — never
|
|
233
|
+
fork the chain logic into `mcp/`.
|
package/dist/chain.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin façade over `@agenttrust-sdk/trustgate`. The MCP server's tools
|
|
3
|
+
* call into this module — never directly into Anchor or @solana/web3.js
|
|
4
|
+
* primitives — so the SDK stays the single source of truth for PDA
|
|
5
|
+
* derivation, IDL loading, and gate-payment simulation.
|
|
6
|
+
*
|
|
7
|
+
* If a helper is missing here, add it to the SDK and re-export. Don't
|
|
8
|
+
* fork chain logic.
|
|
9
|
+
*/
|
|
10
|
+
import * as anchor from "@coral-xyz/anchor";
|
|
11
|
+
import { AnchorProvider, BN, Program } from "@coral-xyz/anchor";
|
|
12
|
+
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
|
13
|
+
import { GateDecision, ProgramIds, derivePolicyPda, deriveVelocityPda, deriveKillSwitchPda, deriveFeedbackLogPda, deriveTrustGateAuthorityPda, deriveAgentAccountPda, deriveAtomConfigPda, deriveAtomStatsPda, deriveAtomRegistryAuthorityPda, deriveQuantuFeedbackAccounts, simulateGatePayment, fetchValidationAttestation, fetchValidationRequest, fetchAttestorProfile, fetchCapabilityNamespace, computeCapabilityHash, computeNamespaceHash, deriveAttestorProfilePda, deriveCapabilityNamespacePda, deriveValidationAttestationPda, deriveValidationRequestPda, buildRegisterAttestorIx, buildRegisterNamespaceIx, buildRequestValidationIx, buildRespondToValidationIx, buildRevokeValidationIx, QuantuProgramIds } from "@agenttrust-sdk/trustgate";
|
|
14
|
+
import { AgentTrustConfig } from "./config";
|
|
15
|
+
export { derivePolicyPda, deriveVelocityPda, deriveKillSwitchPda, deriveFeedbackLogPda, deriveTrustGateAuthorityPda, deriveAgentAccountPda, deriveAtomConfigPda, deriveAtomStatsPda, deriveAtomRegistryAuthorityPda, deriveQuantuFeedbackAccounts, deriveAttestorProfilePda, deriveCapabilityNamespacePda, deriveValidationAttestationPda, deriveValidationRequestPda, computeCapabilityHash, computeNamespaceHash, fetchValidationAttestation, fetchValidationRequest, fetchAttestorProfile, fetchCapabilityNamespace, buildRegisterAttestorIx, buildRegisterNamespaceIx, buildRequestValidationIx, buildRespondToValidationIx, buildRevokeValidationIx, simulateGatePayment, GateDecision, ProgramIds, QuantuProgramIds, };
|
|
16
|
+
/**
|
|
17
|
+
* Build an Anchor provider tied to `cfg.rpcUrl`. If a signer is configured
|
|
18
|
+
* the provider's wallet is the real signer; otherwise a throwaway keypair
|
|
19
|
+
* is used (sufficient for read-only simulation + RPC reads).
|
|
20
|
+
*/
|
|
21
|
+
export declare function makeProvider(cfg: AgentTrustConfig): AnchorProvider;
|
|
22
|
+
/**
|
|
23
|
+
* Lazily-instantiated program clients. `loadPolicyVault` etc. each fetch
|
|
24
|
+
* the IDL on first call; subsequent calls reuse the cached `Program`.
|
|
25
|
+
*/
|
|
26
|
+
export declare class ChainClient {
|
|
27
|
+
readonly cfg: AgentTrustConfig;
|
|
28
|
+
readonly provider: AnchorProvider;
|
|
29
|
+
private _policyVault?;
|
|
30
|
+
private _trustgate?;
|
|
31
|
+
private _validationRegistry?;
|
|
32
|
+
constructor(cfg: AgentTrustConfig);
|
|
33
|
+
get connection(): Connection;
|
|
34
|
+
/** Public key of the configured signer, or null if no signer is set. */
|
|
35
|
+
signerPubkey(): PublicKey | null;
|
|
36
|
+
requireSigner(): Keypair;
|
|
37
|
+
policyVault(): Promise<Program>;
|
|
38
|
+
trustgate(): Promise<Program>;
|
|
39
|
+
validationRegistry(): Promise<Program>;
|
|
40
|
+
}
|
|
41
|
+
export { AnchorProvider, BN, Program, anchor };
|
package/dist/chain.js
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Thin façade over `@agenttrust-sdk/trustgate`. The MCP server's tools
|
|
4
|
+
* call into this module — never directly into Anchor or @solana/web3.js
|
|
5
|
+
* primitives — so the SDK stays the single source of truth for PDA
|
|
6
|
+
* derivation, IDL loading, and gate-payment simulation.
|
|
7
|
+
*
|
|
8
|
+
* If a helper is missing here, add it to the SDK and re-export. Don't
|
|
9
|
+
* fork chain logic.
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
+
var ownKeys = function(o) {
|
|
29
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
+
var ar = [];
|
|
31
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
+
return ar;
|
|
33
|
+
};
|
|
34
|
+
return ownKeys(o);
|
|
35
|
+
};
|
|
36
|
+
return function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.anchor = exports.Program = exports.BN = exports.AnchorProvider = exports.ChainClient = exports.simulateGatePayment = exports.buildRevokeValidationIx = exports.buildRespondToValidationIx = exports.buildRequestValidationIx = exports.buildRegisterNamespaceIx = exports.buildRegisterAttestorIx = exports.fetchCapabilityNamespace = exports.fetchAttestorProfile = exports.fetchValidationRequest = exports.fetchValidationAttestation = exports.computeNamespaceHash = exports.computeCapabilityHash = exports.deriveValidationRequestPda = exports.deriveValidationAttestationPda = exports.deriveCapabilityNamespacePda = exports.deriveAttestorProfilePda = exports.deriveQuantuFeedbackAccounts = exports.deriveAtomRegistryAuthorityPda = exports.deriveAtomStatsPda = exports.deriveAtomConfigPda = exports.deriveAgentAccountPda = exports.deriveTrustGateAuthorityPda = exports.deriveFeedbackLogPda = exports.deriveKillSwitchPda = exports.deriveVelocityPda = exports.derivePolicyPda = void 0;
|
|
46
|
+
exports.makeProvider = makeProvider;
|
|
47
|
+
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
48
|
+
exports.anchor = anchor;
|
|
49
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
50
|
+
Object.defineProperty(exports, "AnchorProvider", { enumerable: true, get: function () { return anchor_1.AnchorProvider; } });
|
|
51
|
+
Object.defineProperty(exports, "BN", { enumerable: true, get: function () { return anchor_1.BN; } });
|
|
52
|
+
Object.defineProperty(exports, "Program", { enumerable: true, get: function () { return anchor_1.Program; } });
|
|
53
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
54
|
+
const trustgate_1 = require("@agenttrust-sdk/trustgate");
|
|
55
|
+
Object.defineProperty(exports, "derivePolicyPda", { enumerable: true, get: function () { return trustgate_1.derivePolicyPda; } });
|
|
56
|
+
Object.defineProperty(exports, "deriveVelocityPda", { enumerable: true, get: function () { return trustgate_1.deriveVelocityPda; } });
|
|
57
|
+
Object.defineProperty(exports, "deriveKillSwitchPda", { enumerable: true, get: function () { return trustgate_1.deriveKillSwitchPda; } });
|
|
58
|
+
Object.defineProperty(exports, "deriveFeedbackLogPda", { enumerable: true, get: function () { return trustgate_1.deriveFeedbackLogPda; } });
|
|
59
|
+
Object.defineProperty(exports, "deriveTrustGateAuthorityPda", { enumerable: true, get: function () { return trustgate_1.deriveTrustGateAuthorityPda; } });
|
|
60
|
+
Object.defineProperty(exports, "deriveAgentAccountPda", { enumerable: true, get: function () { return trustgate_1.deriveAgentAccountPda; } });
|
|
61
|
+
Object.defineProperty(exports, "deriveAtomConfigPda", { enumerable: true, get: function () { return trustgate_1.deriveAtomConfigPda; } });
|
|
62
|
+
Object.defineProperty(exports, "deriveAtomStatsPda", { enumerable: true, get: function () { return trustgate_1.deriveAtomStatsPda; } });
|
|
63
|
+
Object.defineProperty(exports, "deriveAtomRegistryAuthorityPda", { enumerable: true, get: function () { return trustgate_1.deriveAtomRegistryAuthorityPda; } });
|
|
64
|
+
Object.defineProperty(exports, "deriveQuantuFeedbackAccounts", { enumerable: true, get: function () { return trustgate_1.deriveQuantuFeedbackAccounts; } });
|
|
65
|
+
Object.defineProperty(exports, "simulateGatePayment", { enumerable: true, get: function () { return trustgate_1.simulateGatePayment; } });
|
|
66
|
+
Object.defineProperty(exports, "fetchValidationAttestation", { enumerable: true, get: function () { return trustgate_1.fetchValidationAttestation; } });
|
|
67
|
+
Object.defineProperty(exports, "fetchValidationRequest", { enumerable: true, get: function () { return trustgate_1.fetchValidationRequest; } });
|
|
68
|
+
Object.defineProperty(exports, "fetchAttestorProfile", { enumerable: true, get: function () { return trustgate_1.fetchAttestorProfile; } });
|
|
69
|
+
Object.defineProperty(exports, "fetchCapabilityNamespace", { enumerable: true, get: function () { return trustgate_1.fetchCapabilityNamespace; } });
|
|
70
|
+
Object.defineProperty(exports, "computeCapabilityHash", { enumerable: true, get: function () { return trustgate_1.computeCapabilityHash; } });
|
|
71
|
+
Object.defineProperty(exports, "computeNamespaceHash", { enumerable: true, get: function () { return trustgate_1.computeNamespaceHash; } });
|
|
72
|
+
Object.defineProperty(exports, "deriveAttestorProfilePda", { enumerable: true, get: function () { return trustgate_1.deriveAttestorProfilePda; } });
|
|
73
|
+
Object.defineProperty(exports, "deriveCapabilityNamespacePda", { enumerable: true, get: function () { return trustgate_1.deriveCapabilityNamespacePda; } });
|
|
74
|
+
Object.defineProperty(exports, "deriveValidationAttestationPda", { enumerable: true, get: function () { return trustgate_1.deriveValidationAttestationPda; } });
|
|
75
|
+
Object.defineProperty(exports, "deriveValidationRequestPda", { enumerable: true, get: function () { return trustgate_1.deriveValidationRequestPda; } });
|
|
76
|
+
Object.defineProperty(exports, "buildRegisterAttestorIx", { enumerable: true, get: function () { return trustgate_1.buildRegisterAttestorIx; } });
|
|
77
|
+
Object.defineProperty(exports, "buildRegisterNamespaceIx", { enumerable: true, get: function () { return trustgate_1.buildRegisterNamespaceIx; } });
|
|
78
|
+
Object.defineProperty(exports, "buildRequestValidationIx", { enumerable: true, get: function () { return trustgate_1.buildRequestValidationIx; } });
|
|
79
|
+
Object.defineProperty(exports, "buildRespondToValidationIx", { enumerable: true, get: function () { return trustgate_1.buildRespondToValidationIx; } });
|
|
80
|
+
Object.defineProperty(exports, "buildRevokeValidationIx", { enumerable: true, get: function () { return trustgate_1.buildRevokeValidationIx; } });
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
// Provider construction
|
|
83
|
+
// ---------------------------------------------------------------------------
|
|
84
|
+
/**
|
|
85
|
+
* Build an Anchor provider tied to `cfg.rpcUrl`. If a signer is configured
|
|
86
|
+
* the provider's wallet is the real signer; otherwise a throwaway keypair
|
|
87
|
+
* is used (sufficient for read-only simulation + RPC reads).
|
|
88
|
+
*/
|
|
89
|
+
function makeProvider(cfg) {
|
|
90
|
+
const conn = new web3_js_1.Connection(cfg.rpcUrl, "confirmed");
|
|
91
|
+
const wallet = new anchor_1.Wallet(cfg.signer ?? web3_js_1.Keypair.generate());
|
|
92
|
+
return new anchor_1.AnchorProvider(conn, wallet, { commitment: "confirmed" });
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Lazily-instantiated program clients. `loadPolicyVault` etc. each fetch
|
|
96
|
+
* the IDL on first call; subsequent calls reuse the cached `Program`.
|
|
97
|
+
*/
|
|
98
|
+
class ChainClient {
|
|
99
|
+
constructor(cfg) {
|
|
100
|
+
this.cfg = cfg;
|
|
101
|
+
this.provider = makeProvider(cfg);
|
|
102
|
+
}
|
|
103
|
+
get connection() {
|
|
104
|
+
return this.provider.connection;
|
|
105
|
+
}
|
|
106
|
+
/** Public key of the configured signer, or null if no signer is set. */
|
|
107
|
+
signerPubkey() {
|
|
108
|
+
return this.cfg.signer ? this.cfg.signer.publicKey : null;
|
|
109
|
+
}
|
|
110
|
+
requireSigner() {
|
|
111
|
+
if (!this.cfg.signer) {
|
|
112
|
+
throw new Error("This tool requires KEYPAIR_B58 in the environment. " +
|
|
113
|
+
"Set it to a base58-encoded 64-byte secret key, then restart the MCP server.");
|
|
114
|
+
}
|
|
115
|
+
return this.cfg.signer;
|
|
116
|
+
}
|
|
117
|
+
async policyVault() {
|
|
118
|
+
if (!this._policyVault) {
|
|
119
|
+
this._policyVault = await (0, trustgate_1.loadPolicyVault)(this.provider, this.cfg.programs.policyVault, BUNDLED_IDLS.policyVault);
|
|
120
|
+
}
|
|
121
|
+
return this._policyVault;
|
|
122
|
+
}
|
|
123
|
+
async trustgate() {
|
|
124
|
+
if (!this._trustgate) {
|
|
125
|
+
this._trustgate = await (0, trustgate_1.loadTrustGate)(this.provider, this.cfg.programs.trustgate, BUNDLED_IDLS.trustgate);
|
|
126
|
+
}
|
|
127
|
+
return this._trustgate;
|
|
128
|
+
}
|
|
129
|
+
async validationRegistry() {
|
|
130
|
+
if (!this._validationRegistry) {
|
|
131
|
+
this._validationRegistry = await (0, trustgate_1.loadValidationRegistry)(this.provider, this.cfg.validationRegistryId, BUNDLED_IDLS.validationRegistry);
|
|
132
|
+
}
|
|
133
|
+
return this._validationRegistry;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.ChainClient = ChainClient;
|
|
137
|
+
// ---------------------------------------------------------------------------
|
|
138
|
+
// Bundled IDLs — defensive fallback. All three IDLs ARE published on
|
|
139
|
+
// devnet (verified via `anchor idl fetch <programId> --provider.cluster
|
|
140
|
+
// devnet`; see docs/proofs/idl-on-chain.json for the latest evidence
|
|
141
|
+
// snapshot), but bundling them statically:
|
|
142
|
+
// • saves an RPC round-trip on every cold start
|
|
143
|
+
// • keeps the MCP server bootable in offline / air-gapped harnesses
|
|
144
|
+
// • survives the rare window after a fresh redeploy when `anchor idl
|
|
145
|
+
// upgrade` hasn't yet been run
|
|
146
|
+
// The JSON files are committed under src/idl/ as snapshots of target/idl
|
|
147
|
+
// at the time of the latest deploy. The build step copies them into
|
|
148
|
+
// dist/idl/ so the runtime require() resolves post-install.
|
|
149
|
+
// ---------------------------------------------------------------------------
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
151
|
+
const policyVaultIdl = require("./idl/policy_vault.json");
|
|
152
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
153
|
+
const trustgateIdl = require("./idl/trustgate.json");
|
|
154
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
155
|
+
const validationRegistryIdl = require("./idl/validation_registry.json");
|
|
156
|
+
const BUNDLED_IDLS = {
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
158
|
+
policyVault: policyVaultIdl,
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
160
|
+
trustgate: trustgateIdl,
|
|
161
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
162
|
+
validationRegistry: validationRegistryIdl,
|
|
163
|
+
};
|
|
164
|
+
//# sourceMappingURL=chain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGH,oCAIC;AArGD,0DAA4C;AAwMN,wBAAM;AAvM5C,8CAAwE;AAuM/D,+FAvMA,uBAAc,OAuMA;AAAE,mFAvMA,WAAE,OAuMA;AAAE,wFAvMA,gBAAO,OAuMA;AAtMpC,6CAAiE;AAEjE,yDAiCmC;AAUjC,gGAxCA,2BAAe,OAwCA;AACf,kGAxCA,6BAAiB,OAwCA;AACjB,oGAxCA,+BAAmB,OAwCA;AACnB,qGAxCA,gCAAoB,OAwCA;AACpB,4GAxCA,uCAA2B,OAwCA;AAC3B,sGAxCA,iCAAqB,OAwCA;AACrB,oGAxCA,+BAAmB,OAwCA;AACnB,mGAxCA,8BAAkB,OAwCA;AAClB,+GAxCA,0CAA8B,OAwCA;AAC9B,6GAxCA,wCAA4B,OAwCA;AAwB5B,oGA5DA,+BAAmB,OA4DA;AAbnB,2GA9CA,sCAA0B,OA8CA;AAC1B,uGA9CA,kCAAsB,OA8CA;AACtB,qGA9CA,g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A4D;AAC5D,8EAA8E;AAE9E,qGAAqG;AACrG,MAAM,cAAc,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAC1D,qGAAqG;AACrG,MAAM,YAAY,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AACrD,qGAAqG;AACrG,MAAM,qBAAqB,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;AAExE,MAAM,YAAY,GAAG;IACnB,8DAA8D;IAC9D,WAAW,EAAS,cAAqB;IACzC,8DAA8D;IAC9D,SAAS,EAAW,YAAmB;IACvC,8DAA8D;IAC9D,kBAAkB,EAAE,qBAA4B;CACjD,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Env parsing for the AgentTrust MCP server.
|
|
3
|
+
*
|
|
4
|
+
* Read tools work without any env. Write tools require `KEYPAIR_B58`.
|
|
5
|
+
* The HTTP transport requires `MCP_HTTP_PORT` (else stdio is the default).
|
|
6
|
+
*
|
|
7
|
+
* Defaults are biased toward the local-developer / Claude Desktop case:
|
|
8
|
+
* devnet RPC, devnet program IDs, no signer required.
|
|
9
|
+
*/
|
|
10
|
+
import { Keypair, PublicKey } from "@solana/web3.js";
|
|
11
|
+
import { ProgramIds, QuantuProgramIds } from "@agenttrust-sdk/trustgate";
|
|
12
|
+
export type Network = "solana-devnet" | "solana-mainnet";
|
|
13
|
+
export interface AgentTrustConfig {
|
|
14
|
+
readonly network: Network;
|
|
15
|
+
readonly rpcUrl: string;
|
|
16
|
+
readonly explorerCluster: "devnet" | "mainnet";
|
|
17
|
+
readonly programs: ProgramIds;
|
|
18
|
+
readonly validationRegistryId: PublicKey;
|
|
19
|
+
readonly quantu: QuantuProgramIds;
|
|
20
|
+
/** Optional signer keypair. Loaded from KEYPAIR_B58. Write tools require this. */
|
|
21
|
+
readonly signer?: Keypair;
|
|
22
|
+
/** Transport selection. */
|
|
23
|
+
readonly transport: "stdio" | "http";
|
|
24
|
+
/** HTTP transport port (only used when transport === "http"). */
|
|
25
|
+
readonly httpPort: number;
|
|
26
|
+
/** Optional default facilitator name to surface in tool replies. */
|
|
27
|
+
readonly defaultFacilitator?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function loadConfig(): AgentTrustConfig;
|
|
30
|
+
/**
|
|
31
|
+
* Build a Solana Explorer URL for a tx signature or account, scoped to
|
|
32
|
+
* the active cluster. Devnet uses `?cluster=devnet`, mainnet has no
|
|
33
|
+
* suffix.
|
|
34
|
+
*/
|
|
35
|
+
export declare function explorerUrl(cfg: AgentTrustConfig, kind: "tx" | "address", value: string): string;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Env parsing for the AgentTrust MCP server.
|
|
4
|
+
*
|
|
5
|
+
* Read tools work without any env. Write tools require `KEYPAIR_B58`.
|
|
6
|
+
* The HTTP transport requires `MCP_HTTP_PORT` (else stdio is the default).
|
|
7
|
+
*
|
|
8
|
+
* Defaults are biased toward the local-developer / Claude Desktop case:
|
|
9
|
+
* devnet RPC, devnet program IDs, no signer required.
|
|
10
|
+
*/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.loadConfig = loadConfig;
|
|
16
|
+
exports.explorerUrl = explorerUrl;
|
|
17
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
18
|
+
const bs58_1 = __importDefault(require("bs58"));
|
|
19
|
+
const trustgate_1 = require("@agenttrust-sdk/trustgate");
|
|
20
|
+
const DEVNET_RPC = "https://api.devnet.solana.com";
|
|
21
|
+
const MAINNET_RPC = "https://api.mainnet-beta.solana.com";
|
|
22
|
+
function readNetwork() {
|
|
23
|
+
const raw = (process.env.NETWORK ?? "solana-devnet").trim().toLowerCase();
|
|
24
|
+
if (raw === "solana-mainnet" || raw === "mainnet" || raw === "mainnet-beta") {
|
|
25
|
+
return "solana-mainnet";
|
|
26
|
+
}
|
|
27
|
+
return "solana-devnet";
|
|
28
|
+
}
|
|
29
|
+
function readSigner() {
|
|
30
|
+
const raw = process.env.KEYPAIR_B58?.trim();
|
|
31
|
+
if (!raw)
|
|
32
|
+
return undefined;
|
|
33
|
+
try {
|
|
34
|
+
const bytes = bs58_1.default.decode(raw);
|
|
35
|
+
return web3_js_1.Keypair.fromSecretKey(bytes);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
throw new Error(`KEYPAIR_B58 is set but failed to decode: ${err.message}. ` +
|
|
39
|
+
`Expected base58-encoded 64-byte secret key.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function readTransport() {
|
|
43
|
+
const raw = (process.env.MCP_TRANSPORT ?? "stdio").trim().toLowerCase();
|
|
44
|
+
const port = Number.parseInt(process.env.MCP_HTTP_PORT ?? "8765", 10);
|
|
45
|
+
if (raw === "http" || raw === "sse")
|
|
46
|
+
return { transport: "http", httpPort: port };
|
|
47
|
+
return { transport: "stdio", httpPort: port };
|
|
48
|
+
}
|
|
49
|
+
function loadConfig() {
|
|
50
|
+
const network = readNetwork();
|
|
51
|
+
const rpcUrl = (process.env.RPC_URL ?? (network === "solana-mainnet" ? MAINNET_RPC : DEVNET_RPC)).trim();
|
|
52
|
+
const { transport, httpPort } = readTransport();
|
|
53
|
+
// Devnet ships fully-deployed AgentTrust + Quantu. Mainnet ships
|
|
54
|
+
// Quantu only (per CLAUDE.md). When mainnet is selected the AgentTrust
|
|
55
|
+
// program IDs default to devnet placeholders — overridable via env once
|
|
56
|
+
// mainnet deployment lands.
|
|
57
|
+
const programs = {
|
|
58
|
+
policyVault: parsePubkeyEnv("POLICY_VAULT_PROGRAM_ID", trustgate_1.DEFAULT_DEVNET_PROGRAM_IDS.policyVault),
|
|
59
|
+
trustgate: parsePubkeyEnv("TRUSTGATE_PROGRAM_ID", trustgate_1.DEFAULT_DEVNET_PROGRAM_IDS.trustgate),
|
|
60
|
+
};
|
|
61
|
+
const quantu = network === "solana-mainnet"
|
|
62
|
+
? trustgate_1.MAINNET_QUANTU_IDS
|
|
63
|
+
: trustgate_1.DEFAULT_DEVNET_QUANTU_IDS;
|
|
64
|
+
const validationRegistryId = parsePubkeyEnv("VALIDATION_REGISTRY_PROGRAM_ID", trustgate_1.VALIDATION_REGISTRY_DEVNET_ID);
|
|
65
|
+
return {
|
|
66
|
+
network,
|
|
67
|
+
rpcUrl,
|
|
68
|
+
explorerCluster: network === "solana-mainnet" ? "mainnet" : "devnet",
|
|
69
|
+
programs,
|
|
70
|
+
validationRegistryId,
|
|
71
|
+
quantu,
|
|
72
|
+
signer: readSigner(),
|
|
73
|
+
transport,
|
|
74
|
+
httpPort,
|
|
75
|
+
defaultFacilitator: process.env.MCP_DEFAULT_FACILITATOR?.trim() || undefined,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function parsePubkeyEnv(name, fallback) {
|
|
79
|
+
const raw = process.env[name]?.trim();
|
|
80
|
+
if (!raw)
|
|
81
|
+
return fallback;
|
|
82
|
+
try {
|
|
83
|
+
return new web3_js_1.PublicKey(raw);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
throw new Error(`${name} is not a valid base58 pubkey: ${err.message}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Build a Solana Explorer URL for a tx signature or account, scoped to
|
|
91
|
+
* the active cluster. Devnet uses `?cluster=devnet`, mainnet has no
|
|
92
|
+
* suffix.
|
|
93
|
+
*/
|
|
94
|
+
function explorerUrl(cfg, kind, value) {
|
|
95
|
+
const path = kind === "tx" ? `tx/${value}` : `address/${value}`;
|
|
96
|
+
const suffix = cfg.explorerCluster === "devnet" ? "?cluster=devnet" : "";
|
|
97
|
+
return `https://explorer.solana.com/${path}${suffix}`;
|
|
98
|
+
}
|
|
99
|
+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