@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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust://devnet/programs` — JSON resource enumerating every
|
|
4
|
+
* deployed program ID + the URL clients can use to fetch the IDL.
|
|
5
|
+
*
|
|
6
|
+
* Anchor publishes IDLs per-program-per-network; the canonical fetch
|
|
7
|
+
* is `Program.fetchIdl(programId, provider)`. We surface the program
|
|
8
|
+
* IDs + a deep-link to Solana Explorer's "Anchor IDL" view as the
|
|
9
|
+
* easiest external pointer.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PROGRAMS_RESOURCE_URI = void 0;
|
|
13
|
+
exports.describeProgramsResource = describeProgramsResource;
|
|
14
|
+
exports.readProgramsResource = readProgramsResource;
|
|
15
|
+
const config_1 = require("../config");
|
|
16
|
+
exports.PROGRAMS_RESOURCE_URI = "agenttrust://devnet/programs";
|
|
17
|
+
function describeProgramsResource() {
|
|
18
|
+
return {
|
|
19
|
+
uri: exports.PROGRAMS_RESOURCE_URI,
|
|
20
|
+
name: "Deployed program IDs",
|
|
21
|
+
description: "JSON manifest of AgentTrust + Quantu program IDs and Explorer URLs for the active cluster.",
|
|
22
|
+
mimeType: "application/json",
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function readProgramsResource(cfg) {
|
|
26
|
+
const payload = {
|
|
27
|
+
network: cfg.network,
|
|
28
|
+
rpcUrl: cfg.rpcUrl,
|
|
29
|
+
explorerCluster: cfg.explorerCluster,
|
|
30
|
+
programs: {
|
|
31
|
+
policyVault: {
|
|
32
|
+
programId: cfg.programs.policyVault.toBase58(),
|
|
33
|
+
explorerUrl: (0, config_1.explorerUrl)(cfg, "address", cfg.programs.policyVault.toBase58()),
|
|
34
|
+
},
|
|
35
|
+
trustgate: {
|
|
36
|
+
programId: cfg.programs.trustgate.toBase58(),
|
|
37
|
+
explorerUrl: (0, config_1.explorerUrl)(cfg, "address", cfg.programs.trustgate.toBase58()),
|
|
38
|
+
},
|
|
39
|
+
validationRegistry: {
|
|
40
|
+
programId: cfg.validationRegistryId.toBase58(),
|
|
41
|
+
explorerUrl: (0, config_1.explorerUrl)(cfg, "address", cfg.validationRegistryId.toBase58()),
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
quantu: {
|
|
45
|
+
agentRegistry: {
|
|
46
|
+
programId: cfg.quantu.agentRegistry.toBase58(),
|
|
47
|
+
explorerUrl: (0, config_1.explorerUrl)(cfg, "address", cfg.quantu.agentRegistry.toBase58()),
|
|
48
|
+
},
|
|
49
|
+
atomEngine: {
|
|
50
|
+
programId: cfg.quantu.atomEngine.toBase58(),
|
|
51
|
+
explorerUrl: (0, config_1.explorerUrl)(cfg, "address", cfg.quantu.atomEngine.toBase58()),
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
notes: "All three Anchor IDLs are published on devnet (verify with " +
|
|
55
|
+
"`anchor idl fetch <programId> --provider.cluster devnet`; latest " +
|
|
56
|
+
"evidence in docs/proofs/idl-on-chain.json). The MCP server bundles " +
|
|
57
|
+
"snapshots under mcp/src/idl/ as a defensive fallback (saves an RPC " +
|
|
58
|
+
"round-trip on cold start; lets the server boot in offline harnesses). " +
|
|
59
|
+
"SDK consumers can reach the IDLs the same two ways via " +
|
|
60
|
+
"loadPolicyVault / loadTrustGate / loadValidationRegistry — pass an " +
|
|
61
|
+
"`idl` arg to use the bundled snapshot, omit it to fetch from chain.",
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
uri: exports.PROGRAMS_RESOURCE_URI,
|
|
65
|
+
mimeType: "application/json",
|
|
66
|
+
text: JSON.stringify(payload, null, 2),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=programs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"programs.js","sourceRoot":"","sources":["../../src/resources/programs.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAOH,4DAOC;AAED,oDA4CC;AA1DD,sCAA0D;AAG7C,QAAA,qBAAqB,GAAG,8BAA8B,CAAC;AAEpE,SAAgB,wBAAwB;IACtC,OAAO;QACL,GAAG,EAAU,6BAAqB;QAClC,IAAI,EAAS,sBAAsB;QACnC,WAAW,EAAE,4FAA4F;QACzG,QAAQ,EAAK,kBAAkB;KAChC,CAAC;AACJ,CAAC;AAED,SAAgB,oBAAoB,CAAC,GAAqB;IACxD,MAAM,OAAO,GAAG;QACd,OAAO,EAAiB,GAAG,CAAC,OAAO;QACnC,MAAM,EAAkB,GAAG,CAAC,MAAM;QAClC,eAAe,EAAS,GAAG,CAAC,eAAe;QAC3C,QAAQ,EAAE;YACR,WAAW,EAAE;gBACX,SAAS,EAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE;gBAChD,WAAW,EAAE,IAAA,oBAAW,EAAC,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;aAC9E;YACD,SAAS,EAAE;gBACT,SAAS,EAAI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a
|
|
3
|
+
* single `Server` instance and returns it so transports can connect.
|
|
4
|
+
*
|
|
5
|
+
* Tool dispatch flow:
|
|
6
|
+
* 1. tools/list → ALL_TOOLS metadata
|
|
7
|
+
* 2. tools/call → look up by name, parse input via Zod, run handler,
|
|
8
|
+
* wrap output as a single text content block (JSON-encoded).
|
|
9
|
+
*
|
|
10
|
+
* Resources are split into two URI schemes:
|
|
11
|
+
* - agenttrust://docs/<rel-path> → MDX content
|
|
12
|
+
* - agenttrust://devnet/programs → JSON program manifest
|
|
13
|
+
* - agenttrust://examples/<demo>/... → demo source files
|
|
14
|
+
*
|
|
15
|
+
* Prompts surface the three guided workflows from prompts/ALL_PROMPTS.
|
|
16
|
+
*/
|
|
17
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
18
|
+
import type { AgentTrustConfig } from "./config";
|
|
19
|
+
export declare function createMcpServer(cfg: AgentTrustConfig): Server;
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP server registration. Wires every tool / resource / prompt onto a
|
|
4
|
+
* single `Server` instance and returns it so transports can connect.
|
|
5
|
+
*
|
|
6
|
+
* Tool dispatch flow:
|
|
7
|
+
* 1. tools/list → ALL_TOOLS metadata
|
|
8
|
+
* 2. tools/call → look up by name, parse input via Zod, run handler,
|
|
9
|
+
* wrap output as a single text content block (JSON-encoded).
|
|
10
|
+
*
|
|
11
|
+
* Resources are split into two URI schemes:
|
|
12
|
+
* - agenttrust://docs/<rel-path> → MDX content
|
|
13
|
+
* - agenttrust://devnet/programs → JSON program manifest
|
|
14
|
+
* - agenttrust://examples/<demo>/... → demo source files
|
|
15
|
+
*
|
|
16
|
+
* Prompts surface the three guided workflows from prompts/ALL_PROMPTS.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.createMcpServer = createMcpServer;
|
|
20
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
21
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
22
|
+
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
23
|
+
const chain_1 = require("./chain");
|
|
24
|
+
const prompts_1 = require("./prompts");
|
|
25
|
+
const programs_1 = require("./resources/programs");
|
|
26
|
+
const docs_1 = require("./resources/docs");
|
|
27
|
+
const tools_1 = require("./tools");
|
|
28
|
+
const SERVER_NAME = "agenttrust";
|
|
29
|
+
const SERVER_VERSION = "0.1.0";
|
|
30
|
+
const SERVER_INSTRUCTIONS = "AgentTrust MCP server. Read tools work without auth (devnet by default). " +
|
|
31
|
+
"Write tools require KEYPAIR_B58 in env. Resources expose the AgentTrust " +
|
|
32
|
+
"docs corpus, deployed program manifest, and example demo source. Prompts " +
|
|
33
|
+
"ship three guided workflows: audit_payment, setup_agent, explain_failure.";
|
|
34
|
+
function createMcpServer(cfg) {
|
|
35
|
+
const chain = new chain_1.ChainClient(cfg);
|
|
36
|
+
const server = new index_js_1.Server({ name: SERVER_NAME, version: SERVER_VERSION }, {
|
|
37
|
+
capabilities: { tools: {}, resources: {}, prompts: {} },
|
|
38
|
+
instructions: SERVER_INSTRUCTIONS,
|
|
39
|
+
});
|
|
40
|
+
// ---- tools/list ---------------------------------------------------------
|
|
41
|
+
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
|
|
42
|
+
tools: tools_1.ALL_TOOLS.map((t) => ({
|
|
43
|
+
name: t.name,
|
|
44
|
+
description: t.description,
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
+
inputSchema: (0, zod_to_json_schema_1.zodToJsonSchema)(t.inputSchema, { target: "openApi3" }),
|
|
47
|
+
})),
|
|
48
|
+
}));
|
|
49
|
+
// ---- tools/call ---------------------------------------------------------
|
|
50
|
+
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (req) => {
|
|
51
|
+
const tool = tools_1.ALL_TOOLS.find((t) => t.name === req.params.name);
|
|
52
|
+
if (!tool) {
|
|
53
|
+
return {
|
|
54
|
+
isError: true,
|
|
55
|
+
content: [{ type: "text", text: `unknown tool: ${req.params.name}` }],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
let parsed;
|
|
59
|
+
try {
|
|
60
|
+
parsed = tool.inputSchema.parse(req.params.arguments ?? {});
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
return {
|
|
64
|
+
isError: true,
|
|
65
|
+
content: [{ type: "text", text: `input validation failed: ${err.message}` }],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const result = await tool.handler(parsed, { chain });
|
|
70
|
+
return {
|
|
71
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
return {
|
|
76
|
+
isError: true,
|
|
77
|
+
content: [{ type: "text", text: `tool error: ${err.message}` }],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
// ---- resources/list ----------------------------------------------------
|
|
82
|
+
server.setRequestHandler(types_js_1.ListResourcesRequestSchema, async () => ({
|
|
83
|
+
resources: [
|
|
84
|
+
(0, programs_1.describeProgramsResource)(),
|
|
85
|
+
...(0, docs_1.listDocsResources)(),
|
|
86
|
+
...(0, docs_1.listExampleResources)(),
|
|
87
|
+
],
|
|
88
|
+
}));
|
|
89
|
+
// ---- resources/read ----------------------------------------------------
|
|
90
|
+
server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (req) => {
|
|
91
|
+
const uri = req.params.uri;
|
|
92
|
+
if (uri === programs_1.PROGRAMS_RESOURCE_URI) {
|
|
93
|
+
const r = (0, programs_1.readProgramsResource)(cfg);
|
|
94
|
+
return { contents: [r] };
|
|
95
|
+
}
|
|
96
|
+
const docs = (0, docs_1.readDocsResource)(uri);
|
|
97
|
+
if (docs)
|
|
98
|
+
return { contents: [docs] };
|
|
99
|
+
const ex = (0, docs_1.readExampleResource)(uri);
|
|
100
|
+
if (ex)
|
|
101
|
+
return { contents: [ex] };
|
|
102
|
+
throw new Error(`unknown resource URI: ${uri}`);
|
|
103
|
+
});
|
|
104
|
+
// ---- prompts/list ------------------------------------------------------
|
|
105
|
+
server.setRequestHandler(types_js_1.ListPromptsRequestSchema, async () => ({
|
|
106
|
+
prompts: prompts_1.ALL_PROMPTS.map((p) => ({
|
|
107
|
+
name: p.name,
|
|
108
|
+
description: p.description,
|
|
109
|
+
arguments: p.arguments.map((a) => ({
|
|
110
|
+
name: a.name,
|
|
111
|
+
description: a.description,
|
|
112
|
+
required: a.required,
|
|
113
|
+
})),
|
|
114
|
+
})),
|
|
115
|
+
}));
|
|
116
|
+
// ---- prompts/get -------------------------------------------------------
|
|
117
|
+
server.setRequestHandler(types_js_1.GetPromptRequestSchema, async (req) => {
|
|
118
|
+
const prompt = prompts_1.ALL_PROMPTS.find((p) => p.name === req.params.name);
|
|
119
|
+
if (!prompt)
|
|
120
|
+
throw new Error(`unknown prompt: ${req.params.name}`);
|
|
121
|
+
const argMap = (req.params.arguments ?? {});
|
|
122
|
+
// Required-arg guard so prompt build() can stay declarative.
|
|
123
|
+
for (const a of prompt.arguments) {
|
|
124
|
+
if (a.required && !argMap[a.name]) {
|
|
125
|
+
throw new Error(`prompt ${prompt.name} missing required argument: ${a.name}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const messages = prompt.build(argMap);
|
|
129
|
+
return {
|
|
130
|
+
description: prompt.description,
|
|
131
|
+
messages,
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
return server;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAsCH,0CA0GC;AA9ID,wEAAmE;AACnE,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AAQ,EAAK,CAAC,CAAC,QAAQ;aACxB,CAAC,CAAC;SACJ,CAAC,CAAC;KACJ,CAAC,CAAC,CAAC;IAEJ,2EAA2E;IAC3E,MAAM,CAAC,iBAAiB,CAAC,iCAAsB,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QAC7D,MAAM,MAAM,GAAG,qBAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACnE,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACnE,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAA2B,CAAC;QACtE,6DAA6D;QAC7D,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-tool helpers: pubkey parsing, BN serialization, hex conversion.
|
|
3
|
+
*
|
|
4
|
+
* Tools serialise PublicKey → base58 string and BN/bigint → string in
|
|
5
|
+
* tool replies, since most MCP clients render JSON via `JSON.stringify`
|
|
6
|
+
* which would crash on a BigInt or yield `[object Object]` on a PublicKey.
|
|
7
|
+
*/
|
|
8
|
+
import { PublicKey } from "@solana/web3.js";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
export declare const PubkeySchema: z.ZodEffects<z.ZodString, string, string>;
|
|
11
|
+
export declare function parsePubkey(s: string, field: string): PublicKey;
|
|
12
|
+
export declare function bytesToHex(bytes: Uint8Array | Buffer | number[]): string;
|
|
13
|
+
export declare function hexToBytes(s: string): Uint8Array;
|
|
14
|
+
export declare const HexHashSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
15
|
+
/** Convert any `BN`-like or bigint into a decimal string. */
|
|
16
|
+
export declare function toDecString(v: unknown): string;
|
|
17
|
+
/** Convert a decoded Anchor account's potential `Pubkey` field to base58. */
|
|
18
|
+
export declare function pubkeyOrNull(v: unknown): string | null;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cross-tool helpers: pubkey parsing, BN serialization, hex conversion.
|
|
4
|
+
*
|
|
5
|
+
* Tools serialise PublicKey → base58 string and BN/bigint → string in
|
|
6
|
+
* tool replies, since most MCP clients render JSON via `JSON.stringify`
|
|
7
|
+
* which would crash on a BigInt or yield `[object Object]` on a PublicKey.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.HexHashSchema = exports.PubkeySchema = void 0;
|
|
11
|
+
exports.parsePubkey = parsePubkey;
|
|
12
|
+
exports.bytesToHex = bytesToHex;
|
|
13
|
+
exports.hexToBytes = hexToBytes;
|
|
14
|
+
exports.toDecString = toDecString;
|
|
15
|
+
exports.pubkeyOrNull = pubkeyOrNull;
|
|
16
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
17
|
+
const zod_1 = require("zod");
|
|
18
|
+
exports.PubkeySchema = zod_1.z.string().refine((s) => {
|
|
19
|
+
try {
|
|
20
|
+
new web3_js_1.PublicKey(s);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}, { message: "must be a base58-encoded Solana public key" });
|
|
27
|
+
function parsePubkey(s, field) {
|
|
28
|
+
try {
|
|
29
|
+
return new web3_js_1.PublicKey(s);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
throw new Error(`${field}: ${err.message}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function bytesToHex(bytes) {
|
|
36
|
+
const b = Buffer.from(bytes);
|
|
37
|
+
return b.toString("hex");
|
|
38
|
+
}
|
|
39
|
+
function hexToBytes(s) {
|
|
40
|
+
const clean = s.startsWith("0x") ? s.slice(2) : s;
|
|
41
|
+
if (!/^[0-9a-fA-F]*$/.test(clean) || clean.length % 2 !== 0) {
|
|
42
|
+
throw new Error(`invalid hex string: ${s}`);
|
|
43
|
+
}
|
|
44
|
+
return new Uint8Array(Buffer.from(clean, "hex"));
|
|
45
|
+
}
|
|
46
|
+
exports.HexHashSchema = zod_1.z.string().refine((s) => {
|
|
47
|
+
const clean = s.startsWith("0x") ? s.slice(2) : s;
|
|
48
|
+
return /^[0-9a-fA-F]{64}$/.test(clean);
|
|
49
|
+
}, { message: "must be a 32-byte hex string (64 hex chars, optional 0x prefix)" });
|
|
50
|
+
/** Convert any `BN`-like or bigint into a decimal string. */
|
|
51
|
+
function toDecString(v) {
|
|
52
|
+
if (v == null)
|
|
53
|
+
return "0";
|
|
54
|
+
if (typeof v === "bigint")
|
|
55
|
+
return v.toString();
|
|
56
|
+
if (typeof v === "number")
|
|
57
|
+
return v.toString();
|
|
58
|
+
if (typeof v === "string")
|
|
59
|
+
return v;
|
|
60
|
+
// @coral-xyz/anchor BN
|
|
61
|
+
if (typeof v.toString === "function") {
|
|
62
|
+
return v.toString(10);
|
|
63
|
+
}
|
|
64
|
+
return String(v);
|
|
65
|
+
}
|
|
66
|
+
/** Convert a decoded Anchor account's potential `Pubkey` field to base58. */
|
|
67
|
+
function pubkeyOrNull(v) {
|
|
68
|
+
if (!v)
|
|
69
|
+
return null;
|
|
70
|
+
if (v instanceof web3_js_1.PublicKey)
|
|
71
|
+
return v.toBase58();
|
|
72
|
+
if (typeof v.toBase58 === "function") {
|
|
73
|
+
return v.toBase58();
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/tools/common.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAYH,kCAMC;AAED,gCAGC;AAED,gCAMC;AAWD,kCAUC;AAGD,oCAOC;AA5DD,6CAA4C;AAC5C,6BAAwB;AAEX,QAAA,YAAY,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAC3C,CAAC,CAAC,EAAE,EAAE;IACJ,IAAI,CAAC;QAAC,IAAI,mBAAS,CAAC,CAAC,CAAC,CAAC;QAAC,OAAO,IAAI,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,KAAK,CAAC;IAAC,CAAC;AAChE,CAAC,EACD,EAAE,OAAO,EAAE,4CAA4C,EAAE,CAC1D,CAAC;AAEF,SAAgB,WAAW,CAAC,CAAS,EAAE,KAAa;IAClD,IAAI,CAAC;QACH,OAAO,IAAI,mBAAS,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,KAAM,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AAED,SAAgB,UAAU,CAAC,KAAqC;IAC9D,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAA0B,CAAC,CAAC;IAClD,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AAED,SAAgB,UAAU,CAAC,CAA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Q,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC;AAED,6EAA6E;AAC7E,SAAgB,YAAY,CAAC,CAAU;IACrC,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,IAAI,CAAC,YAAY,mBAAS;QAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IAChD,IAAI,OAAQ,CAAiC,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;QACtE,OAAQ,CAAgC,CAAC,QAAQ,EAAE,CAAC;IACtD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust_docs` — naïve full-text search over the MDX corpus at
|
|
3
|
+
* `docs-site/content/docs/`. Returns the top 5 ranked snippets.
|
|
4
|
+
*
|
|
5
|
+
* Indexer: walks the docs corpus once on first call, caches the
|
|
6
|
+
* resulting `DocPage[]`. Each page is parsed for title/description
|
|
7
|
+
* frontmatter + raw body. Ranking: term-frequency over the body, with
|
|
8
|
+
* a 5x bonus for matches in title or description.
|
|
9
|
+
*
|
|
10
|
+
* The MCP server runs in-process so the cache survives across tool
|
|
11
|
+
* calls. A `MCP_DOCS_DIR` env override exists for tests.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
import type { Tool } from "../types";
|
|
15
|
+
interface DocPage {
|
|
16
|
+
uri: string;
|
|
17
|
+
filePath: string;
|
|
18
|
+
title: string;
|
|
19
|
+
description: string;
|
|
20
|
+
body: string;
|
|
21
|
+
bodyLower: string;
|
|
22
|
+
}
|
|
23
|
+
declare const InputSchema: z.ZodObject<{
|
|
24
|
+
query: z.ZodString;
|
|
25
|
+
max_results: z.ZodDefault<z.ZodNumber>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
query: string;
|
|
28
|
+
max_results: number;
|
|
29
|
+
}, {
|
|
30
|
+
query: string;
|
|
31
|
+
max_results?: number | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
type Input = z.infer<typeof InputSchema>;
|
|
34
|
+
interface Hit {
|
|
35
|
+
uri: string;
|
|
36
|
+
title: string;
|
|
37
|
+
description: string;
|
|
38
|
+
score: number;
|
|
39
|
+
excerpt: string;
|
|
40
|
+
}
|
|
41
|
+
interface Output {
|
|
42
|
+
query: string;
|
|
43
|
+
hits: Hit[];
|
|
44
|
+
}
|
|
45
|
+
export declare function findDocsRoot(): string | null;
|
|
46
|
+
export declare function loadDocsCorpus(force?: boolean): DocPage[];
|
|
47
|
+
export declare const docsTool: Tool<Input, Output>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_docs` — naïve full-text search over the MDX corpus at
|
|
4
|
+
* `docs-site/content/docs/`. Returns the top 5 ranked snippets.
|
|
5
|
+
*
|
|
6
|
+
* Indexer: walks the docs corpus once on first call, caches the
|
|
7
|
+
* resulting `DocPage[]`. Each page is parsed for title/description
|
|
8
|
+
* frontmatter + raw body. Ranking: term-frequency over the body, with
|
|
9
|
+
* a 5x bonus for matches in title or description.
|
|
10
|
+
*
|
|
11
|
+
* The MCP server runs in-process so the cache survives across tool
|
|
12
|
+
* calls. A `MCP_DOCS_DIR` env override exists for tests.
|
|
13
|
+
*/
|
|
14
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
+
}) : function(o, v) {
|
|
28
|
+
o["default"] = v;
|
|
29
|
+
});
|
|
30
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
31
|
+
var ownKeys = function(o) {
|
|
32
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
33
|
+
var ar = [];
|
|
34
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
return ownKeys(o);
|
|
38
|
+
};
|
|
39
|
+
return function (mod) {
|
|
40
|
+
if (mod && mod.__esModule) return mod;
|
|
41
|
+
var result = {};
|
|
42
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
43
|
+
__setModuleDefault(result, mod);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.docsTool = void 0;
|
|
49
|
+
exports.findDocsRoot = findDocsRoot;
|
|
50
|
+
exports.loadDocsCorpus = loadDocsCorpus;
|
|
51
|
+
const fs = __importStar(require("fs"));
|
|
52
|
+
const path = __importStar(require("path"));
|
|
53
|
+
const zod_1 = require("zod");
|
|
54
|
+
const InputSchema = zod_1.z.object({
|
|
55
|
+
query: zod_1.z.string().min(2).describe("Free-text query (case-insensitive)"),
|
|
56
|
+
max_results: zod_1.z.number().int().min(1).max(20).default(5),
|
|
57
|
+
});
|
|
58
|
+
let cache = null;
|
|
59
|
+
function findDocsRoot() {
|
|
60
|
+
const candidates = [
|
|
61
|
+
process.env.MCP_DOCS_DIR ?? "",
|
|
62
|
+
path.resolve(__dirname, "../../../../docs-site/content/docs"),
|
|
63
|
+
path.resolve(process.cwd(), "docs-site/content/docs"),
|
|
64
|
+
].filter(Boolean);
|
|
65
|
+
for (const c of candidates) {
|
|
66
|
+
try {
|
|
67
|
+
if (c && fs.statSync(c).isDirectory())
|
|
68
|
+
return c;
|
|
69
|
+
}
|
|
70
|
+
catch { /* ignore */ }
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
function loadDocsCorpus(force = false) {
|
|
75
|
+
if (cache && !force)
|
|
76
|
+
return cache;
|
|
77
|
+
const root = findDocsRoot();
|
|
78
|
+
if (!root) {
|
|
79
|
+
cache = [];
|
|
80
|
+
return cache;
|
|
81
|
+
}
|
|
82
|
+
const pages = [];
|
|
83
|
+
walk(root, "", pages, root);
|
|
84
|
+
cache = pages;
|
|
85
|
+
return pages;
|
|
86
|
+
}
|
|
87
|
+
function walk(dir, rel, pages, root) {
|
|
88
|
+
for (const ent of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
89
|
+
const abs = path.join(dir, ent.name);
|
|
90
|
+
const cur = rel ? path.join(rel, ent.name) : ent.name;
|
|
91
|
+
if (ent.isDirectory()) {
|
|
92
|
+
walk(abs, cur, pages, root);
|
|
93
|
+
}
|
|
94
|
+
else if (ent.isFile() && ent.name.endsWith(".mdx")) {
|
|
95
|
+
const raw = fs.readFileSync(abs, "utf-8");
|
|
96
|
+
const meta = parseFrontmatter(raw);
|
|
97
|
+
const body = stripFrontmatter(raw);
|
|
98
|
+
const uri = "agenttrust://docs/" + cur.replace(/\.mdx$/, "").replace(/\\/g, "/");
|
|
99
|
+
pages.push({
|
|
100
|
+
uri,
|
|
101
|
+
filePath: abs,
|
|
102
|
+
title: meta.title ?? cur,
|
|
103
|
+
description: meta.description ?? "",
|
|
104
|
+
body,
|
|
105
|
+
bodyLower: body.toLowerCase(),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function parseFrontmatter(raw) {
|
|
111
|
+
if (!raw.startsWith("---\n"))
|
|
112
|
+
return {};
|
|
113
|
+
const end = raw.indexOf("\n---\n", 4);
|
|
114
|
+
if (end < 0)
|
|
115
|
+
return {};
|
|
116
|
+
const block = raw.slice(4, end);
|
|
117
|
+
const out = {};
|
|
118
|
+
for (const line of block.split("\n")) {
|
|
119
|
+
const m = /^([A-Za-z_]+):\s*(.+?)\s*$/.exec(line);
|
|
120
|
+
if (!m)
|
|
121
|
+
continue;
|
|
122
|
+
const key = m[1].toLowerCase();
|
|
123
|
+
let val = m[2];
|
|
124
|
+
if ((val.startsWith("\"") && val.endsWith("\"")) || (val.startsWith("'") && val.endsWith("'"))) {
|
|
125
|
+
val = val.slice(1, -1);
|
|
126
|
+
}
|
|
127
|
+
if (key === "title")
|
|
128
|
+
out.title = val;
|
|
129
|
+
if (key === "description")
|
|
130
|
+
out.description = val;
|
|
131
|
+
}
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
function stripFrontmatter(raw) {
|
|
135
|
+
if (!raw.startsWith("---\n"))
|
|
136
|
+
return raw;
|
|
137
|
+
const end = raw.indexOf("\n---\n", 4);
|
|
138
|
+
if (end < 0)
|
|
139
|
+
return raw;
|
|
140
|
+
return raw.slice(end + 5);
|
|
141
|
+
}
|
|
142
|
+
function score(query, page) {
|
|
143
|
+
const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
144
|
+
if (terms.length === 0)
|
|
145
|
+
return { score: 0, excerpt: "" };
|
|
146
|
+
let s = 0;
|
|
147
|
+
let firstHitIdx = -1;
|
|
148
|
+
for (const t of terms) {
|
|
149
|
+
const titleHit = page.title.toLowerCase().includes(t) ? 5 : 0;
|
|
150
|
+
const descHit = page.description.toLowerCase().includes(t) ? 5 : 0;
|
|
151
|
+
let bodyHits = 0;
|
|
152
|
+
let from = 0;
|
|
153
|
+
while (true) {
|
|
154
|
+
const idx = page.bodyLower.indexOf(t, from);
|
|
155
|
+
if (idx < 0)
|
|
156
|
+
break;
|
|
157
|
+
bodyHits++;
|
|
158
|
+
if (firstHitIdx < 0)
|
|
159
|
+
firstHitIdx = idx;
|
|
160
|
+
from = idx + t.length;
|
|
161
|
+
}
|
|
162
|
+
s += titleHit + descHit + bodyHits;
|
|
163
|
+
}
|
|
164
|
+
const excerptStart = Math.max(0, firstHitIdx - 80);
|
|
165
|
+
const excerptEnd = Math.min(page.body.length, (firstHitIdx < 0 ? 0 : firstHitIdx) + 240);
|
|
166
|
+
const excerpt = firstHitIdx >= 0
|
|
167
|
+
? page.body.slice(excerptStart, excerptEnd).replace(/\n+/g, " ").trim()
|
|
168
|
+
: (page.description || page.body.slice(0, 240).replace(/\n+/g, " ").trim());
|
|
169
|
+
return { score: s, excerpt };
|
|
170
|
+
}
|
|
171
|
+
exports.docsTool = {
|
|
172
|
+
name: "agenttrust_docs",
|
|
173
|
+
description: "Full-text search the AgentTrust docs corpus (docs-site/content/docs). " +
|
|
174
|
+
"Returns up to N ranked hits with title, agenttrust:// URI, score, and " +
|
|
175
|
+
"an excerpt around the first match. Use the URI in resources/read for " +
|
|
176
|
+
"the full doc.",
|
|
177
|
+
inputSchema: InputSchema,
|
|
178
|
+
async handler(input) {
|
|
179
|
+
const corpus = loadDocsCorpus();
|
|
180
|
+
if (corpus.length === 0) {
|
|
181
|
+
return { query: input.query, hits: [] };
|
|
182
|
+
}
|
|
183
|
+
const ranked = [];
|
|
184
|
+
for (const page of corpus) {
|
|
185
|
+
const r = score(input.query, page);
|
|
186
|
+
if (r.score > 0) {
|
|
187
|
+
ranked.push({
|
|
188
|
+
uri: page.uri,
|
|
189
|
+
title: page.title,
|
|
190
|
+
description: page.description,
|
|
191
|
+
score: r.score,
|
|
192
|
+
excerpt: r.excerpt,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
ranked.sort((a, b) => b.score - a.score);
|
|
197
|
+
return { query: input.query, hits: ranked.slice(0, input.max_results) };
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
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2
|
+
* `agenttrust_explain_decision` — translate a numeric reason code into
|
|
3
|
+
* its enum name plus a one-paragraph remediation hint.
|
|
4
|
+
*
|
|
5
|
+
* Authoritative mapping comes from the SDK's `denyReasonName` (which
|
|
6
|
+
* mirrors `programs/policy-vault/src/state/decision.rs`). The hints
|
|
7
|
+
* here are MCP-specific guidance text — they describe what a developer
|
|
8
|
+
* or operator should do next when they see the code.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import type { Tool } from "../types";
|
|
12
|
+
declare const InputSchema: z.ZodObject<{
|
|
13
|
+
reason_code: z.ZodNumber;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
reason_code: number;
|
|
16
|
+
}, {
|
|
17
|
+
reason_code: number;
|
|
18
|
+
}>;
|
|
19
|
+
type Input = z.infer<typeof InputSchema>;
|
|
20
|
+
interface Output {
|
|
21
|
+
reasonCode: number;
|
|
22
|
+
reasonName: string;
|
|
23
|
+
category: "killswitch" | "spending" | "velocity" | "counterparty" | "atom" | "validation";
|
|
24
|
+
oneLiner: string;
|
|
25
|
+
remediation: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const explainDecisionTool: Tool<Input, Output>;
|
|
28
|
+
export {};
|