@agenttrust-sdk/mcp 0.3.3 → 0.3.5
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/chain.js +25 -0
- package/dist/chain.js.map +1 -1
- package/dist/config.d.ts +20 -1
- package/dist/config.js +49 -13
- package/dist/config.js.map +1 -1
- package/dist/embedded-docs/quickstart.mdx +11 -0
- package/dist/embedded-examples/pay-sh-demo/src/index.ts +12 -0
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +143 -5
- package/dist/errors.js.map +1 -1
- package/dist/idl/trustgate.json +8 -0
- package/dist/server.d.ts +27 -0
- package/dist/server.js +75 -1
- package/dist/server.js.map +1 -1
- package/dist/tools/write/request-validation.js +5 -1
- package/dist/tools/write/request-validation.js.map +1 -1
- package/dist/tools/write/respond-to-validation.js +5 -1
- package/dist/tools/write/respond-to-validation.js.map +1 -1
- package/package.json +2 -2
package/dist/chain.js
CHANGED
|
@@ -78,6 +78,7 @@ Object.defineProperty(exports, "buildRegisterNamespaceIx", { enumerable: true, g
|
|
|
78
78
|
Object.defineProperty(exports, "buildRequestValidationIx", { enumerable: true, get: function () { return trustgate_1.buildRequestValidationIx; } });
|
|
79
79
|
Object.defineProperty(exports, "buildRespondToValidationIx", { enumerable: true, get: function () { return trustgate_1.buildRespondToValidationIx; } });
|
|
80
80
|
Object.defineProperty(exports, "buildRevokeValidationIx", { enumerable: true, get: function () { return trustgate_1.buildRevokeValidationIx; } });
|
|
81
|
+
const config_1 = require("./config");
|
|
81
82
|
// ---------------------------------------------------------------------------
|
|
82
83
|
// Provider construction
|
|
83
84
|
// ---------------------------------------------------------------------------
|
|
@@ -117,18 +118,21 @@ class ChainClient {
|
|
|
117
118
|
return this.cfg.signer;
|
|
118
119
|
}
|
|
119
120
|
async policyVault() {
|
|
121
|
+
guardATProgramId("policy_vault", "POLICY_VAULT_PROGRAM_ID", this.cfg.programs.policyVault);
|
|
120
122
|
if (!this._policyVault) {
|
|
121
123
|
this._policyVault = await (0, trustgate_1.loadPolicyVault)(this.provider, this.cfg.programs.policyVault, BUNDLED_IDLS.policyVault);
|
|
122
124
|
}
|
|
123
125
|
return this._policyVault;
|
|
124
126
|
}
|
|
125
127
|
async trustgate() {
|
|
128
|
+
guardATProgramId("trustgate", "TRUSTGATE_PROGRAM_ID", this.cfg.programs.trustGate);
|
|
126
129
|
if (!this._trustgate) {
|
|
127
130
|
this._trustgate = await (0, trustgate_1.loadTrustGate)(this.provider, this.cfg.programs.trustGate, BUNDLED_IDLS.trustgate);
|
|
128
131
|
}
|
|
129
132
|
return this._trustgate;
|
|
130
133
|
}
|
|
131
134
|
async validationRegistry() {
|
|
135
|
+
guardATProgramId("validation_registry", "VALIDATION_REGISTRY_PROGRAM_ID", this.cfg.programs.validationRegistry);
|
|
132
136
|
if (!this._validationRegistry) {
|
|
133
137
|
this._validationRegistry = await (0, trustgate_1.loadValidationRegistry)(this.provider, this.cfg.programs.validationRegistry, BUNDLED_IDLS.validationRegistry);
|
|
134
138
|
}
|
|
@@ -136,6 +140,27 @@ class ChainClient {
|
|
|
136
140
|
}
|
|
137
141
|
}
|
|
138
142
|
exports.ChainClient = ChainClient;
|
|
143
|
+
/**
|
|
144
|
+
* If `pubkey` is the mainnet-undeployed sentinel (System Program), throw
|
|
145
|
+
* a structured `config_error` so the MCP `tools/call` envelope surfaces
|
|
146
|
+
* a clean remediation instead of an opaque "account does not exist"
|
|
147
|
+
* Anchor failure that the classifier might miscategorise.
|
|
148
|
+
*
|
|
149
|
+
* The thrown `Error` carries `name = "ConfigError"` so
|
|
150
|
+
* `errors.ts:classifyError` can route it to `errorCode: "config_error"`
|
|
151
|
+
* without ad-hoc string matching.
|
|
152
|
+
*/
|
|
153
|
+
function guardATProgramId(programLabel, envVar, pubkey) {
|
|
154
|
+
if (!(0, config_1.isMainnetUndeployedSentinel)(pubkey))
|
|
155
|
+
return;
|
|
156
|
+
const err = new Error(`AgentTrust ${programLabel} program is not deployed on mainnet yet. ` +
|
|
157
|
+
`Set ${envVar} to an explicit base58 program ID, or use NETWORK=solana-devnet ` +
|
|
158
|
+
`where AgentTrust programs are already deployed. Quantu reads ` +
|
|
159
|
+
`(get_quantu_reputation, agent_account lookups) are unaffected and work on ` +
|
|
160
|
+
`mainnet without any AgentTrust program ID override.`);
|
|
161
|
+
err.name = "ConfigError";
|
|
162
|
+
throw err;
|
|
163
|
+
}
|
|
139
164
|
// ---------------------------------------------------------------------------
|
|
140
165
|
// Bundled IDLs — defensive fallback. All three IDLs ARE published on
|
|
141
166
|
// devnet (verified via `anchor idl fetch <programId> --provider.cluster
|
package/dist/chain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGH,oCAIC;AArGD,0DAA4C;
|
|
1
|
+
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGH,oCAIC;AArGD,0DAA4C;AAsON,wBAAM;AArO5C,8CAAwE;AAqO/D,+FArOA,uBAAc,OAqOA;AAAE,mFArOA,WAAE,OAqOA;AAAE,wFArOA,gBAAO,OAqOA;AApOpC,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;AAbn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ANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* Defaults are biased toward the local-developer / Claude Desktop case:
|
|
14
14
|
* devnet RPC, devnet program IDs, no signer required.
|
|
15
15
|
*/
|
|
16
|
-
import { Keypair } from "@solana/web3.js";
|
|
16
|
+
import { Keypair, PublicKey } from "@solana/web3.js";
|
|
17
17
|
import { ProgramIds, QuantuProgramIds } from "@agenttrust-sdk/trustgate";
|
|
18
18
|
export type Network = "solana-devnet" | "solana-mainnet";
|
|
19
19
|
export interface AgentTrustConfig {
|
|
@@ -40,6 +40,25 @@ export interface AgentTrustConfig {
|
|
|
40
40
|
/** Optional default facilitator name to surface in tool replies. */
|
|
41
41
|
readonly defaultFacilitator?: string;
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Sentinel pubkey for AgentTrust programs on mainnet when the operator
|
|
45
|
+
* hasn't supplied explicit overrides via env. We use the System Program
|
|
46
|
+
* (`11111111111111111111111111111111`) because:
|
|
47
|
+
* - It's a valid PublicKey (passes `new PublicKey(...)`), so the rest
|
|
48
|
+
* of the config pipeline works unchanged.
|
|
49
|
+
* - It's never a real AgentTrust program ID, so chain.ts can detect
|
|
50
|
+
* the sentinel cheaply with `.equals(MAINNET_UNDEPLOYED_SENTINEL)`.
|
|
51
|
+
* - Booting against it would fail loudly the moment any AT-touching
|
|
52
|
+
* tool tries to `loadPolicyVault` / `loadTrustGate` etc., which is
|
|
53
|
+
* exactly the call-time error we want (`config_error` envelope).
|
|
54
|
+
*
|
|
55
|
+
* Quantu programs always have real IDs (see `MAINNET_QUANTU_IDS` in
|
|
56
|
+
* `@agenttrust-sdk/trustgate`) so `get_quantu_reputation` and the
|
|
57
|
+
* agent-account lookup path are unaffected.
|
|
58
|
+
*/
|
|
59
|
+
export declare const MAINNET_UNDEPLOYED_SENTINEL: PublicKey;
|
|
60
|
+
/** True iff `pubkey` is the mainnet-undeployed sentinel. */
|
|
61
|
+
export declare function isMainnetUndeployedSentinel(pubkey: PublicKey): boolean;
|
|
43
62
|
/**
|
|
44
63
|
* Decode a JSON-array secret-key file (Solana CLI's native format) into
|
|
45
64
|
* a Keypair. Exported for direct testing.
|
package/dist/config.js
CHANGED
|
@@ -51,6 +51,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
51
51
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
52
52
|
};
|
|
53
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.MAINNET_UNDEPLOYED_SENTINEL = void 0;
|
|
55
|
+
exports.isMainnetUndeployedSentinel = isMainnetUndeployedSentinel;
|
|
54
56
|
exports.readKeypairFile = readKeypairFile;
|
|
55
57
|
exports.loadConfig = loadConfig;
|
|
56
58
|
exports.explorerUrl = explorerUrl;
|
|
@@ -62,6 +64,27 @@ const bs58_1 = __importDefault(require("bs58"));
|
|
|
62
64
|
const trustgate_1 = require("@agenttrust-sdk/trustgate");
|
|
63
65
|
const DEVNET_RPC = "https://api.devnet.solana.com";
|
|
64
66
|
const MAINNET_RPC = "https://api.mainnet-beta.solana.com";
|
|
67
|
+
/**
|
|
68
|
+
* Sentinel pubkey for AgentTrust programs on mainnet when the operator
|
|
69
|
+
* hasn't supplied explicit overrides via env. We use the System Program
|
|
70
|
+
* (`11111111111111111111111111111111`) because:
|
|
71
|
+
* - It's a valid PublicKey (passes `new PublicKey(...)`), so the rest
|
|
72
|
+
* of the config pipeline works unchanged.
|
|
73
|
+
* - It's never a real AgentTrust program ID, so chain.ts can detect
|
|
74
|
+
* the sentinel cheaply with `.equals(MAINNET_UNDEPLOYED_SENTINEL)`.
|
|
75
|
+
* - Booting against it would fail loudly the moment any AT-touching
|
|
76
|
+
* tool tries to `loadPolicyVault` / `loadTrustGate` etc., which is
|
|
77
|
+
* exactly the call-time error we want (`config_error` envelope).
|
|
78
|
+
*
|
|
79
|
+
* Quantu programs always have real IDs (see `MAINNET_QUANTU_IDS` in
|
|
80
|
+
* `@agenttrust-sdk/trustgate`) so `get_quantu_reputation` and the
|
|
81
|
+
* agent-account lookup path are unaffected.
|
|
82
|
+
*/
|
|
83
|
+
exports.MAINNET_UNDEPLOYED_SENTINEL = new web3_js_1.PublicKey("11111111111111111111111111111111");
|
|
84
|
+
/** True iff `pubkey` is the mainnet-undeployed sentinel. */
|
|
85
|
+
function isMainnetUndeployedSentinel(pubkey) {
|
|
86
|
+
return pubkey.equals(exports.MAINNET_UNDEPLOYED_SENTINEL);
|
|
87
|
+
}
|
|
65
88
|
function readNetwork() {
|
|
66
89
|
const raw = (process.env.NETWORK ?? "solana-devnet").trim().toLowerCase();
|
|
67
90
|
if (raw === "solana-mainnet" || raw === "mainnet" || raw === "mainnet-beta") {
|
|
@@ -191,23 +214,36 @@ function loadConfig() {
|
|
|
191
214
|
}
|
|
192
215
|
const { transport, httpPort, httpHost } = readTransport();
|
|
193
216
|
// AgentTrust programs ship on devnet. Quantu ships on both devnet and
|
|
194
|
-
// mainnet. When mainnet is selected
|
|
195
|
-
//
|
|
196
|
-
//
|
|
197
|
-
//
|
|
217
|
+
// mainnet. When mainnet is selected without explicit AgentTrust program
|
|
218
|
+
// IDs we fall back to a sentinel pubkey (System Program 11..1) so the
|
|
219
|
+
// server still boots and Quantu-only reads keep working. AT-touching
|
|
220
|
+
// tools detect the sentinel at call time and throw a structured
|
|
221
|
+
// `config_error` envelope. See `chain.ts:requireProgramId` and the gate
|
|
222
|
+
// E2E report (Polish item 2 in
|
|
223
|
+
// submission/e2e-claude-code-2026-05-13/README.md).
|
|
198
224
|
const policyVaultEnv = process.env.POLICY_VAULT_PROGRAM_ID?.trim();
|
|
199
225
|
const trustGateEnv = process.env.TRUSTGATE_PROGRAM_ID?.trim();
|
|
200
226
|
const validationRegistryEnv = process.env.VALIDATION_REGISTRY_PROGRAM_ID?.trim();
|
|
201
227
|
if (network === "solana-mainnet" && !policyVaultEnv && !trustGateEnv && !validationRegistryEnv) {
|
|
202
|
-
|
|
203
|
-
"
|
|
204
|
-
"
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
228
|
+
process.stderr.write("[agenttrust] WARN mainnet selected but AgentTrust programs are not " +
|
|
229
|
+
"deployed to mainnet yet. Read tools that touch policy_vault / trustgate " +
|
|
230
|
+
"/ validation_registry will fail with errorCode: \"config_error\". Quantu " +
|
|
231
|
+
"reads (get_quantu_reputation, agent_account lookups) are unaffected. " +
|
|
232
|
+
"To override, set POLICY_VAULT_PROGRAM_ID / TRUSTGATE_PROGRAM_ID / " +
|
|
233
|
+
"VALIDATION_REGISTRY_PROGRAM_ID.\n");
|
|
234
|
+
}
|
|
235
|
+
const onMainnetWithoutOverrides = network === "solana-mainnet" && !policyVaultEnv && !trustGateEnv && !validationRegistryEnv;
|
|
236
|
+
const programs = onMainnetWithoutOverrides
|
|
237
|
+
? {
|
|
238
|
+
policyVault: exports.MAINNET_UNDEPLOYED_SENTINEL,
|
|
239
|
+
trustGate: exports.MAINNET_UNDEPLOYED_SENTINEL,
|
|
240
|
+
validationRegistry: exports.MAINNET_UNDEPLOYED_SENTINEL,
|
|
241
|
+
}
|
|
242
|
+
: {
|
|
243
|
+
policyVault: parsePubkeyEnv("POLICY_VAULT_PROGRAM_ID", trustgate_1.DEFAULT_DEVNET_PROGRAM_IDS.policyVault),
|
|
244
|
+
trustGate: parsePubkeyEnv("TRUSTGATE_PROGRAM_ID", trustgate_1.DEFAULT_DEVNET_PROGRAM_IDS.trustGate),
|
|
245
|
+
validationRegistry: parsePubkeyEnv("VALIDATION_REGISTRY_PROGRAM_ID", trustgate_1.VALIDATION_REGISTRY_DEVNET_ID),
|
|
246
|
+
};
|
|
211
247
|
const quantu = network === "solana-mainnet"
|
|
212
248
|
? trustgate_1.MAINNET_QUANTU_IDS
|
|
213
249
|
: trustgate_1.DEFAULT_DEVNET_QUANTU_IDS;
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config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,CAAC,CAAC,CAAC,EAAE,CAAC;IACzE,OAAO,+BAA+B,IAAI,GAAG,MAAM,EAAE,CAAC;AACxD,CAAC"}
|
|
@@ -46,6 +46,17 @@ Output:
|
|
|
46
46
|
|
|
47
47
|
Open the `explorerTxUrl` to see the on-chain transaction. The `policyPda` is the `PolicyAccount` PDA the gate evaluates against on every payment.
|
|
48
48
|
|
|
49
|
+
### Before you simulate: seed a counterparty
|
|
50
|
+
|
|
51
|
+
`agenttrust_simulate_payment` runs `gate_payment` against a payee agent that must already exist on Quantu's `agent_registry`. A brand-new agent_asset that has never been registered will surface an `AccountNotInitialized` error (now correctly classified as `chain_error` in the envelope), not a clean gate decision.
|
|
52
|
+
|
|
53
|
+
Two ways to get a counterparty the simulator can reach:
|
|
54
|
+
|
|
55
|
+
1. Use a bundled demo counterparty. The repo ships three pre-seeded agents at `examples/pay-sh-demo/devnet-counterparties.json` (tier 0, tier 1, tier 3). The pubkey `BTcgiDauqVHoGMiXujytE5wycfncDEmNnXJiUZ4s4oWL` is one of them and is safe to drop into the prompt below as the `payee_agent`.
|
|
56
|
+
2. Register your own. Run the Quantu `register_agent` flow (see the Quantu reference at `/quantu` for the full instruction set, or call `agenttrust_register_agent` via the MCP server) and use the new agent_asset.
|
|
57
|
+
|
|
58
|
+
If neither is set up, the simulator still returns a structured envelope. The hint inside it names the missing on-chain account so you know exactly which step to run next.
|
|
59
|
+
|
|
49
60
|
## 3. Run a gate-decision simulation
|
|
50
61
|
|
|
51
62
|
Now ask:
|
|
@@ -254,6 +254,18 @@ function assembleDemoApp(args: AssembleArgs): DemoApp {
|
|
|
254
254
|
const app = express();
|
|
255
255
|
app.use(express.json({ limit: "256kb" }));
|
|
256
256
|
|
|
257
|
+
// Friendly root handler. Replaces the bare Express "Cannot GET /"
|
|
258
|
+
// 404 for visitors landing on https://demo.agenttrust.tech/ from a
|
|
259
|
+
// browser. Returns 200 with a small JSON payload pointing at the
|
|
260
|
+
// docs and the functional endpoints.
|
|
261
|
+
app.get("/", (_req, res) => {
|
|
262
|
+
res.status(200).json({
|
|
263
|
+
service: "agenttrust-demo",
|
|
264
|
+
docs: "https://docs.agenttrust.tech",
|
|
265
|
+
endpoints: ["/protected", "/health"],
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
|
|
257
269
|
app.get("/health", (_req, res) => {
|
|
258
270
|
res.json({
|
|
259
271
|
status: "ok",
|
package/dist/errors.d.ts
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* pattern-matching in `server.ts`.
|
|
35
35
|
*/
|
|
36
36
|
/** Stable enum of error categories surfaced to MCP clients. */
|
|
37
|
-
export type ToolErrorCode = "auth_required" | "input_invalid" | "rpc_failure" | "chain_error" | "not_found" | "internal";
|
|
37
|
+
export type ToolErrorCode = "auth_required" | "config_error" | "input_invalid" | "rpc_failure" | "chain_error" | "not_found" | "internal";
|
|
38
38
|
export interface ToolError {
|
|
39
39
|
errorCode: ToolErrorCode;
|
|
40
40
|
message: string;
|
package/dist/errors.js
CHANGED
|
@@ -119,12 +119,119 @@ function isAnchorError(err, name, message) {
|
|
|
119
119
|
// AnchorError.toString() includes "AnchorError caused by account..."
|
|
120
120
|
if (message.startsWith("AnchorError"))
|
|
121
121
|
return true;
|
|
122
|
+
// AnchorError exposes structured `error.errorCode.code` even when the
|
|
123
|
+
// surface message doesn't look Anchor-y (e.g. when a tool catches and
|
|
124
|
+
// rethrows). Sniff the shape directly.
|
|
125
|
+
if (typeof err === "object" && err !== null) {
|
|
126
|
+
const e = err;
|
|
127
|
+
if (typeof e.error?.errorCode?.code === "string")
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
122
130
|
// SendTransactionError wraps AnchorError for .rpc() calls
|
|
123
131
|
if (/Error Code:\s*\w+\.\s*Error Number:\s*\d+/i.test(message))
|
|
124
132
|
return true;
|
|
125
133
|
// CPI-deep failures bubble up `custom program error: 0x...`
|
|
126
134
|
if (/custom program error:\s*0x[0-9a-f]+/i.test(message))
|
|
127
135
|
return true;
|
|
136
|
+
// Raw Solana `InstructionError` payload — surfaces when a simulation /
|
|
137
|
+
// send hits a program error before Anchor decodes it. Two shapes:
|
|
138
|
+
// - JSON string in message: 'simulation failed: {"InstructionError":[0,{"Custom":3012}]}'
|
|
139
|
+
// - Plain text: 'transaction simulation failed: ... InstructionError ... Custom: 3012'
|
|
140
|
+
if (/InstructionError/.test(message))
|
|
141
|
+
return true;
|
|
142
|
+
if (/"Custom":\s*\d+/.test(message))
|
|
143
|
+
return true;
|
|
144
|
+
if (/\bCustom:\s*\d+\b/.test(message))
|
|
145
|
+
return true;
|
|
146
|
+
// web3.js `SendTransactionError` — thrown by `Connection.simulateTransaction`
|
|
147
|
+
// and `Connection.sendRawTransaction` when the runtime rejects a tx for a
|
|
148
|
+
// reason that isn't an Anchor-decoded `Custom NNN`. The error class name
|
|
149
|
+
// appears in the auto-appended guide text ("Catch the
|
|
150
|
+
// `SendTransactionError` and call `getLogs()` on it for full details.").
|
|
151
|
+
// The constructor itself starts the message with "Simulation failed." or
|
|
152
|
+
// "Transaction ... resulted in an error." — match both shapes so the
|
|
153
|
+
// envelope lands as `chain_error` not `internal`. See the gate E2E rerun
|
|
154
|
+
// Beat F polish note for the originating transcript shape (downstream CPI
|
|
155
|
+
// hits "An account required by the instruction is missing").
|
|
156
|
+
if (name === "SendTransactionError")
|
|
157
|
+
return true;
|
|
158
|
+
if (/SendTransactionError/.test(message))
|
|
159
|
+
return true;
|
|
160
|
+
if (/Simulation failed\.\s*\nMessage:/i.test(message))
|
|
161
|
+
return true;
|
|
162
|
+
if (/^Transaction \w+ resulted in an error/i.test(message))
|
|
163
|
+
return true;
|
|
164
|
+
if (/Transaction simulation failed:/i.test(message))
|
|
165
|
+
return true;
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Extract a `Custom <n>` Anchor error number from an `InstructionError`
|
|
170
|
+
* payload. Used to build a richer hint in the `chain_error` envelope.
|
|
171
|
+
*
|
|
172
|
+
* Matches both JSON ({"Custom":3012}) and text (`Custom: 3012`) shapes.
|
|
173
|
+
* Returns undefined if no recognisable code is present.
|
|
174
|
+
*/
|
|
175
|
+
function extractCustomErrorCode(message) {
|
|
176
|
+
const jsonMatch = /"Custom":\s*(\d+)/.exec(message);
|
|
177
|
+
if (jsonMatch)
|
|
178
|
+
return Number.parseInt(jsonMatch[1], 10);
|
|
179
|
+
const textMatch = /\bCustom:\s*(\d+)\b/.exec(message);
|
|
180
|
+
if (textMatch)
|
|
181
|
+
return Number.parseInt(textMatch[1], 10);
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Map known Anchor error numbers to a short human label so the
|
|
186
|
+
* `chain_error` hint reads "Custom 3012 (AccountNotInitialized)" rather
|
|
187
|
+
* than just "Custom 3012". Only the codes we see in practice — the
|
|
188
|
+
* Anchor docs list the full table; we name the ones the gate E2E hits.
|
|
189
|
+
*/
|
|
190
|
+
const ANCHOR_ERROR_CODES = {
|
|
191
|
+
3012: "AccountNotInitialized",
|
|
192
|
+
3007: "InstructionFallbackNotFound",
|
|
193
|
+
6000: "(program-defined; see the program's `error.rs`)",
|
|
194
|
+
};
|
|
195
|
+
function formatInstructionErrorHint(message) {
|
|
196
|
+
const code = extractCustomErrorCode(message);
|
|
197
|
+
if (code === undefined) {
|
|
198
|
+
return "On-chain program returned an InstructionError; inspect the cause for the failing instruction index and check the transaction logs on the explorer.";
|
|
199
|
+
}
|
|
200
|
+
const label = ANCHOR_ERROR_CODES[code];
|
|
201
|
+
const suffix = label ? ` (${label})` : "";
|
|
202
|
+
return `On-chain program returned Custom ${code}${suffix}. Inspect the transaction logs on the explorer; the failing constraint or seed mismatch is named in the program's error.rs.`;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Build a hint for a `SendTransactionError` text-shape failure — the
|
|
206
|
+
* web3.js error class thrown by `Connection.simulateTransaction` and
|
|
207
|
+
* `Connection.sendRawTransaction` when the runtime rejects a tx for a
|
|
208
|
+
* reason that didn't come back as an Anchor `Custom NNN` code.
|
|
209
|
+
*
|
|
210
|
+
* The most common diagnostic embedded in the message is "An account
|
|
211
|
+
* required by the instruction is missing" — this is what a CPI-deep
|
|
212
|
+
* call into an unseeded counterparty (e.g. emit_feedback against an
|
|
213
|
+
* agent_asset whose Quantu `agent_account` PDA hasn't been registered)
|
|
214
|
+
* surfaces in practice. Capture that shape with a remediation-specific
|
|
215
|
+
* hint so the LLM doesn't fall back to a generic "check the logs"
|
|
216
|
+
* blurb. See the gate E2E rerun Beat F transcript for the originating
|
|
217
|
+
* sample.
|
|
218
|
+
*/
|
|
219
|
+
function formatSendTransactionErrorHint(message) {
|
|
220
|
+
if (/An account required by the instruction is missing/i.test(message)) {
|
|
221
|
+
return ("Transaction failed because a required account was not in the instruction's account list. " +
|
|
222
|
+
"This usually means a downstream CPI target (e.g. a Quantu agent_account PDA or facilitator authority PDA) " +
|
|
223
|
+
"has not been seeded for this signer / counterparty. Inspect the embedded logs in the cause to identify the " +
|
|
224
|
+
"missing account, then run the matching init / register tool before retrying.");
|
|
225
|
+
}
|
|
226
|
+
return ("Transaction was rejected by the Solana runtime. Inspect the embedded logs in the cause for the failing " +
|
|
227
|
+
"program invoke + the precise runtime error; in a SendTransactionError handler, call `getLogs()` for the full set.");
|
|
228
|
+
}
|
|
229
|
+
function isConfigError(err, name) {
|
|
230
|
+
if (name === "ConfigError")
|
|
231
|
+
return true;
|
|
232
|
+
if (typeof err === "object" && err !== null && "name" in err) {
|
|
233
|
+
return err.name === "ConfigError";
|
|
234
|
+
}
|
|
128
235
|
return false;
|
|
129
236
|
}
|
|
130
237
|
function isRpcFailure(name, message) {
|
|
@@ -190,7 +297,19 @@ function classifyError(err, toolName) {
|
|
|
190
297
|
cause,
|
|
191
298
|
};
|
|
192
299
|
}
|
|
193
|
-
// 2.
|
|
300
|
+
// 2. Config errors — thrown from `chain.ts:guardATProgramId` when an
|
|
301
|
+
// AT-touching tool runs on mainnet without explicit program IDs.
|
|
302
|
+
// Caught before the Anchor branch so the "ConfigError" name is
|
|
303
|
+
// picked up before the message hits any Anchor heuristics.
|
|
304
|
+
if (isConfigError(err, name)) {
|
|
305
|
+
return {
|
|
306
|
+
errorCode: "config_error",
|
|
307
|
+
message: "MCP server is misconfigured for this tool.",
|
|
308
|
+
hint: message,
|
|
309
|
+
cause,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
// 3. Zod schema validation — `instanceof ZodError` works because the
|
|
194
313
|
// server passes the parse error through directly (no wrapping).
|
|
195
314
|
if (err instanceof zod_1.ZodError) {
|
|
196
315
|
return {
|
|
@@ -200,14 +319,33 @@ function classifyError(err, toolName) {
|
|
|
200
319
|
cause: clamp(JSON.stringify(err.issues)),
|
|
201
320
|
};
|
|
202
321
|
}
|
|
203
|
-
//
|
|
322
|
+
// 4. Anchor / on-chain program errors. Includes raw Solana
|
|
323
|
+
// `InstructionError` payloads (e.g. simulation hits an
|
|
324
|
+
// `AccountNotInitialized` Custom 3012 on an unseeded PDA) so the
|
|
325
|
+
// classifier lands them in `chain_error` rather than `internal`.
|
|
326
|
+
// See the gate E2E Beat C polish item in
|
|
327
|
+
// submission/e2e-claude-code-2026-05-13/README.md.
|
|
204
328
|
if (isAnchorError(err, name, message)) {
|
|
329
|
+
const anchorHint = formatAnchorHint(err);
|
|
330
|
+
let fallbackHint;
|
|
331
|
+
if (/InstructionError/.test(message) || /\bCustom\b/.test(message)) {
|
|
332
|
+
fallbackHint = formatInstructionErrorHint(message);
|
|
333
|
+
}
|
|
334
|
+
else if (name === "SendTransactionError" ||
|
|
335
|
+
/SendTransactionError/.test(message) ||
|
|
336
|
+
/Simulation failed\.\s*\nMessage:/i.test(message) ||
|
|
337
|
+
/Transaction simulation failed:/i.test(message)) {
|
|
338
|
+
fallbackHint = formatSendTransactionErrorHint(message);
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
fallbackHint =
|
|
342
|
+
"Inspect the transaction logs on the explorer; the failing constraint or " +
|
|
343
|
+
"custom error code is included in the cause.";
|
|
344
|
+
}
|
|
205
345
|
return {
|
|
206
346
|
errorCode: "chain_error",
|
|
207
347
|
message: "On-chain transaction failed.",
|
|
208
|
-
hint:
|
|
209
|
-
"Inspect the transaction logs on the explorer; the failing constraint or " +
|
|
210
|
-
"custom error code is included in the cause.",
|
|
348
|
+
hint: anchorHint ?? fallbackHint,
|
|
211
349
|
cause,
|
|
212
350
|
};
|
|
213
351
|
}
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;AAiPH,sCAwGC;AAqBD,0CAkBC;AA9XD,6BAA+B;AAmB/B,4EAA4E;AAC5E,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B,gEAAgE;AAChE,SAAS,KAAK,CAAC,CAAS,EAAE,GAAG,GAAG,aAAa;IAC3C,IAAI,CAAC,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,iBAAiB,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,GAAY;IAC/B,IAAI,GAAG,IAAI,IAAI;QAAE,OAAO,iBAAiB,CAAC;IAC1C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IACxC,IAAI,GAAG,YAAY,KAAK;QAAE,OAAO,GAAG,CAAC,OAAO,CAAC;IAC7C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,SAAS,IAAI,GAAG,EAAE,CAAC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HANGED
|
@@ -16,4 +16,31 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
18
18
|
import type { AgentTrustConfig } from "./config";
|
|
19
|
+
/**
|
|
20
|
+
* Recursively rewrite JSON-Schema draft-04 boolean `exclusiveMinimum` /
|
|
21
|
+
* `exclusiveMaximum` to the draft 2020-12 numeric form expected by the
|
|
22
|
+
* Anthropic API.
|
|
23
|
+
*
|
|
24
|
+
* Input (draft-04, what `zod-to-json-schema`'s `openApi3` target emits
|
|
25
|
+
* for `z.number().positive()` / `.gt(N)` / `.negative()` / `.lt(N)`):
|
|
26
|
+
*
|
|
27
|
+
* { type: "integer", exclusiveMinimum: true, minimum: 0 }
|
|
28
|
+
* { type: "integer", exclusiveMaximum: true, maximum: 100 }
|
|
29
|
+
*
|
|
30
|
+
* Output (draft 2020-12, what Anthropic /v1/messages accepts):
|
|
31
|
+
*
|
|
32
|
+
* { type: "integer", exclusiveMinimum: 0 }
|
|
33
|
+
* { type: "integer", exclusiveMaximum: 100 }
|
|
34
|
+
*
|
|
35
|
+
* The `exclusiveMinimum: false` no-op form is also stripped (it means
|
|
36
|
+
* "the regular `minimum` is inclusive" in draft-04 and is meaningless in
|
|
37
|
+
* 2020-12).
|
|
38
|
+
*
|
|
39
|
+
* Walks `properties`, `items`, `oneOf` / `anyOf` / `allOf`, `definitions`,
|
|
40
|
+
* `$defs`, and nested objects so the rewrite catches every schema node
|
|
41
|
+
* regardless of how the tool author composed the Zod expression.
|
|
42
|
+
*
|
|
43
|
+
* Exported for tests in `test/json-schema-output.test.ts`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function rewriteExclusiveBoundsToDraft2020(node: unknown): Record<string, unknown>;
|
|
19
46
|
export declare function createMcpServer(cfg: AgentTrustConfig): Server;
|
package/dist/server.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* Prompts surface the three guided workflows from prompts/ALL_PROMPTS.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.rewriteExclusiveBoundsToDraft2020 = rewriteExclusiveBoundsToDraft2020;
|
|
19
20
|
exports.createMcpServer = createMcpServer;
|
|
20
21
|
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
21
22
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
@@ -39,6 +40,66 @@ const SERVER_INSTRUCTIONS = "AgentTrust MCP server. Read tools work without auth
|
|
|
39
40
|
"README). Resources expose the AgentTrust docs corpus, deployed program " +
|
|
40
41
|
"manifest, and example demo source. Prompts ship three guided workflows: " +
|
|
41
42
|
"audit_payment, setup_agent, explain_failure.";
|
|
43
|
+
/**
|
|
44
|
+
* Recursively rewrite JSON-Schema draft-04 boolean `exclusiveMinimum` /
|
|
45
|
+
* `exclusiveMaximum` to the draft 2020-12 numeric form expected by the
|
|
46
|
+
* Anthropic API.
|
|
47
|
+
*
|
|
48
|
+
* Input (draft-04, what `zod-to-json-schema`'s `openApi3` target emits
|
|
49
|
+
* for `z.number().positive()` / `.gt(N)` / `.negative()` / `.lt(N)`):
|
|
50
|
+
*
|
|
51
|
+
* { type: "integer", exclusiveMinimum: true, minimum: 0 }
|
|
52
|
+
* { type: "integer", exclusiveMaximum: true, maximum: 100 }
|
|
53
|
+
*
|
|
54
|
+
* Output (draft 2020-12, what Anthropic /v1/messages accepts):
|
|
55
|
+
*
|
|
56
|
+
* { type: "integer", exclusiveMinimum: 0 }
|
|
57
|
+
* { type: "integer", exclusiveMaximum: 100 }
|
|
58
|
+
*
|
|
59
|
+
* The `exclusiveMinimum: false` no-op form is also stripped (it means
|
|
60
|
+
* "the regular `minimum` is inclusive" in draft-04 and is meaningless in
|
|
61
|
+
* 2020-12).
|
|
62
|
+
*
|
|
63
|
+
* Walks `properties`, `items`, `oneOf` / `anyOf` / `allOf`, `definitions`,
|
|
64
|
+
* `$defs`, and nested objects so the rewrite catches every schema node
|
|
65
|
+
* regardless of how the tool author composed the Zod expression.
|
|
66
|
+
*
|
|
67
|
+
* Exported for tests in `test/json-schema-output.test.ts`.
|
|
68
|
+
*/
|
|
69
|
+
function rewriteExclusiveBoundsToDraft2020(node) {
|
|
70
|
+
if (!isPlainObject(node))
|
|
71
|
+
return node;
|
|
72
|
+
const out = {};
|
|
73
|
+
for (const [key, value] of Object.entries(node)) {
|
|
74
|
+
out[key] = rewriteValue(value);
|
|
75
|
+
}
|
|
76
|
+
// Fold draft-04 boolean exclusiveMinimum/Maximum into numeric form.
|
|
77
|
+
if (out.exclusiveMinimum === true && typeof out.minimum === "number") {
|
|
78
|
+
out.exclusiveMinimum = out.minimum;
|
|
79
|
+
delete out.minimum;
|
|
80
|
+
}
|
|
81
|
+
else if (out.exclusiveMinimum === false) {
|
|
82
|
+
delete out.exclusiveMinimum;
|
|
83
|
+
}
|
|
84
|
+
if (out.exclusiveMaximum === true && typeof out.maximum === "number") {
|
|
85
|
+
out.exclusiveMaximum = out.maximum;
|
|
86
|
+
delete out.maximum;
|
|
87
|
+
}
|
|
88
|
+
else if (out.exclusiveMaximum === false) {
|
|
89
|
+
delete out.exclusiveMaximum;
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
function rewriteValue(value) {
|
|
94
|
+
if (Array.isArray(value))
|
|
95
|
+
return value.map(rewriteValue);
|
|
96
|
+
if (isPlainObject(value))
|
|
97
|
+
return rewriteExclusiveBoundsToDraft2020(value);
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
100
|
+
function isPlainObject(v) {
|
|
101
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
102
|
+
}
|
|
42
103
|
function createMcpServer(cfg) {
|
|
43
104
|
const chain = new chain_1.ChainClient(cfg);
|
|
44
105
|
const server = new index_js_1.Server({ name: SERVER_NAME, version: SERVER_VERSION }, {
|
|
@@ -46,12 +107,25 @@ function createMcpServer(cfg) {
|
|
|
46
107
|
instructions: SERVER_INSTRUCTIONS,
|
|
47
108
|
});
|
|
48
109
|
// ---- tools/list ---------------------------------------------------------
|
|
110
|
+
// `zodToJsonSchema(..., { target: "openApi3" })` emits the draft-04 boolean
|
|
111
|
+
// form of `exclusiveMinimum` / `exclusiveMaximum` (`{ exclusiveMinimum: true,
|
|
112
|
+
// minimum: 0 }`) when a Zod field uses `.positive()` / `.gt(N)` / `.negative()`.
|
|
113
|
+
// The Anthropic /v1/messages tool-input-schema validator enforces JSON Schema
|
|
114
|
+
// draft 2020-12 where these fields must be numbers, not booleans, and rejects
|
|
115
|
+
// the entire tool array with HTTP 400 otherwise (see the gate E2E report at
|
|
116
|
+
// submission/e2e-claude-code-2026-05-13/README.md, Regression 1). The
|
|
117
|
+
// canonical Zod patterns we use now (`.min(1)` for slot ints) sidestep this,
|
|
118
|
+
// but this post-processor is defence-in-depth so a future `.positive()` in
|
|
119
|
+
// any tool's input schema cannot regress the Anthropic tool-validation path
|
|
120
|
+
// unnoticed.
|
|
49
121
|
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
|
|
50
122
|
tools: tools_1.ALL_TOOLS.map((t) => ({
|
|
51
123
|
name: t.name,
|
|
52
124
|
description: t.description,
|
|
53
125
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
-
inputSchema: (
|
|
126
|
+
inputSchema: rewriteExclusiveBoundsToDraft2020(
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
+
(0, zod_to_json_schema_1.zodToJsonSchema)(t.inputSchema, { target: "openApi3" })),
|
|
55
129
|
})),
|
|
56
130
|
}));
|
|
57
131
|
// ---- tools/call ---------------------------------------------------------
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":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C,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;gBAClC,MAAM,IAAI,KAAK,CAAC,UAAU,MAAM,CAAC,IAAI,+BAA+B,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAChF,CAAC;QACH,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACtC,OAAO;YACL,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,QAAQ;SACT,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -21,7 +21,11 @@ const InputSchema = zod_1.z.object({
|
|
|
21
21
|
capability_hash_hex: common_1.HexHashSchema.optional()
|
|
22
22
|
.describe("Direct 32-byte capability hash (hex); use only if you already have the digest"),
|
|
23
23
|
claim_uri_hash_hex: common_1.HexHashSchema.describe("32-byte hash of the off-chain claim URI"),
|
|
24
|
-
|
|
24
|
+
// Use `.min(1)` rather than `.positive()` so `zodToJsonSchema(..., { target: "openApi3" })`
|
|
25
|
+
// emits `{ "minimum": 1 }` (JSON Schema draft 2020-12 compatible) rather than the
|
|
26
|
+
// draft-04 boolean form `{ "exclusiveMinimum": true, "minimum": 0 }`, which the
|
|
27
|
+
// Anthropic /v1/messages tool validator rejects with HTTP 400.
|
|
28
|
+
deadline_slot: zod_1.z.union([zod_1.z.number().int().min(1), zod_1.z.string().regex(/^\d+$/)])
|
|
25
29
|
.describe("Slot by which an attestor must respond. Must be greater than the " +
|
|
26
30
|
"current Solana slot. Devnet slots advance roughly every 400ms " +
|
|
27
31
|
"(so `current_slot + 60 * 1000 / 400 = current_slot + 150` is " +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-validation.js","sourceRoot":"","sources":["../../../src/tools/write/request-validation.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,6CAA8C;AAC9C,6BAAwB;AAExB,uCAIqB;AACrB,yCAA2C;AA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AkB,EAAE,CAAC;QACrD,MAAM,EAAE,GAAG,MAAM,IAAA,gCAAwB,EAAC;YACxC,OAAO;YACP,SAAS,EAAO,MAAM,CAAC,SAAS;YAChC,YAAY,EAAI,OAAO;YACvB,cAAc,EAAE,OAAO;YACvB,YAAY,EAAI,SAAS;YACzB,YAAY,EAAI,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;SACvD,CAAC,CAAC;QAEH,MAAM,EAAE,GAAG,IAAI,qBAAW,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACrC,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1E,MAAM,UAAU,GAAG,IAAA,kCAA0B,EAC3C,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,SAAS,CAC9E,CAAC;QAEF,OAAO;YACL,WAAW;YACX,aAAa,EAAM,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAO,WAAW,CAAC;YACrE,UAAU,EAAS,UAAU,CAAC,QAAQ,EAAE;YACxC,eAAe,EAAI,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC;YAC/E,iBAAiB,EAAE,IAAA,mBAAU,EAAC,OAAO,CAAC;SACvC,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -25,7 +25,11 @@ const InputSchema = zod_1.z.object({
|
|
|
25
25
|
capability_hash_hex: common_1.HexHashSchema.optional(),
|
|
26
26
|
claim_payload_hash_hex: common_1.HexHashSchema.describe("32-byte hash of the attestor's signed claim payload"),
|
|
27
27
|
claim_uri_hash_hex: common_1.HexHashSchema.describe("32-byte hash of the canonical claim URI"),
|
|
28
|
-
|
|
28
|
+
// Use `.min(1)` rather than `.positive()` so `zodToJsonSchema(..., { target: "openApi3" })`
|
|
29
|
+
// emits `{ "minimum": 1 }` (JSON Schema draft 2020-12 compatible) rather than the
|
|
30
|
+
// draft-04 boolean form `{ "exclusiveMinimum": true, "minimum": 0 }`, which the
|
|
31
|
+
// Anthropic /v1/messages tool validator rejects with HTTP 400.
|
|
32
|
+
expires_at_slot: zod_1.z.union([zod_1.z.number().int().min(1), zod_1.z.string().regex(/^\d+$/)])
|
|
29
33
|
.describe("Attestation expiry slot (0 = never)"),
|
|
30
34
|
});
|
|
31
35
|
exports.respondToValidationTool = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"respond-to-validation.js","sourceRoot":"","sources":["../../../src/tools/write/respond-to-validation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,6CAA8C;AAC9C,6BAAwB;AAExB,uCAMqB;AACrB,yCAA2C;AAC3C,sCAA6F;AAG7F,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,aAAa,EAAS,qBAAY;IAClC,eAAe,EAAO,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC1D,mBAAmB,EAAG,sBAAa,CAAC,QAAQ,EAAE;IAC9C,sBAAsB,EAAE,sBAAa,CAAC,QAAQ,CAAC,qDAAqD,CAAC;IACrG,kBAAkB,EAAI,sBAAa,CAAC,QAAQ,CAAC,yCAAyC,CAAC;IACvF,eAAe,EAAO,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"respond-to-validation.js","sourceRoot":"","sources":["../../../src/tools/write/respond-to-validation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,6CAA8C;AAC9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KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAE1E,MAAM,cAAc,GAAG,IAAA,sCAA8B,EACnD,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,SAAS,CAC9E,CAAC;QACF,MAAM,kBAAkB,GAAG,IAAA,gCAAwB,EACjD,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC,SAAS,CAC5D,CAAC;QAEF,OAAO;YACL,WAAW;YACX,aAAa,EAAS,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAO,WAAW,CAAC;YACxE,cAAc,EAAQ,cAAc,CAAC,QAAQ,EAAE;YAC/C,mBAAmB,EAAG,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,cAAc,CAAC,QAAQ,EAAE,CAAC;YACtF,kBAAkB,EAAI,kBAAkB,CAAC,QAAQ,EAAE;YACnD,iBAAiB,EAAK,IAAA,mBAAU,EAAC,OAAO,CAAC;SAC1C,CAAC;IACJ,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agenttrust-sdk/mcp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "MCP server for AgentTrust — query and call deployed Solana programs from Claude Desktop / Cursor / any MCP client",
|
|
5
5
|
"author": "AgentTrust Labs (https://agenttrust.tech)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"bs58": "^6.0.0",
|
|
48
48
|
"zod": "^3.25.76",
|
|
49
49
|
"zod-to-json-schema": "^3.23.5",
|
|
50
|
-
"@agenttrust-sdk/trustgate": "^0.3.
|
|
50
|
+
"@agenttrust-sdk/trustgate": "^0.3.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/chai": "^4.3.0",
|