@agntor/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 +251 -0
- package/dist/index.js +672 -0
- package/dist/server.js +754 -0
- package/package.json +72 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { z as z3 } from "zod";
|
|
4
|
+
import { guard, redact, guardTool, Agntor } from "@agntor/sdk";
|
|
5
|
+
|
|
6
|
+
// src/schemas.ts
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
var AgentCardSchema = z.object({
|
|
9
|
+
// Identity
|
|
10
|
+
id: z.string().describe("Unique Agent ID (DID or UUID)"),
|
|
11
|
+
name: z.string().describe("Display name of the agent"),
|
|
12
|
+
organization: z.string().describe("Legal entity owning the agent"),
|
|
13
|
+
version: z.string().describe("Semantic version of the agent code"),
|
|
14
|
+
// Certification
|
|
15
|
+
audit_level: z.enum(["Bronze", "Silver", "Gold", "Platinum"]).describe("Agntor Certification Level"),
|
|
16
|
+
trust_score: z.number().min(0).max(100).describe("Real-time trust score (0-100)"),
|
|
17
|
+
certified_at: z.string().datetime().describe("ISO timestamp of last full audit"),
|
|
18
|
+
expires_at: z.string().datetime().describe("ISO timestamp when certification expires"),
|
|
19
|
+
// Capabilities & Constraints
|
|
20
|
+
capabilities: z.array(z.string()).describe("List of allowed actions (e.g., 'trade', 'email')"),
|
|
21
|
+
constraints: z.object({
|
|
22
|
+
max_transaction_value: z.number().describe("Hard cap on single transaction value (USD)"),
|
|
23
|
+
allowed_domains: z.array(z.string()).describe("Whitelisted external domains"),
|
|
24
|
+
requires_human_approval: z.boolean().describe("If true, high-risk actions need human sign-off"),
|
|
25
|
+
requires_x402_payment: z.boolean().describe("If true, x402 proof-of-payment required")
|
|
26
|
+
}),
|
|
27
|
+
// Verification
|
|
28
|
+
issuer: z.string().describe("Authority that issued this card (e.g., 'agntor.com')"),
|
|
29
|
+
signature: z.string().describe("Cryptographic signature of this card")
|
|
30
|
+
});
|
|
31
|
+
var AgentPulseSchema = z.object({
|
|
32
|
+
agent_id: z.string(),
|
|
33
|
+
status: z.enum(["healthy", "degraded", "critical", "offline"]),
|
|
34
|
+
metrics: z.object({
|
|
35
|
+
uptime_24h: z.number().min(0).max(100),
|
|
36
|
+
error_rate_1h: z.number().min(0).max(1),
|
|
37
|
+
avg_latency_ms: z.number(),
|
|
38
|
+
spend_velocity_1h: z.number().describe("USD spent in last hour")
|
|
39
|
+
}),
|
|
40
|
+
last_heartbeat: z.string().datetime()
|
|
41
|
+
});
|
|
42
|
+
var AgentRegistrationSchema = z.object({
|
|
43
|
+
type: z.string().describe("EIP-8004 registration type URI"),
|
|
44
|
+
name: z.string(),
|
|
45
|
+
description: z.string(),
|
|
46
|
+
image: z.string().optional(),
|
|
47
|
+
endpoints: z.array(
|
|
48
|
+
z.object({
|
|
49
|
+
name: z.string(),
|
|
50
|
+
endpoint: z.string(),
|
|
51
|
+
version: z.string().optional(),
|
|
52
|
+
capabilities: z.array(z.string()).optional(),
|
|
53
|
+
skills: z.array(z.string()).optional(),
|
|
54
|
+
domains: z.array(z.string()).optional()
|
|
55
|
+
})
|
|
56
|
+
),
|
|
57
|
+
x402Support: z.boolean(),
|
|
58
|
+
active: z.boolean(),
|
|
59
|
+
registrations: z.array(
|
|
60
|
+
z.object({
|
|
61
|
+
agentId: z.number(),
|
|
62
|
+
agentRegistry: z.string()
|
|
63
|
+
})
|
|
64
|
+
),
|
|
65
|
+
supportedTrust: z.array(z.string()).optional()
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// src/types.ts
|
|
69
|
+
import { z as z2 } from "zod";
|
|
70
|
+
var VerifyAgentRequest = z2.object({
|
|
71
|
+
agentId: z2.string().describe("The agent ID to verify"),
|
|
72
|
+
includeHealth: z2.boolean().optional().describe("Include behavioral health metrics")
|
|
73
|
+
});
|
|
74
|
+
var IssueTicketRequest = z2.object({
|
|
75
|
+
agentId: z2.string().describe("Agent ID to issue ticket for"),
|
|
76
|
+
validitySeconds: z2.number().optional().describe("Ticket validity in seconds (default: 300)")
|
|
77
|
+
});
|
|
78
|
+
var QueryAgentsRequest = z2.object({
|
|
79
|
+
minTrustScore: z2.number().optional().describe("Minimum trust score (0-100)"),
|
|
80
|
+
auditLevel: z2.enum(["Bronze", "Silver", "Gold", "Platinum"]).optional(),
|
|
81
|
+
capabilities: z2.array(z2.string()).optional().describe("Required capabilities"),
|
|
82
|
+
limit: z2.number().optional().describe("Maximum results (default: 10)")
|
|
83
|
+
});
|
|
84
|
+
var KillSwitchRequest = z2.object({
|
|
85
|
+
agentId: z2.string().describe("Agent ID to disable"),
|
|
86
|
+
reason: z2.string().describe("Reason for kill switch activation"),
|
|
87
|
+
revokeTickets: z2.boolean().optional().describe("Revoke all existing tickets (default: true)")
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// src/index.ts
|
|
91
|
+
function getAgntorClient() {
|
|
92
|
+
const apiKey = process.env.AGNTOR_API_KEY;
|
|
93
|
+
if (!apiKey) {
|
|
94
|
+
console.warn("[MCP] Warning: AGNTOR_API_KEY not set. SDK calls to the backend will fail.");
|
|
95
|
+
}
|
|
96
|
+
const apiUrl = process.env.AGNTOR_API_URL || "https://app.agntor.com";
|
|
97
|
+
return new Agntor({
|
|
98
|
+
apiKey: apiKey || "not-configured",
|
|
99
|
+
agentId: process.env.AGNTOR_AGENT_ID || "agent://mcp-server",
|
|
100
|
+
chain: process.env.AGNTOR_CHAIN || "base",
|
|
101
|
+
baseUrl: apiUrl
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
async function getAgentRecord(agentId) {
|
|
105
|
+
const agntor = getAgntorClient();
|
|
106
|
+
try {
|
|
107
|
+
const raw = await agntor.getAgent(agentId);
|
|
108
|
+
const identity = raw.identity ?? {};
|
|
109
|
+
const profile = raw.profile ?? {};
|
|
110
|
+
const trust = raw.trust ?? {};
|
|
111
|
+
const status = raw.status ?? {};
|
|
112
|
+
const meta = profile.metadata ?? {};
|
|
113
|
+
const record = {
|
|
114
|
+
agentId: raw.id ?? agentId,
|
|
115
|
+
auditLevel: trust.level ?? "Bronze",
|
|
116
|
+
trustScore: trust.score ?? 0,
|
|
117
|
+
organization: profile.organization ?? "Unknown",
|
|
118
|
+
metadata: {
|
|
119
|
+
name: identity.handle ?? meta.name ?? "Unknown Agent",
|
|
120
|
+
description: meta.description ?? "",
|
|
121
|
+
capabilities: meta.capabilities ?? [],
|
|
122
|
+
verified_domain: meta.verified_domain
|
|
123
|
+
},
|
|
124
|
+
certification: {
|
|
125
|
+
certified_at: trust.certified ? Date.now() : 0,
|
|
126
|
+
expires_at: trust.certified ? Date.now() + 365 * 24 * 60 * 60 * 1e3 : 0,
|
|
127
|
+
certifier: "agntor.com",
|
|
128
|
+
mva_level: trust.level === "Platinum" ? 5 : trust.level === "Gold" ? 4 : trust.level === "Silver" ? 3 : 1
|
|
129
|
+
},
|
|
130
|
+
health: {
|
|
131
|
+
uptime_percentage: meta.uptime_percentage ?? 0,
|
|
132
|
+
avg_latency_ms: meta.avg_latency_ms ?? 0,
|
|
133
|
+
error_rate: meta.error_rate ?? 0,
|
|
134
|
+
total_transactions: meta.total_transactions ?? 0,
|
|
135
|
+
last_active: meta.last_active ?? Date.now()
|
|
136
|
+
},
|
|
137
|
+
killSwitchActive: !(status.active ?? true),
|
|
138
|
+
constraints: {
|
|
139
|
+
max_op_value: meta.max_op_value ?? 1e4,
|
|
140
|
+
allowed_mcp_servers: meta.allowed_mcp_servers ?? [],
|
|
141
|
+
max_ops_per_hour: meta.max_ops_per_hour,
|
|
142
|
+
requires_x402_payment: meta.requires_x402_payment
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
return record;
|
|
146
|
+
} catch (e) {
|
|
147
|
+
console.error(`[MCP] getAgentRecord failed for ${agentId}:`, e.message);
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function createAgntorMcpServer(issuer) {
|
|
152
|
+
const server = new McpServer({
|
|
153
|
+
name: "agntor-audit-server",
|
|
154
|
+
version: "0.1.0"
|
|
155
|
+
});
|
|
156
|
+
server.registerTool(
|
|
157
|
+
"get_agent_card",
|
|
158
|
+
{
|
|
159
|
+
title: "Get Agent Card",
|
|
160
|
+
description: "Retrieve the verifiable AgentCard (Passport) for an agent",
|
|
161
|
+
inputSchema: {
|
|
162
|
+
agentId: z3.string().describe("The agent ID to retrieve")
|
|
163
|
+
},
|
|
164
|
+
outputSchema: AgentCardSchema
|
|
165
|
+
},
|
|
166
|
+
async ({ agentId }) => {
|
|
167
|
+
const agent = await getAgentRecord(agentId);
|
|
168
|
+
if (!agent) {
|
|
169
|
+
throw new Error(`Agent ${agentId} not found`);
|
|
170
|
+
}
|
|
171
|
+
const card = {
|
|
172
|
+
id: agent.agentId,
|
|
173
|
+
name: agent.metadata.name,
|
|
174
|
+
organization: agent.organization,
|
|
175
|
+
version: "1.0.0",
|
|
176
|
+
// Placeholder
|
|
177
|
+
audit_level: agent.auditLevel,
|
|
178
|
+
trust_score: agent.trustScore,
|
|
179
|
+
certified_at: new Date(agent.certification.certified_at).toISOString(),
|
|
180
|
+
expires_at: new Date(agent.certification.expires_at).toISOString(),
|
|
181
|
+
capabilities: agent.metadata.capabilities,
|
|
182
|
+
constraints: {
|
|
183
|
+
max_transaction_value: agent.constraints.max_op_value,
|
|
184
|
+
allowed_domains: [],
|
|
185
|
+
// Placeholder
|
|
186
|
+
requires_human_approval: false,
|
|
187
|
+
requires_x402_payment: Boolean(agent.constraints?.requires_x402_payment ?? true)
|
|
188
|
+
},
|
|
189
|
+
issuer: "agntor.com",
|
|
190
|
+
signature: `agntor:${agent.agentId}:${Date.now()}`
|
|
191
|
+
// Real signatures require on-chain integration
|
|
192
|
+
};
|
|
193
|
+
return {
|
|
194
|
+
content: [{ type: "text", text: JSON.stringify(card) }],
|
|
195
|
+
structuredContent: card
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
server.registerTool(
|
|
200
|
+
"get_agent_registration",
|
|
201
|
+
{
|
|
202
|
+
title: "Get Agent Registration",
|
|
203
|
+
description: "Retrieve the EIP-8004 agent registration file",
|
|
204
|
+
inputSchema: {
|
|
205
|
+
agentId: z3.string().describe("The agent ID to retrieve")
|
|
206
|
+
},
|
|
207
|
+
outputSchema: AgentRegistrationSchema
|
|
208
|
+
},
|
|
209
|
+
async ({ agentId }) => {
|
|
210
|
+
const agent = await getAgentRecord(agentId);
|
|
211
|
+
if (!agent) {
|
|
212
|
+
throw new Error(`Agent ${agentId} not found`);
|
|
213
|
+
}
|
|
214
|
+
const registry = agent.metadata?.agentRegistry ?? "eip155:1:0x0000000000000000000000000000000000000000";
|
|
215
|
+
const registrationId = Number.parseInt(agent.agentId, 10);
|
|
216
|
+
const endpoints = agent.metadata?.endpoints ?? [
|
|
217
|
+
{
|
|
218
|
+
name: "MCP",
|
|
219
|
+
endpoint: "https://agntor.com/mcp",
|
|
220
|
+
version: "2025-06-18",
|
|
221
|
+
capabilities: agent.metadata.capabilities ?? []
|
|
222
|
+
}
|
|
223
|
+
];
|
|
224
|
+
const registration = {
|
|
225
|
+
type: "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
|
|
226
|
+
name: agent.metadata.name,
|
|
227
|
+
description: agent.metadata.description || "Agntor-registered agent",
|
|
228
|
+
image: agent.metadata?.image,
|
|
229
|
+
endpoints,
|
|
230
|
+
x402Support: true,
|
|
231
|
+
active: !agent.killSwitchActive,
|
|
232
|
+
registrations: [
|
|
233
|
+
{
|
|
234
|
+
agentId: Number.isNaN(registrationId) ? 0 : registrationId,
|
|
235
|
+
agentRegistry: registry
|
|
236
|
+
}
|
|
237
|
+
],
|
|
238
|
+
supportedTrust: ["reputation", "validation", "crypto-economic"]
|
|
239
|
+
};
|
|
240
|
+
return {
|
|
241
|
+
content: [{ type: "text", text: JSON.stringify(registration) }],
|
|
242
|
+
structuredContent: registration
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
server.registerTool(
|
|
247
|
+
"check_agent_pulse",
|
|
248
|
+
{
|
|
249
|
+
title: "Check Agent Pulse",
|
|
250
|
+
description: "Get real-time health and behavioral metrics",
|
|
251
|
+
inputSchema: {
|
|
252
|
+
agentId: z3.string()
|
|
253
|
+
},
|
|
254
|
+
outputSchema: AgentPulseSchema
|
|
255
|
+
},
|
|
256
|
+
async ({ agentId }) => {
|
|
257
|
+
const agent = await getAgentRecord(agentId);
|
|
258
|
+
if (!agent)
|
|
259
|
+
throw new Error(`Agent ${agentId} not found`);
|
|
260
|
+
const pulse = {
|
|
261
|
+
agent_id: agent.agentId,
|
|
262
|
+
status: agent.killSwitchActive ? "critical" : "healthy",
|
|
263
|
+
metrics: {
|
|
264
|
+
uptime_24h: agent.health.uptime_percentage,
|
|
265
|
+
error_rate_1h: agent.health.error_rate,
|
|
266
|
+
avg_latency_ms: agent.health.avg_latency_ms,
|
|
267
|
+
spend_velocity_1h: 0
|
|
268
|
+
// Placeholder
|
|
269
|
+
},
|
|
270
|
+
last_heartbeat: new Date(agent.health.last_active).toISOString()
|
|
271
|
+
};
|
|
272
|
+
return {
|
|
273
|
+
content: [{ type: "text", text: JSON.stringify(pulse) }],
|
|
274
|
+
structuredContent: pulse
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
server.registerTool(
|
|
279
|
+
"is_agent_certified",
|
|
280
|
+
{
|
|
281
|
+
title: "Check Agent Certification",
|
|
282
|
+
description: "Verify if an agent has valid Agntor certification",
|
|
283
|
+
inputSchema: {
|
|
284
|
+
agentId: z3.string().describe("The agent ID to check")
|
|
285
|
+
},
|
|
286
|
+
outputSchema: {
|
|
287
|
+
certified: z3.boolean(),
|
|
288
|
+
agentId: z3.string(),
|
|
289
|
+
auditLevel: z3.string().optional(),
|
|
290
|
+
expiresAt: z3.number().optional(),
|
|
291
|
+
killSwitchActive: z3.boolean().optional()
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
async ({ agentId }) => {
|
|
295
|
+
const agent = await getAgentRecord(agentId);
|
|
296
|
+
if (!agent) {
|
|
297
|
+
const output2 = { certified: false, agentId };
|
|
298
|
+
return {
|
|
299
|
+
content: [{ type: "text", text: JSON.stringify(output2) }],
|
|
300
|
+
structuredContent: output2
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
const now = Date.now();
|
|
304
|
+
const isCertified = agent.certification.expires_at > now && !agent.killSwitchActive;
|
|
305
|
+
const output = {
|
|
306
|
+
certified: isCertified,
|
|
307
|
+
agentId: agent.agentId,
|
|
308
|
+
auditLevel: agent.auditLevel,
|
|
309
|
+
expiresAt: agent.certification.expires_at,
|
|
310
|
+
killSwitchActive: agent.killSwitchActive
|
|
311
|
+
};
|
|
312
|
+
return {
|
|
313
|
+
content: [{ type: "text", text: JSON.stringify(output) }],
|
|
314
|
+
structuredContent: output
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
);
|
|
318
|
+
server.registerTool(
|
|
319
|
+
"guard_input",
|
|
320
|
+
{
|
|
321
|
+
title: "Guard Input",
|
|
322
|
+
description: "Scan incoming prompts for unsafe or malicious instructions",
|
|
323
|
+
inputSchema: {
|
|
324
|
+
input: z3.string(),
|
|
325
|
+
context: z3.any().optional(),
|
|
326
|
+
policy: z3.any().optional()
|
|
327
|
+
},
|
|
328
|
+
outputSchema: {
|
|
329
|
+
classification: z3.enum(["pass", "block"]),
|
|
330
|
+
violation_types: z3.array(z3.string()),
|
|
331
|
+
cwe_codes: z3.array(z3.string()),
|
|
332
|
+
usage: z3.object({
|
|
333
|
+
promptTokens: z3.number(),
|
|
334
|
+
completionTokens: z3.number(),
|
|
335
|
+
totalTokens: z3.number()
|
|
336
|
+
}).optional()
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
async ({ input, policy }) => {
|
|
340
|
+
const result = await guard(input, policy ?? {});
|
|
341
|
+
return {
|
|
342
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
343
|
+
structuredContent: result
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
);
|
|
347
|
+
server.registerTool(
|
|
348
|
+
"redact_output",
|
|
349
|
+
{
|
|
350
|
+
title: "Redact Output",
|
|
351
|
+
description: "Scan and redact sensitive content from outputs",
|
|
352
|
+
inputSchema: {
|
|
353
|
+
input: z3.string(),
|
|
354
|
+
policy: z3.any().optional()
|
|
355
|
+
},
|
|
356
|
+
outputSchema: {
|
|
357
|
+
redacted: z3.string(),
|
|
358
|
+
findings: z3.array(z3.object({
|
|
359
|
+
type: z3.string(),
|
|
360
|
+
span: z3.tuple([z3.number(), z3.number()]),
|
|
361
|
+
value: z3.string().optional()
|
|
362
|
+
}))
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
async ({ input, policy }) => {
|
|
366
|
+
const result = redact(input, policy ?? {});
|
|
367
|
+
return {
|
|
368
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
369
|
+
structuredContent: result
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
);
|
|
373
|
+
server.registerTool(
|
|
374
|
+
"guard_tool",
|
|
375
|
+
{
|
|
376
|
+
title: "Guard Tool",
|
|
377
|
+
description: "Authorize or block tool execution",
|
|
378
|
+
inputSchema: {
|
|
379
|
+
tool: z3.string(),
|
|
380
|
+
args: z3.any(),
|
|
381
|
+
policy: z3.any().optional()
|
|
382
|
+
},
|
|
383
|
+
outputSchema: {
|
|
384
|
+
allowed: z3.boolean(),
|
|
385
|
+
violations: z3.array(z3.string()).optional(),
|
|
386
|
+
reason: z3.string().optional()
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
async ({ tool, args, policy }) => {
|
|
390
|
+
const result = guardTool(tool, args, policy ?? {});
|
|
391
|
+
return {
|
|
392
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
393
|
+
structuredContent: result
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
server.registerTool(
|
|
398
|
+
"get_trust_score",
|
|
399
|
+
{
|
|
400
|
+
title: "Get Agent Trust Score",
|
|
401
|
+
description: "Calculate comprehensive trust score with behavioral factors",
|
|
402
|
+
inputSchema: VerifyAgentRequest.shape,
|
|
403
|
+
outputSchema: {
|
|
404
|
+
agentId: z3.string(),
|
|
405
|
+
score: z3.number(),
|
|
406
|
+
level: z3.string(),
|
|
407
|
+
factors: z3.object({
|
|
408
|
+
certification: z3.number(),
|
|
409
|
+
behavioral_health: z3.number(),
|
|
410
|
+
transaction_history: z3.number(),
|
|
411
|
+
domain_verification: z3.number()
|
|
412
|
+
}),
|
|
413
|
+
recommendation: z3.enum(["approve", "review", "reject"]),
|
|
414
|
+
details: z3.any().optional()
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
async ({ agentId, includeHealth }) => {
|
|
418
|
+
const agntor = getAgntorClient();
|
|
419
|
+
try {
|
|
420
|
+
const agentData = await agntor.getAgent(agentId);
|
|
421
|
+
const score = agentData?.trust?.score ?? 0;
|
|
422
|
+
const trustScore = {
|
|
423
|
+
agentId,
|
|
424
|
+
score: score || 0,
|
|
425
|
+
level: agentData.auditLevel || "None",
|
|
426
|
+
factors: {
|
|
427
|
+
certification: agentData.trust?.factors?.certification || 0,
|
|
428
|
+
behavioral_health: agentData.trust?.factors?.behavioral_health || 0,
|
|
429
|
+
transaction_history: agentData.trust?.factors?.transaction_history || 0,
|
|
430
|
+
domain_verification: agentData.trust?.factors?.domain_verification || 0
|
|
431
|
+
},
|
|
432
|
+
recommendation: score >= 80 ? "approve" : score >= 60 ? "review" : "reject"
|
|
433
|
+
};
|
|
434
|
+
const output = {
|
|
435
|
+
...trustScore,
|
|
436
|
+
details: includeHealth ? agentData.health : void 0
|
|
437
|
+
};
|
|
438
|
+
return {
|
|
439
|
+
content: [{ type: "text", text: JSON.stringify(output) }],
|
|
440
|
+
structuredContent: output
|
|
441
|
+
};
|
|
442
|
+
} catch (error) {
|
|
443
|
+
return {
|
|
444
|
+
content: [{ type: "text", text: `Error fetching trust score: ${error}` }],
|
|
445
|
+
isError: true
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
);
|
|
450
|
+
server.registerTool(
|
|
451
|
+
"issue_audit_ticket",
|
|
452
|
+
{
|
|
453
|
+
title: "Issue Audit Ticket",
|
|
454
|
+
description: "Generate signed JWT ticket for x402 transactions",
|
|
455
|
+
inputSchema: IssueTicketRequest.shape,
|
|
456
|
+
outputSchema: {
|
|
457
|
+
success: z3.boolean(),
|
|
458
|
+
ticket: z3.string().optional(),
|
|
459
|
+
agentId: z3.string(),
|
|
460
|
+
expiresIn: z3.number().optional(),
|
|
461
|
+
error: z3.string().optional()
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
async ({ agentId, validitySeconds }) => {
|
|
465
|
+
const agent = await getAgentRecord(agentId);
|
|
466
|
+
if (!agent) {
|
|
467
|
+
return {
|
|
468
|
+
content: [{ type: "text", text: "Agent not found" }],
|
|
469
|
+
structuredContent: {
|
|
470
|
+
success: false,
|
|
471
|
+
agentId,
|
|
472
|
+
error: "Agent not found"
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
if (agent.killSwitchActive) {
|
|
477
|
+
return {
|
|
478
|
+
content: [{ type: "text", text: "Agent kill switch active" }],
|
|
479
|
+
structuredContent: {
|
|
480
|
+
success: false,
|
|
481
|
+
agentId,
|
|
482
|
+
error: "Agent kill switch active"
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
const ticket = issuer.generateTicket({
|
|
487
|
+
agentId: agent.agentId,
|
|
488
|
+
auditLevel: agent.auditLevel,
|
|
489
|
+
constraints: agent.constraints,
|
|
490
|
+
validitySeconds
|
|
491
|
+
});
|
|
492
|
+
const output = {
|
|
493
|
+
success: true,
|
|
494
|
+
ticket,
|
|
495
|
+
agentId,
|
|
496
|
+
expiresIn: validitySeconds || 300
|
|
497
|
+
};
|
|
498
|
+
return {
|
|
499
|
+
content: [{ type: "text", text: JSON.stringify(output) }],
|
|
500
|
+
structuredContent: output
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
);
|
|
504
|
+
server.registerTool(
|
|
505
|
+
"query_agents",
|
|
506
|
+
{
|
|
507
|
+
title: "Query Agents",
|
|
508
|
+
description: "Search for agents by criteria",
|
|
509
|
+
inputSchema: QueryAgentsRequest.shape,
|
|
510
|
+
outputSchema: {
|
|
511
|
+
results: z3.array(z3.any()),
|
|
512
|
+
total: z3.number()
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
async ({ minTrustScore, auditLevel, capabilities, limit }) => {
|
|
516
|
+
const agntor = getAgntorClient();
|
|
517
|
+
try {
|
|
518
|
+
const response = await agntor.queryAgents({ minTrustScore, auditLevel, capabilities, limit });
|
|
519
|
+
return {
|
|
520
|
+
content: [{ type: "text", text: JSON.stringify(response.results) }],
|
|
521
|
+
structuredContent: response
|
|
522
|
+
};
|
|
523
|
+
} catch (error) {
|
|
524
|
+
return {
|
|
525
|
+
content: [{ type: "text", text: `Error querying agents: ${error}` }],
|
|
526
|
+
isError: true
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
);
|
|
531
|
+
server.registerTool(
|
|
532
|
+
"activate_kill_switch",
|
|
533
|
+
{
|
|
534
|
+
title: "Activate Kill Switch",
|
|
535
|
+
description: "Emergency disable an agent",
|
|
536
|
+
inputSchema: KillSwitchRequest.shape,
|
|
537
|
+
outputSchema: {
|
|
538
|
+
success: z3.boolean(),
|
|
539
|
+
agentId: z3.string(),
|
|
540
|
+
timestamp: z3.number(),
|
|
541
|
+
reason: z3.string()
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
async ({ agentId, reason }) => {
|
|
545
|
+
const agntor = getAgntorClient();
|
|
546
|
+
try {
|
|
547
|
+
const result = await agntor.activateKillSwitch(agentId, reason);
|
|
548
|
+
return {
|
|
549
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
550
|
+
structuredContent: result
|
|
551
|
+
};
|
|
552
|
+
} catch (error) {
|
|
553
|
+
return {
|
|
554
|
+
content: [{ type: "text", text: `Error activating kill switch: ${error}` }],
|
|
555
|
+
isError: true
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
);
|
|
560
|
+
server.registerTool(
|
|
561
|
+
"create_escrow",
|
|
562
|
+
{
|
|
563
|
+
title: "Create Escrow",
|
|
564
|
+
description: "Create a new escrow task for payment",
|
|
565
|
+
inputSchema: z3.object({
|
|
566
|
+
agentId: z3.string(),
|
|
567
|
+
target: z3.string(),
|
|
568
|
+
amount: z3.number(),
|
|
569
|
+
task: z3.string()
|
|
570
|
+
}),
|
|
571
|
+
outputSchema: z3.any()
|
|
572
|
+
},
|
|
573
|
+
async ({ agentId, target, amount, task }) => {
|
|
574
|
+
const agntor = getAgntorClient();
|
|
575
|
+
try {
|
|
576
|
+
const result = await agntor.createEscrowLegacy({ agentId, target, amount, task });
|
|
577
|
+
return {
|
|
578
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
579
|
+
structuredContent: result
|
|
580
|
+
};
|
|
581
|
+
} catch (e) {
|
|
582
|
+
return {
|
|
583
|
+
content: [{ type: "text", text: `Error: ${e.message}` }],
|
|
584
|
+
isError: true
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
);
|
|
589
|
+
server.registerTool(
|
|
590
|
+
"verify_agent_identity",
|
|
591
|
+
{
|
|
592
|
+
title: "Verify Agent Identity",
|
|
593
|
+
description: "Trigger self-verification via SDK",
|
|
594
|
+
inputSchema: z3.object({
|
|
595
|
+
agentId: z3.string().optional()
|
|
596
|
+
}),
|
|
597
|
+
outputSchema: z3.any()
|
|
598
|
+
},
|
|
599
|
+
async ({ agentId }) => {
|
|
600
|
+
const agntor = getAgntorClient();
|
|
601
|
+
try {
|
|
602
|
+
const result = await agntor.verifyLegacy(agentId);
|
|
603
|
+
return {
|
|
604
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
605
|
+
structuredContent: result
|
|
606
|
+
};
|
|
607
|
+
} catch (e) {
|
|
608
|
+
return {
|
|
609
|
+
content: [{ type: "text", text: `Error: ${e.message}` }],
|
|
610
|
+
isError: true
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
);
|
|
615
|
+
server.registerTool(
|
|
616
|
+
"register_agent",
|
|
617
|
+
{
|
|
618
|
+
title: "Register Agent",
|
|
619
|
+
description: "Register a new AI agent in the Agntor trust network",
|
|
620
|
+
inputSchema: z3.object({
|
|
621
|
+
name: z3.string().describe("Unique agent name/handle"),
|
|
622
|
+
organization: z3.string().optional().describe("Organization or company name"),
|
|
623
|
+
description: z3.string().optional().describe("What this agent does"),
|
|
624
|
+
capabilities: z3.array(z3.string()).optional().describe('Agent capabilities (e.g. ["trade", "email", "search"])'),
|
|
625
|
+
endpoint: z3.string().optional().describe("Agent API endpoint URL"),
|
|
626
|
+
walletAddress: z3.string().optional().describe("Blockchain wallet address")
|
|
627
|
+
}),
|
|
628
|
+
outputSchema: z3.object({
|
|
629
|
+
success: z3.boolean(),
|
|
630
|
+
agent: z3.object({
|
|
631
|
+
id: z3.string(),
|
|
632
|
+
name: z3.string(),
|
|
633
|
+
organization: z3.string(),
|
|
634
|
+
auditLevel: z3.string(),
|
|
635
|
+
trustScore: z3.number(),
|
|
636
|
+
status: z3.string()
|
|
637
|
+
}).optional(),
|
|
638
|
+
message: z3.string().optional(),
|
|
639
|
+
error: z3.string().optional()
|
|
640
|
+
})
|
|
641
|
+
},
|
|
642
|
+
async ({ name, organization, description, capabilities, endpoint, walletAddress }) => {
|
|
643
|
+
const agntor = getAgntorClient();
|
|
644
|
+
try {
|
|
645
|
+
const result = await agntor.request("/api/v1/identity/register", {
|
|
646
|
+
method: "POST",
|
|
647
|
+
body: JSON.stringify({
|
|
648
|
+
name,
|
|
649
|
+
organization,
|
|
650
|
+
description,
|
|
651
|
+
capabilities,
|
|
652
|
+
endpoint,
|
|
653
|
+
walletAddress
|
|
654
|
+
})
|
|
655
|
+
});
|
|
656
|
+
return {
|
|
657
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
658
|
+
structuredContent: result
|
|
659
|
+
};
|
|
660
|
+
} catch (e) {
|
|
661
|
+
return {
|
|
662
|
+
content: [{ type: "text", text: `Error: ${e.message}` }],
|
|
663
|
+
isError: true
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
);
|
|
668
|
+
return server;
|
|
669
|
+
}
|
|
670
|
+
export {
|
|
671
|
+
createAgntorMcpServer
|
|
672
|
+
};
|