@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.
Files changed (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +233 -0
  3. package/dist/chain.d.ts +41 -0
  4. package/dist/chain.js +164 -0
  5. package/dist/chain.js.map +1 -0
  6. package/dist/config.d.ts +35 -0
  7. package/dist/config.js +99 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/idl/policy_vault.json +1723 -0
  10. package/dist/idl/trustgate.json +623 -0
  11. package/dist/idl/validation_registry.json +1052 -0
  12. package/dist/index.d.ts +10 -0
  13. package/dist/index.js +123 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/prompts/audit-payment.d.ts +10 -0
  16. package/dist/prompts/audit-payment.js +55 -0
  17. package/dist/prompts/audit-payment.js.map +1 -0
  18. package/dist/prompts/explain-failure.d.ts +7 -0
  19. package/dist/prompts/explain-failure.js +57 -0
  20. package/dist/prompts/explain-failure.js.map +1 -0
  21. package/dist/prompts/index.d.ts +3 -0
  22. package/dist/prompts/index.js +12 -0
  23. package/dist/prompts/index.js.map +1 -0
  24. package/dist/prompts/setup-agent.d.ts +6 -0
  25. package/dist/prompts/setup-agent.js +43 -0
  26. package/dist/prompts/setup-agent.js.map +1 -0
  27. package/dist/prompts/types.d.ts +23 -0
  28. package/dist/prompts/types.js +6 -0
  29. package/dist/prompts/types.js.map +1 -0
  30. package/dist/resources/docs.d.ts +23 -0
  31. package/dist/resources/docs.js +147 -0
  32. package/dist/resources/docs.js.map +1 -0
  33. package/dist/resources/programs.d.ts +14 -0
  34. package/dist/resources/programs.js +69 -0
  35. package/dist/resources/programs.js.map +1 -0
  36. package/dist/server.d.ts +19 -0
  37. package/dist/server.js +136 -0
  38. package/dist/server.js.map +1 -0
  39. package/dist/tools/common.d.ts +18 -0
  40. package/dist/tools/common.js +77 -0
  41. package/dist/tools/common.js.map +1 -0
  42. package/dist/tools/discovery/docs.d.ts +48 -0
  43. package/dist/tools/discovery/docs.js +200 -0
  44. package/dist/tools/discovery/docs.js.map +1 -0
  45. package/dist/tools/discovery/explain-decision.d.ts +28 -0
  46. package/dist/tools/discovery/explain-decision.js +144 -0
  47. package/dist/tools/discovery/explain-decision.js.map +1 -0
  48. package/dist/tools/discovery/facilitator-walkthrough.d.ts +30 -0
  49. package/dist/tools/discovery/facilitator-walkthrough.js +117 -0
  50. package/dist/tools/discovery/facilitator-walkthrough.js.map +1 -0
  51. package/dist/tools/index.d.ts +9 -0
  52. package/dist/tools/index.js +55 -0
  53. package/dist/tools/index.js.map +1 -0
  54. package/dist/tools/read/demo-state.d.ts +48 -0
  55. package/dist/tools/read/demo-state.js +129 -0
  56. package/dist/tools/read/demo-state.js.map +1 -0
  57. package/dist/tools/read/get-feedback-log.d.ts +28 -0
  58. package/dist/tools/read/get-feedback-log.js +51 -0
  59. package/dist/tools/read/get-feedback-log.js.map +1 -0
  60. package/dist/tools/read/get-killswitch.d.ts +38 -0
  61. package/dist/tools/read/get-killswitch.js +63 -0
  62. package/dist/tools/read/get-killswitch.js.map +1 -0
  63. package/dist/tools/read/get-policy.d.ts +51 -0
  64. package/dist/tools/read/get-policy.js +71 -0
  65. package/dist/tools/read/get-policy.js.map +1 -0
  66. package/dist/tools/read/get-quantu-reputation.d.ts +39 -0
  67. package/dist/tools/read/get-quantu-reputation.js +65 -0
  68. package/dist/tools/read/get-quantu-reputation.js.map +1 -0
  69. package/dist/tools/read/get-validation-attestation.d.ts +45 -0
  70. package/dist/tools/read/get-validation-attestation.js +76 -0
  71. package/dist/tools/read/get-validation-attestation.js.map +1 -0
  72. package/dist/tools/read/get-velocity.d.ts +31 -0
  73. package/dist/tools/read/get-velocity.js +50 -0
  74. package/dist/tools/read/get-velocity.js.map +1 -0
  75. package/dist/tools/read/list-facilitators.d.ts +31 -0
  76. package/dist/tools/read/list-facilitators.js +60 -0
  77. package/dist/tools/read/list-facilitators.js.map +1 -0
  78. package/dist/tools/read/list-policies.d.ts +33 -0
  79. package/dist/tools/read/list-policies.js +49 -0
  80. package/dist/tools/read/list-policies.js.map +1 -0
  81. package/dist/tools/read/simulate-payment.d.ts +44 -0
  82. package/dist/tools/read/simulate-payment.js +54 -0
  83. package/dist/tools/read/simulate-payment.js.map +1 -0
  84. package/dist/tools/types.d.ts +31 -0
  85. package/dist/tools/types.js +12 -0
  86. package/dist/tools/types.js.map +1 -0
  87. package/dist/tools/write/emit-feedback.d.ts +55 -0
  88. package/dist/tools/write/emit-feedback.js +83 -0
  89. package/dist/tools/write/emit-feedback.js.map +1 -0
  90. package/dist/tools/write/init-policy.d.ts +133 -0
  91. package/dist/tools/write/init-policy.js +124 -0
  92. package/dist/tools/write/init-policy.js.map +1 -0
  93. package/dist/tools/write/request-validation.d.ts +39 -0
  94. package/dist/tools/write/request-validation.js +69 -0
  95. package/dist/tools/write/request-validation.js.map +1 -0
  96. package/dist/tools/write/respond-to-validation.d.ts +47 -0
  97. package/dist/tools/write/respond-to-validation.js +81 -0
  98. package/dist/tools/write/respond-to-validation.js.map +1 -0
  99. package/dist/tools/write/set-killswitch.d.ts +34 -0
  100. package/dist/tools/write/set-killswitch.js +70 -0
  101. package/dist/tools/write/set-killswitch.js.map +1 -0
  102. package/package.json +72 -0
  103. package/scripts/install-claude-desktop.sh +72 -0
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ /**
3
+ * `agenttrust_init_policy` — initialise a PolicyAccount + VelocityLedger
4
+ * for the caller's `(agent_asset, policy_id)` pair. Requires the
5
+ * PolicyAuthority to already exist with the signer as a member; this
6
+ * tool surfaces a clear error pointing at `init_authority` if not.
7
+ *
8
+ * The full per-kind config is exposed as JSON; sane defaults zero every
9
+ * field so callers can incrementally enable kinds via the bitmask.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.initPolicyTool = void 0;
13
+ const anchor_1 = require("@coral-xyz/anchor");
14
+ const web3_js_1 = require("@solana/web3.js");
15
+ const zod_1 = require("zod");
16
+ const chain_1 = require("../../chain");
17
+ const config_1 = require("../../config");
18
+ const common_1 = require("../common");
19
+ const POLICY_AUTHORITY_PREFIX = Buffer.from("policy_authority");
20
+ const SpendingSchema = zod_1.z.object({
21
+ per_tx_max: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(0),
22
+ daily_max: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(0),
23
+ weekly_max: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(0),
24
+ }).default({ per_tx_max: 0, daily_max: 0, weekly_max: 0 });
25
+ const VelocitySchema = zod_1.z.object({
26
+ window_secs: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(0),
27
+ max_in_window: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(0),
28
+ tier0_decay_factor: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(10000),
29
+ }).default({ window_secs: 0, max_in_window: 0, tier0_decay_factor: 10000 });
30
+ const CounterpartySchema = zod_1.z.object({
31
+ min_tier: zod_1.z.number().int().min(0).max(4).default(0),
32
+ max_risk_score: zod_1.z.number().int().min(0).max(255).default(255),
33
+ min_confidence: zod_1.z.number().int().min(0).max(10000).default(0),
34
+ default_unrated_treatment: zod_1.z.number().int().min(0).max(2).default(0),
35
+ }).default({ min_tier: 0, max_risk_score: 255, min_confidence: 0, default_unrated_treatment: 0 });
36
+ const ValidationSchema = zod_1.z.object({
37
+ required_capability_hash_hex: common_1.HexHashSchema.optional(),
38
+ accepted_attestors: zod_1.z.array(common_1.PubkeySchema).max(2).default([]),
39
+ }).default({ accepted_attestors: [] });
40
+ const InputSchema = zod_1.z.object({
41
+ agent_asset: common_1.PubkeySchema.describe("Quantu agent asset (must equal a member of the agent's PolicyAuthority)"),
42
+ policy_id: zod_1.z.number().int().min(0).max(0xffffffff),
43
+ enabled_kinds_bitmask: zod_1.z.number().int().min(0).max(255).describe("OR of KIND_* flags: 1=KillSwitch 2=Spending 4=Velocity 8=CounterpartyTier 16=RequireValidation"),
44
+ gate_mode: zod_1.z.number().int().min(0).max(1).default(0).describe("0=Immediate, 1=Confirmed"),
45
+ scope_kind: zod_1.z.number().int().min(0).max(2).default(2).describe("0=Global 1=PerCollection 2=PerAgent"),
46
+ spending: SpendingSchema,
47
+ velocity: VelocitySchema,
48
+ counterparty: CounterpartySchema,
49
+ validation: ValidationSchema,
50
+ });
51
+ const ZERO_PUBKEY = new web3_js_1.PublicKey(new Uint8Array(32));
52
+ exports.initPolicyTool = {
53
+ name: "agenttrust_init_policy",
54
+ description: "Create a PolicyAccount + VelocityLedger PDA for the caller's agent. " +
55
+ "Requires KEYPAIR_B58 (the signer must be a member of the agent's " +
56
+ "PolicyAuthority). Returns the tx signature plus Explorer URLs for " +
57
+ "both new PDAs.",
58
+ inputSchema: InputSchema,
59
+ async handler(input, ctx) {
60
+ const signer = ctx.chain.requireSigner();
61
+ const agent = (0, common_1.parsePubkey)(input.agent_asset, "agent_asset");
62
+ const policyVault = await ctx.chain.policyVault();
63
+ const policyPda = (0, chain_1.derivePolicyPda)(ctx.chain.cfg.programs.policyVault, agent, input.policy_id);
64
+ const velocityPda = (0, chain_1.deriveVelocityPda)(ctx.chain.cfg.programs.policyVault, agent, input.policy_id);
65
+ const authorityPda = web3_js_1.PublicKey.findProgramAddressSync([POLICY_AUTHORITY_PREFIX, agent.toBuffer()], ctx.chain.cfg.programs.policyVault)[0];
66
+ const validationHash = input.validation.required_capability_hash_hex
67
+ ? Array.from((0, common_1.hexToBytes)(input.validation.required_capability_hash_hex))
68
+ : Array.from(new Uint8Array(32));
69
+ const acceptedAttestors = [
70
+ input.validation.accepted_attestors[0]
71
+ ? (0, common_1.parsePubkey)(input.validation.accepted_attestors[0], "validation.accepted_attestors[0]")
72
+ : ZERO_PUBKEY,
73
+ input.validation.accepted_attestors[1]
74
+ ? (0, common_1.parsePubkey)(input.validation.accepted_attestors[1], "validation.accepted_attestors[1]")
75
+ : ZERO_PUBKEY,
76
+ ];
77
+ const args = {
78
+ policyId: input.policy_id,
79
+ enabledKindsBitmask: input.enabled_kinds_bitmask,
80
+ gateMode: input.gate_mode,
81
+ scopeKind: input.scope_kind,
82
+ spending: {
83
+ perTxMax: new anchor_1.BN(input.spending.per_tx_max.toString()),
84
+ dailyMax: new anchor_1.BN(input.spending.daily_max.toString()),
85
+ weeklyMax: new anchor_1.BN(input.spending.weekly_max.toString()),
86
+ },
87
+ velocity: {
88
+ windowSecs: new anchor_1.BN(input.velocity.window_secs.toString()),
89
+ maxInWindow: new anchor_1.BN(input.velocity.max_in_window.toString()),
90
+ tier0DecayFactor: new anchor_1.BN(input.velocity.tier0_decay_factor.toString()),
91
+ },
92
+ counterparty: {
93
+ minTier: input.counterparty.min_tier,
94
+ maxRiskScore: input.counterparty.max_risk_score,
95
+ minConfidence: input.counterparty.min_confidence,
96
+ defaultUnratedTreatment: input.counterparty.default_unrated_treatment,
97
+ },
98
+ validation: {
99
+ requiredCapabilityHash: validationHash,
100
+ acceptedAttestors,
101
+ },
102
+ };
103
+ const txSignature = await policyVault.methods
104
+ .initPolicy(agent, args)
105
+ .accounts({
106
+ payer: signer.publicKey,
107
+ policyAuthority: authorityPda,
108
+ policyAccount: policyPda,
109
+ velocityLedger: velocityPda,
110
+ systemProgram: web3_js_1.SystemProgram.programId,
111
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
+ })
113
+ .rpc();
114
+ return {
115
+ txSignature,
116
+ explorerTxUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "tx", txSignature),
117
+ policyPda: policyPda.toBase58(),
118
+ policyExplorer: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", policyPda.toBase58()),
119
+ velocityPda: velocityPda.toBase58(),
120
+ velocityExplorer: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", velocityPda.toBase58()),
121
+ };
122
+ },
123
+ };
124
+ //# sourceMappingURL=init-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-policy.js","sourceRoot":"","sources":["../../../src/tools/write/init-policy.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,8CAAuC;AACvC,6CAA2D;AAC3D,6BAAwB;AAExB,uCAAiE;AACjE,yCAA2C;AAC3C,sCAAiF;AAGjF,MAAM,uBAAuB,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;AAEhE,MAAM,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9B,UAAU,EAAG,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5F,SAAS,EAAI,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5F,UAAU,EAAG,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;CAC7F,CAAC,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;AAE3D,MAAM,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9B,WAAW,EAAS,OAAC,CAAC,K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G,EAAE,SAAS,EAAE,WAAW,CAAC,QAAQ,EAAE,CAAC;SAChF,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * `agenttrust_request_validation` — open a ValidationRequest PDA,
3
+ * inviting attestors to attest to `(subject_asset, capability_hash)`
4
+ * by `deadline_slot`.
5
+ *
6
+ * Composes via `buildRequestValidationIx` in the SDK so the on-chain
7
+ * account list + arg encoding stays the canonical source of truth.
8
+ */
9
+ import { z } from "zod";
10
+ import type { Tool } from "../types";
11
+ declare const InputSchema: z.ZodObject<{
12
+ subject_asset: z.ZodEffects<z.ZodString, string, string>;
13
+ capability_name: z.ZodOptional<z.ZodString>;
14
+ capability_hash_hex: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
15
+ claim_uri_hash_hex: z.ZodEffects<z.ZodString, string, string>;
16
+ deadline_slot: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
17
+ }, "strip", z.ZodTypeAny, {
18
+ subject_asset: string;
19
+ claim_uri_hash_hex: string;
20
+ deadline_slot: string | number;
21
+ capability_name?: string | undefined;
22
+ capability_hash_hex?: string | undefined;
23
+ }, {
24
+ subject_asset: string;
25
+ claim_uri_hash_hex: string;
26
+ deadline_slot: string | number;
27
+ capability_name?: string | undefined;
28
+ capability_hash_hex?: string | undefined;
29
+ }>;
30
+ type Input = z.infer<typeof InputSchema>;
31
+ interface Output {
32
+ txSignature: string;
33
+ explorerTxUrl: string;
34
+ requestPda: string;
35
+ requestExplorer: string;
36
+ capabilityHashHex: string;
37
+ }
38
+ export declare const requestValidationTool: Tool<Input, Output>;
39
+ export {};
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ /**
3
+ * `agenttrust_request_validation` — open a ValidationRequest PDA,
4
+ * inviting attestors to attest to `(subject_asset, capability_hash)`
5
+ * by `deadline_slot`.
6
+ *
7
+ * Composes via `buildRequestValidationIx` in the SDK so the on-chain
8
+ * account list + arg encoding stays the canonical source of truth.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.requestValidationTool = void 0;
12
+ const web3_js_1 = require("@solana/web3.js");
13
+ const zod_1 = require("zod");
14
+ const chain_1 = require("../../chain");
15
+ const config_1 = require("../../config");
16
+ const common_1 = require("../common");
17
+ const InputSchema = zod_1.z.object({
18
+ subject_asset: common_1.PubkeySchema.describe("Quantu agent asset whose capability is being attested"),
19
+ capability_name: zod_1.z.string().min(3).max(32).optional()
20
+ .describe("Canonical capability name (3..=32 chars, no ':'); preferred over hex"),
21
+ capability_hash_hex: common_1.HexHashSchema.optional()
22
+ .describe("Direct 32-byte capability hash (hex); use only if you already have the digest"),
23
+ claim_uri_hash_hex: common_1.HexHashSchema.describe("32-byte hash of the off-chain claim URI"),
24
+ deadline_slot: zod_1.z.union([zod_1.z.number().int().positive(), zod_1.z.string().regex(/^\d+$/)])
25
+ .describe("Slot by which an attestor must respond"),
26
+ });
27
+ exports.requestValidationTool = {
28
+ name: "agenttrust_request_validation",
29
+ description: "Open a ValidationRequest PDA inviting attestors to attest to a " +
30
+ "subject's capability. Pass either capability_name (preferred — the SDK " +
31
+ "computes SHA256(name) and stamps it as the hash) or capability_hash_hex " +
32
+ "directly. Requires KEYPAIR_B58. Returns the request PDA's Explorer URL.",
33
+ inputSchema: InputSchema,
34
+ async handler(input, ctx) {
35
+ const signer = ctx.chain.requireSigner();
36
+ const subject = (0, common_1.parsePubkey)(input.subject_asset, "subject_asset");
37
+ if (!input.capability_name && !input.capability_hash_hex) {
38
+ throw new Error("Provide either capability_name or capability_hash_hex.");
39
+ }
40
+ const capHash = input.capability_name
41
+ ? (0, chain_1.computeCapabilityHash)(input.capability_name)
42
+ : (0, common_1.hexToBytes)(input.capability_hash_hex);
43
+ if (capHash.length !== 32)
44
+ throw new Error("capability_hash must be 32 bytes");
45
+ const claimHash = (0, common_1.hexToBytes)(input.claim_uri_hash_hex);
46
+ if (claimHash.length !== 32)
47
+ throw new Error("claim_uri_hash must decode to 32 bytes");
48
+ const program = await ctx.chain.validationRegistry();
49
+ const ix = await (0, chain_1.buildRequestValidationIx)({
50
+ program,
51
+ requester: signer.publicKey,
52
+ subjectAsset: subject,
53
+ capabilityHash: capHash,
54
+ claimUriHash: claimHash,
55
+ deadlineSlot: BigInt(input.deadline_slot.toString()),
56
+ });
57
+ const tx = new web3_js_1.Transaction().add(ix);
58
+ const txSignature = await ctx.chain.provider.sendAndConfirm(tx, [signer]);
59
+ const requestPda = (0, chain_1.deriveValidationRequestPda)(ctx.chain.cfg.validationRegistryId, subject, capHash, signer.publicKey);
60
+ return {
61
+ txSignature,
62
+ explorerTxUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "tx", txSignature),
63
+ requestPda: requestPda.toBase58(),
64
+ requestExplorer: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", requestPda.toBase58()),
65
+ capabilityHashHex: (0, common_1.bytesToHex)(capHash),
66
+ };
67
+ },
68
+ };
69
+ //# sourceMappingURL=request-validation.js.map
@@ -0,0 +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;AAC3C,sCAA6F;AAG7F,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,aAAa,EAAS,qBAAY,CAAC,QAAQ,CAAC,uDAAuD,CAAC;IACpG,eAAe,EAAO,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;SACjC,QAAQ,CAAC,sEAAsE,CAAC;IACzG,mBAAmB,EAAG,sBAAa,CAAC,QAAQ,EAAE;SACrB,QAAQ,CAAC,+EAA+E,CAAC;IAClH,kBAAkB,EAAI,sBAAa,CAAC,QAAQ,CAAC,yCAAyC,CAAC;IACvF,aAAa,EAAS,OAAC,CAAC,K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E,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,oBAAoB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,SAAS,CACvE,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"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * `agenttrust_respond_to_validation` — an attestor responds to an open
3
+ * `ValidationRequest` by writing a `ValidationAttestation` PDA.
4
+ *
5
+ * Composes via the SDK's `buildRespondToValidationIx` so the same
6
+ * builder the attestor-demo uses runs through the MCP path. The signer
7
+ * must be the attestor (matches `attestor_profile.attestor`).
8
+ *
9
+ * If the attestor profile doesn't exist yet, this tool surfaces a clear
10
+ * error pointing at the planned `register_attestor` flow — the
11
+ * attestor-demo's bootstrap script is the source-of-truth lifecycle.
12
+ */
13
+ import { z } from "zod";
14
+ import type { Tool } from "../types";
15
+ declare const InputSchema: z.ZodObject<{
16
+ subject_asset: z.ZodEffects<z.ZodString, string, string>;
17
+ capability_name: z.ZodOptional<z.ZodString>;
18
+ capability_hash_hex: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
19
+ claim_payload_hash_hex: z.ZodEffects<z.ZodString, string, string>;
20
+ claim_uri_hash_hex: z.ZodEffects<z.ZodString, string, string>;
21
+ expires_at_slot: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
22
+ }, "strip", z.ZodTypeAny, {
23
+ subject_asset: string;
24
+ claim_uri_hash_hex: string;
25
+ claim_payload_hash_hex: string;
26
+ expires_at_slot: string | number;
27
+ capability_name?: string | undefined;
28
+ capability_hash_hex?: string | undefined;
29
+ }, {
30
+ subject_asset: string;
31
+ claim_uri_hash_hex: string;
32
+ claim_payload_hash_hex: string;
33
+ expires_at_slot: string | number;
34
+ capability_name?: string | undefined;
35
+ capability_hash_hex?: string | undefined;
36
+ }>;
37
+ type Input = z.infer<typeof InputSchema>;
38
+ interface Output {
39
+ txSignature: string;
40
+ explorerTxUrl: string;
41
+ attestationPda: string;
42
+ attestationExplorer: string;
43
+ attestorProfilePda: string;
44
+ capabilityHashHex: string;
45
+ }
46
+ export declare const respondToValidationTool: Tool<Input, Output>;
47
+ export {};
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ /**
3
+ * `agenttrust_respond_to_validation` — an attestor responds to an open
4
+ * `ValidationRequest` by writing a `ValidationAttestation` PDA.
5
+ *
6
+ * Composes via the SDK's `buildRespondToValidationIx` so the same
7
+ * builder the attestor-demo uses runs through the MCP path. The signer
8
+ * must be the attestor (matches `attestor_profile.attestor`).
9
+ *
10
+ * If the attestor profile doesn't exist yet, this tool surfaces a clear
11
+ * error pointing at the planned `register_attestor` flow — the
12
+ * attestor-demo's bootstrap script is the source-of-truth lifecycle.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.respondToValidationTool = void 0;
16
+ const web3_js_1 = require("@solana/web3.js");
17
+ const zod_1 = require("zod");
18
+ const chain_1 = require("../../chain");
19
+ const config_1 = require("../../config");
20
+ const common_1 = require("../common");
21
+ const InputSchema = zod_1.z.object({
22
+ subject_asset: common_1.PubkeySchema,
23
+ capability_name: zod_1.z.string().min(3).max(32).optional(),
24
+ capability_hash_hex: common_1.HexHashSchema.optional(),
25
+ claim_payload_hash_hex: common_1.HexHashSchema.describe("32-byte hash of the attestor's signed claim payload"),
26
+ claim_uri_hash_hex: common_1.HexHashSchema.describe("32-byte hash of the canonical claim URI"),
27
+ expires_at_slot: zod_1.z.union([zod_1.z.number().int().positive(), zod_1.z.string().regex(/^\d+$/)])
28
+ .describe("Attestation expiry slot (0 = never)"),
29
+ });
30
+ exports.respondToValidationTool = {
31
+ name: "agenttrust_respond_to_validation",
32
+ description: "Attestor responds to a ValidationRequest by creating a " +
33
+ "ValidationAttestation PDA. Requires KEYPAIR_B58 (must equal the " +
34
+ "attestor pubkey registered in AttestorProfile). Surfaces the " +
35
+ "attestation PDA + Explorer URL for downstream PolicyVault " +
36
+ "RequireValidation reads.",
37
+ inputSchema: InputSchema,
38
+ async handler(input, ctx) {
39
+ const signer = ctx.chain.requireSigner();
40
+ const subject = (0, common_1.parsePubkey)(input.subject_asset, "subject_asset");
41
+ if (!input.capability_name && !input.capability_hash_hex) {
42
+ throw new Error("Provide either capability_name or capability_hash_hex.");
43
+ }
44
+ const capHash = input.capability_name
45
+ ? (0, chain_1.computeCapabilityHash)(input.capability_name)
46
+ : (0, common_1.hexToBytes)(input.capability_hash_hex);
47
+ if (capHash.length !== 32)
48
+ throw new Error("capability_hash must be 32 bytes");
49
+ const claimPayloadHash = (0, common_1.hexToBytes)(input.claim_payload_hash_hex);
50
+ const claimUriHash = (0, common_1.hexToBytes)(input.claim_uri_hash_hex);
51
+ const program = await ctx.chain.validationRegistry();
52
+ const profile = await (0, chain_1.fetchAttestorProfile)(program, signer.publicKey);
53
+ if (!profile.data) {
54
+ throw new Error(`AttestorProfile not initialised for signer ${signer.publicKey.toBase58()}. ` +
55
+ `Run the attestor-demo bootstrap (or register_attestor instruction) first.`);
56
+ }
57
+ const ix = await (0, chain_1.buildRespondToValidationIx)({
58
+ program,
59
+ payer: signer.publicKey,
60
+ attestor: signer.publicKey,
61
+ subjectAsset: subject,
62
+ capabilityHash: capHash,
63
+ claimPayloadHash,
64
+ claimUriHash,
65
+ expiresAtSlot: BigInt(input.expires_at_slot.toString()),
66
+ });
67
+ const tx = new web3_js_1.Transaction().add(ix);
68
+ const txSignature = await ctx.chain.provider.sendAndConfirm(tx, [signer]);
69
+ const attestationPda = (0, chain_1.deriveValidationAttestationPda)(ctx.chain.cfg.validationRegistryId, subject, capHash, signer.publicKey);
70
+ const attestorProfilePda = (0, chain_1.deriveAttestorProfilePda)(ctx.chain.cfg.validationRegistryId, signer.publicKey);
71
+ return {
72
+ txSignature,
73
+ explorerTxUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "tx", txSignature),
74
+ attestationPda: attestationPda.toBase58(),
75
+ attestationExplorer: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", attestationPda.toBase58()),
76
+ attestorProfilePda: attestorProfilePda.toBase58(),
77
+ capabilityHashHex: (0, common_1.bytesToHex)(capHash),
78
+ };
79
+ },
80
+ };
81
+ //# sourceMappingURL=respond-to-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"respond-to-validation.js","sourceRoot":"","sources":["../../../src/tools/write/respond-to-validation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;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,CA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gCAAwB,EACjD,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,SAAS,CACrD,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"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * `agenttrust_set_killswitch` — flip the per-agent KillSwitchState pause
3
+ * bit. Multisig-gated: the signer (lead) plus optional additional
4
+ * signers in `remainingAccounts` must reach the PolicyAuthority's
5
+ * threshold count.
6
+ *
7
+ * v1 ships the lead-signer-only happy path; thresholds > 1 require the
8
+ * caller to assemble the multisig out-of-band and pass cosigner pubkeys
9
+ * via `cosigner_pubkeys` (each must be available in the local keypair
10
+ * env to actually sign — the tool currently supports lead-only and
11
+ * surfaces a clear error if more signers are needed).
12
+ */
13
+ import { z } from "zod";
14
+ import type { Tool } from "../types";
15
+ declare const InputSchema: z.ZodObject<{
16
+ agent_asset: z.ZodEffects<z.ZodString, string, string>;
17
+ paused: z.ZodBoolean;
18
+ }, "strip", z.ZodTypeAny, {
19
+ agent_asset: string;
20
+ paused: boolean;
21
+ }, {
22
+ agent_asset: string;
23
+ paused: boolean;
24
+ }>;
25
+ type Input = z.infer<typeof InputSchema>;
26
+ interface Output {
27
+ txSignature: string;
28
+ explorerTxUrl: string;
29
+ killSwitchPda: string;
30
+ killSwitchExplorer: string;
31
+ paused: boolean;
32
+ }
33
+ export declare const setKillswitchTool: Tool<Input, Output>;
34
+ export {};
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /**
3
+ * `agenttrust_set_killswitch` — flip the per-agent KillSwitchState pause
4
+ * bit. Multisig-gated: the signer (lead) plus optional additional
5
+ * signers in `remainingAccounts` must reach the PolicyAuthority's
6
+ * threshold count.
7
+ *
8
+ * v1 ships the lead-signer-only happy path; thresholds > 1 require the
9
+ * caller to assemble the multisig out-of-band and pass cosigner pubkeys
10
+ * via `cosigner_pubkeys` (each must be available in the local keypair
11
+ * env to actually sign — the tool currently supports lead-only and
12
+ * surfaces a clear error if more signers are needed).
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.setKillswitchTool = void 0;
16
+ const web3_js_1 = require("@solana/web3.js");
17
+ const zod_1 = require("zod");
18
+ const chain_1 = require("../../chain");
19
+ const config_1 = require("../../config");
20
+ const common_1 = require("../common");
21
+ const POLICY_AUTHORITY_PREFIX = Buffer.from("policy_authority");
22
+ const InputSchema = zod_1.z.object({
23
+ agent_asset: common_1.PubkeySchema.describe("Quantu agent asset"),
24
+ paused: zod_1.z.boolean().describe("true to pause, false to unpause"),
25
+ });
26
+ exports.setKillswitchTool = {
27
+ name: "agenttrust_set_killswitch",
28
+ description: "Pause or unpause an agent's KillSwitchState. Requires KEYPAIR_B58 to " +
29
+ "be the lead signer (a member of the agent's PolicyAuthority). When the " +
30
+ "authority's threshold > 1 the call needs additional cosigners; this " +
31
+ "tool currently only supports lead-only multisigs (threshold=1).",
32
+ inputSchema: InputSchema,
33
+ async handler(input, ctx) {
34
+ const signer = ctx.chain.requireSigner();
35
+ const agent = (0, common_1.parsePubkey)(input.agent_asset, "agent_asset");
36
+ const policy = await ctx.chain.policyVault();
37
+ const ksPda = (0, chain_1.deriveKillSwitchPda)(ctx.chain.cfg.programs.policyVault, agent);
38
+ const authPda = web3_js_1.PublicKey.findProgramAddressSync([POLICY_AUTHORITY_PREFIX, agent.toBuffer()], ctx.chain.cfg.programs.policyVault)[0];
39
+ // Friendly preflight: confirm the authority threshold is satisfiable
40
+ // by the lead signer alone.
41
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
+ const auth = await policy.account.policyAuthority.fetchNullable(authPda);
43
+ if (!auth) {
44
+ throw new Error(`PolicyAuthority not initialised for ${agent.toBase58()}. Call ` +
45
+ `init_authority before set_killswitch.`);
46
+ }
47
+ const threshold = Number(auth.threshold ?? 0);
48
+ if (threshold > 1) {
49
+ throw new Error(`PolicyAuthority threshold is ${threshold}; this tool only supports ` +
50
+ `lead-only signing (threshold=1). Cosigner support is roadmap.`);
51
+ }
52
+ const txSignature = await policy.methods
53
+ .setKillswitch(agent, input.paused)
54
+ .accounts({
55
+ signer: signer.publicKey,
56
+ policyAuthority: authPda,
57
+ killSwitchState: ksPda,
58
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
+ })
60
+ .rpc();
61
+ return {
62
+ txSignature,
63
+ explorerTxUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "tx", txSignature),
64
+ killSwitchPda: ksPda.toBase58(),
65
+ killSwitchExplorer: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", ksPda.toBase58()),
66
+ paused: input.paused,
67
+ };
68
+ },
69
+ };
70
+ //# sourceMappingURL=set-killswitch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-killswitch.js","sourceRoot":"","sources":["../../../src/tools/write/set-killswitch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAEH,6CAA4C;AAC5C,6BAAwB;AAExB,uCAAkD;AAClD,yCAA2C;AAC3C,sCAAsD;AAGtD,MAAM,uBAAuB,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;AAEhE,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,qBAAY,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IACxD,MAAM,EAAO,OAAC,CAAC,OAAO,EAAE,CA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CAAgC,SAAS,4BAA4B;gBACrE,+DAA+D,CAChE,CAAC;QACJ,CAAC;QAED,MAAM,WAAW,GAAW,MAAM,MAAM,CAAC,OAAO;aAC7C,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC;aAClC,QAAQ,CAAC;YACR,MAAM,EAAY,MAAM,CAAC,SAAS;YAClC,eAAe,EAAG,OAAO;YACzB,eAAe,EAAG,KAAK;YACvB,8DAA8D;SACxD,CAAC;aACR,GAAG,EAAE,CAAC;QAET,OAAO;YACL,WAAW;YACX,aAAa,EAAO,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAO,WAAW,CAAC;YACtE,aAAa,EAAO,KAAK,CAAC,QAAQ,EAAE;YACpC,kBAAkB,EAAE,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;YAC3E,MAAM,EAAc,KAAK,CAAC,MAAM;SACjC,CAAC;IACJ,CAAC;CACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@agenttrust-sdk/mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP server for AgentTrust — query and call deployed Solana programs from Claude Desktop / Cursor / any MCP client",
5
+ "author": "AgentTrust Labs (https://agenttrust.tech)",
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/agenttrust-labs/agenttrust/tree/main/mcp#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/agenttrust-labs/agenttrust.git",
11
+ "directory": "mcp"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/agenttrust-labs/agenttrust/issues"
15
+ },
16
+ "keywords": [
17
+ "mcp",
18
+ "model-context-protocol",
19
+ "agenttrust",
20
+ "solana",
21
+ "claude-desktop",
22
+ "cursor",
23
+ "x402",
24
+ "agent-payments"
25
+ ],
26
+ "main": "dist/index.js",
27
+ "types": "dist/index.d.ts",
28
+ "bin": {
29
+ "agenttrust-mcp": "dist/index.js"
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "scripts/install-claude-desktop.sh",
34
+ "README.md",
35
+ "LICENSE"
36
+ ],
37
+ "engines": {
38
+ "node": ">=20"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "dependencies": {
44
+ "@coral-xyz/anchor": "^0.31.1",
45
+ "@modelcontextprotocol/sdk": "^1.29.0",
46
+ "@solana/web3.js": "^1.98.0",
47
+ "bs58": "^6.0.0",
48
+ "zod": "^3.25.76",
49
+ "zod-to-json-schema": "^3.23.5",
50
+ "@agenttrust-sdk/trustgate": "0.1.1"
51
+ },
52
+ "devDependencies": {
53
+ "@types/chai": "^4.3.0",
54
+ "@types/mocha": "^9.0.0",
55
+ "@types/node": "^20.0.0",
56
+ "chai": "^4.3.4",
57
+ "mocha": "^9.0.3",
58
+ "ts-mocha": "^10.0.0",
59
+ "ts-node": "^10.9.2",
60
+ "typescript": "^5.6.0"
61
+ },
62
+ "scripts": {
63
+ "build": "tsc && node -e \"const fs=require('fs');const path=require('path');const src=path.resolve('src/idl');const dst=path.resolve('dist/idl');fs.mkdirSync(dst,{recursive:true});for(const f of fs.readdirSync(src))if(f.endsWith('.json'))fs.copyFileSync(path.join(src,f),path.join(dst,f));\"",
64
+ "lint": "tsc --noEmit",
65
+ "start": "node dist/index.js",
66
+ "dev": "ts-node src/index.ts",
67
+ "test": "ts-mocha -p ./test/tsconfig.json -t 30000 \"test/**/*.test.ts\"",
68
+ "test:integration": "INTEGRATION=1 ts-mocha -p ./test/tsconfig.json -t 60000 test/integration.test.ts",
69
+ "test:conformance": "pnpm run build && ts-node test/protocol-conformance.ts",
70
+ "publish:dry": "npm publish --dry-run"
71
+ }
72
+ }
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env bash
2
+ # Insert the AgentTrust MCP server into Claude Desktop's config.
3
+ #
4
+ # Backs up the existing config to <path>.bak.<timestamp> before
5
+ # editing. Idempotent: re-running updates the entry in place rather
6
+ # than appending a duplicate.
7
+ #
8
+ # Requires `node` (used to merge the JSON safely) and a built MCP
9
+ # server at mcp/dist/index.js — run `pnpm --filter ./mcp run build`
10
+ # first.
11
+
12
+ set -euo pipefail
13
+
14
+ # Resolve the absolute path to dist/index.js relative to this script.
15
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16
+ MCP_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
17
+ DIST_ENTRY="$MCP_DIR/dist/index.js"
18
+
19
+ if [ ! -f "$DIST_ENTRY" ]; then
20
+ echo "error: $DIST_ENTRY does not exist" >&2
21
+ echo " run: pnpm --filter ./mcp run build" >&2
22
+ exit 1
23
+ fi
24
+
25
+ # Locate Claude Desktop config based on OS.
26
+ case "$(uname -s)" in
27
+ Darwin*)
28
+ CONFIG="$HOME/Library/Application Support/Claude/claude_desktop_config.json"
29
+ ;;
30
+ Linux*)
31
+ CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/Claude/claude_desktop_config.json"
32
+ ;;
33
+ *)
34
+ echo "error: unsupported platform $(uname -s)" >&2
35
+ echo " paste the snippet manually; see mcp/README.md" >&2
36
+ exit 1
37
+ ;;
38
+ esac
39
+
40
+ # Ensure parent dir exists; create empty config if absent.
41
+ mkdir -p "$(dirname "$CONFIG")"
42
+ if [ ! -f "$CONFIG" ]; then
43
+ echo '{}' > "$CONFIG"
44
+ fi
45
+
46
+ # Backup before edit.
47
+ TIMESTAMP="$(date -u +%Y%m%dT%H%M%SZ)"
48
+ cp "$CONFIG" "$CONFIG.bak.$TIMESTAMP"
49
+ echo "Backed up: $CONFIG.bak.$TIMESTAMP"
50
+
51
+ # Merge using node — safer than sed for JSON.
52
+ node - "$CONFIG" "$DIST_ENTRY" <<'EOF'
53
+ const fs = require("fs");
54
+ const [, , configPath, distEntry] = process.argv;
55
+ const raw = fs.readFileSync(configPath, "utf-8");
56
+ const cfg = JSON.parse(raw || "{}");
57
+ if (!cfg.mcpServers || typeof cfg.mcpServers !== "object") cfg.mcpServers = {};
58
+ cfg.mcpServers.agenttrust = {
59
+ command: "node",
60
+ args: [distEntry],
61
+ env: {
62
+ RPC_URL: "https://api.devnet.solana.com",
63
+ NETWORK: "solana-devnet",
64
+ },
65
+ };
66
+ fs.writeFileSync(configPath, JSON.stringify(cfg, null, 2) + "\n");
67
+ console.log("agenttrust entry written to " + configPath);
68
+ EOF
69
+
70
+ echo "Done. Restart Claude Desktop to pick up the new server."
71
+ echo
72
+ echo "To enable write tools, edit $CONFIG and add KEYPAIR_B58 to the env block."