@agledger/mcp-server 1.2.0 → 1.3.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 +1 -1
- package/README.md +1 -1
- package/dist/enums.d.ts +0 -1
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +0 -1
- package/dist/enums.js.map +1 -1
- package/dist/errors.d.ts +0 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +0 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/resources/contract-types.d.ts +0 -1
- package/dist/resources/contract-types.d.ts.map +1 -1
- package/dist/resources/contract-types.js +0 -3
- package/dist/resources/contract-types.js.map +1 -1
- package/dist/server.d.ts +0 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -3
- package/dist/server.js.map +1 -1
- package/dist/tool-scopes.d.ts +0 -12
- package/dist/tool-scopes.d.ts.map +1 -1
- package/dist/tool-scopes.js +20 -30
- package/dist/tool-scopes.js.map +1 -1
- package/dist/tools/a2a.d.ts +0 -1
- package/dist/tools/a2a.d.ts.map +1 -1
- package/dist/tools/a2a.js +21 -52
- package/dist/tools/a2a.js.map +1 -1
- package/dist/tools/agent-mandates.d.ts +0 -1
- package/dist/tools/agent-mandates.d.ts.map +1 -1
- package/dist/tools/agent-mandates.js +0 -10
- package/dist/tools/agent-mandates.js.map +1 -1
- package/dist/tools/agents-refs.d.ts +0 -1
- package/dist/tools/agents-refs.d.ts.map +1 -1
- package/dist/tools/agents-refs.js +0 -8
- package/dist/tools/agents-refs.js.map +1 -1
- package/dist/tools/capabilities.d.ts +0 -1
- package/dist/tools/capabilities.d.ts.map +1 -1
- package/dist/tools/capabilities.js +0 -3
- package/dist/tools/capabilities.js.map +1 -1
- package/dist/tools/code-mode.d.ts +0 -1
- package/dist/tools/code-mode.d.ts.map +1 -1
- package/dist/tools/code-mode.js +4 -10
- package/dist/tools/code-mode.js.map +1 -1
- package/dist/tools/compliance.d.ts +0 -1
- package/dist/tools/compliance.d.ts.map +1 -1
- package/dist/tools/compliance.js +0 -1
- package/dist/tools/compliance.js.map +1 -1
- package/dist/tools/dashboard.d.ts +0 -1
- package/dist/tools/dashboard.d.ts.map +1 -1
- package/dist/tools/dashboard.js +0 -1
- package/dist/tools/dashboard.js.map +1 -1
- package/dist/tools/disputes.d.ts +0 -1
- package/dist/tools/disputes.d.ts.map +1 -1
- package/dist/tools/disputes.js +0 -5
- package/dist/tools/disputes.js.map +1 -1
- package/dist/tools/enterprises.d.ts +0 -1
- package/dist/tools/enterprises.d.ts.map +1 -1
- package/dist/tools/enterprises.js +0 -7
- package/dist/tools/enterprises.js.map +1 -1
- package/dist/tools/events.d.ts +0 -1
- package/dist/tools/events.d.ts.map +1 -1
- package/dist/tools/events.js +0 -2
- package/dist/tools/events.js.map +1 -1
- package/dist/tools/federation-admin.d.ts +0 -1
- package/dist/tools/federation-admin.d.ts.map +1 -1
- package/dist/tools/federation-admin.js +0 -25
- package/dist/tools/federation-admin.js.map +1 -1
- package/dist/tools/federation.d.ts +0 -1
- package/dist/tools/federation.d.ts.map +1 -1
- package/dist/tools/federation.js +0 -21
- package/dist/tools/federation.js.map +1 -1
- package/dist/tools/health.d.ts +0 -1
- package/dist/tools/health.d.ts.map +1 -1
- package/dist/tools/health.js +0 -2
- package/dist/tools/health.js.map +1 -1
- package/dist/tools/mandates.d.ts +0 -1
- package/dist/tools/mandates.d.ts.map +1 -1
- package/dist/tools/mandates.js +0 -11
- package/dist/tools/mandates.js.map +1 -1
- package/dist/tools/openclaw.d.ts +0 -5
- package/dist/tools/openclaw.d.ts.map +1 -1
- package/dist/tools/openclaw.js +0 -5
- package/dist/tools/openclaw.js.map +1 -1
- package/dist/tools/receipts.d.ts +0 -1
- package/dist/tools/receipts.d.ts.map +1 -1
- package/dist/tools/receipts.js +3 -8
- package/dist/tools/receipts.js.map +1 -1
- package/dist/tools/reputation.d.ts +0 -1
- package/dist/tools/reputation.d.ts.map +1 -1
- package/dist/tools/reputation.js +0 -1
- package/dist/tools/reputation.js.map +1 -1
- package/dist/tools/schemas.d.ts +0 -1
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +0 -17
- package/dist/tools/schemas.js.map +1 -1
- package/dist/tools/verification-keys.d.ts +4 -0
- package/dist/tools/verification-keys.d.ts.map +1 -0
- package/dist/tools/verification-keys.js +48 -0
- package/dist/tools/verification-keys.js.map +1 -0
- package/dist/tools/verification.d.ts +0 -1
- package/dist/tools/verification.d.ts.map +1 -1
- package/dist/tools/verification.js +0 -3
- package/dist/tools/verification.js.map +1 -1
- package/package.json +2 -7
- package/src/enums.ts +46 -0
- package/src/errors.ts +35 -0
- package/src/index.ts +100 -0
- package/src/resources/contract-types.ts +130 -0
- package/src/server.ts +132 -0
- package/src/tool-scopes.ts +180 -0
- package/src/tools/a2a.ts +519 -0
- package/src/tools/agent-mandates.ts +325 -0
- package/src/tools/agents-refs.ts +287 -0
- package/src/tools/capabilities.ts +76 -0
- package/src/tools/code-mode.ts +461 -0
- package/src/tools/compliance.ts +79 -0
- package/src/tools/dashboard.ts +73 -0
- package/src/tools/disputes.ts +154 -0
- package/src/tools/enterprises.ts +235 -0
- package/src/tools/events.ts +52 -0
- package/src/tools/federation-admin.ts +922 -0
- package/src/tools/federation.ts +784 -0
- package/src/tools/health.ts +43 -0
- package/src/tools/mandates.ts +382 -0
- package/src/tools/openclaw.ts +168 -0
- package/src/tools/receipts.ts +179 -0
- package/src/tools/reputation.ts +78 -0
- package/src/tools/schemas.ts +667 -0
- package/src/tools/verification-keys.ts +56 -0
- package/src/tools/verification.ts +85 -0
- package/tests/code-mode-manifest.test.ts +144 -0
- package/tests/enterprises.test.ts +96 -0
- package/tests/schemas.test.ts +531 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import type { AgledgerClient } from '@agledger/sdk';
|
|
4
|
+
import { apiErrorResult } from '../errors.js';
|
|
5
|
+
import { NextStepsField, ReceiptStatusEnum } from '../enums.js';
|
|
6
|
+
import { toolMeta } from '../tool-scopes.js';
|
|
7
|
+
|
|
8
|
+
const ReceiptOutputSchema = z.object({
|
|
9
|
+
id: z.string().describe('Receipt UUID'),
|
|
10
|
+
mandateId: z.string().describe('Associated mandate UUID'),
|
|
11
|
+
agentId: z.string().describe('Agent that submitted the receipt'),
|
|
12
|
+
status: ReceiptStatusEnum,
|
|
13
|
+
evidence: z.record(z.string(), z.unknown()).describe('Evidence payload'),
|
|
14
|
+
evidenceHash: z.string().nullable().optional().describe('SHA-256 hash of evidence'),
|
|
15
|
+
notes: z.string().nullable().optional().describe('Human-readable notes'),
|
|
16
|
+
verificationPhase: z.string().nullable().optional().describe('Current verification phase'),
|
|
17
|
+
verificationResult: z.record(z.string(), z.unknown()).nullable().optional().describe('Verification result details'),
|
|
18
|
+
validationErrors: z.array(z.string()).nullable().optional().describe('Validation errors if any'),
|
|
19
|
+
idempotencyKey: z.string().nullable().optional().describe('Idempotency key for deduplication'),
|
|
20
|
+
createdAt: z.string().describe('ISO 8601 creation timestamp'),
|
|
21
|
+
updatedAt: z.string().nullable().optional().describe('ISO 8601 last update timestamp'),
|
|
22
|
+
nextSteps: NextStepsField,
|
|
23
|
+
}).passthrough().describe('AGLedger receipt (task attestation) object');
|
|
24
|
+
|
|
25
|
+
const ReceiptListOutputSchema = z.object({
|
|
26
|
+
data: z.array(ReceiptOutputSchema).describe('Array of receipts for the mandate'),
|
|
27
|
+
nextCursor: z.string().nullable().optional().describe('Cursor for the next page (null if no more results)'),
|
|
28
|
+
}).passthrough().describe('List of receipts for a mandate');
|
|
29
|
+
|
|
30
|
+
export function registerReceiptTools(mcp: McpServer, client: AgledgerClient): void {
|
|
31
|
+
mcp.registerTool(
|
|
32
|
+
'submit_receipt',
|
|
33
|
+
{
|
|
34
|
+
title: 'Submit Receipt',
|
|
35
|
+
description: 'Submit a task attestation (receipt) with evidence against a mandate. REQUIRED to close the accountability loop — do NOT skip this step after completing work.',
|
|
36
|
+
inputSchema: {
|
|
37
|
+
mandateId: z.string().describe('UUID of the mandate this receipt is for'),
|
|
38
|
+
agentId: z.string().describe('Agent ID submitting the receipt'),
|
|
39
|
+
evidence: z.record(z.string(), z.unknown()).describe('Evidence JSON object proving task completion'),
|
|
40
|
+
notes: z.string().optional().describe('Human-readable notes about the submission'),
|
|
41
|
+
},
|
|
42
|
+
outputSchema: ReceiptOutputSchema,
|
|
43
|
+
annotations: {
|
|
44
|
+
readOnlyHint: false,
|
|
45
|
+
destructiveHint: false,
|
|
46
|
+
idempotentHint: false,
|
|
47
|
+
openWorldHint: true,
|
|
48
|
+
},
|
|
49
|
+
_meta: toolMeta('submit_receipt'),
|
|
50
|
+
},
|
|
51
|
+
async (args) => {
|
|
52
|
+
try {
|
|
53
|
+
const { mandateId, ...submitParams } = args;
|
|
54
|
+
const receipt = await client.receipts.submit(mandateId, submitParams);
|
|
55
|
+
let text = ` Receipt ${receipt.id} submitted for mandate ${mandateId}. Status: ${receipt.structuralValidation}.`;
|
|
56
|
+
// Use denormalized mandateStatus from receipt response (no extra API call)
|
|
57
|
+
const ms = receipt.mandateStatus;
|
|
58
|
+
if (ms === 'FULFILLED') {
|
|
59
|
+
text += '\n\n Mandate settled to FULFILLED. Accountability loop closed.';
|
|
60
|
+
} else if (ms === 'PROCESSING') {
|
|
61
|
+
text += '\n\n Evidence is being verified. The principal will accept or reject.';
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
content: [{ type: 'text', text }],
|
|
65
|
+
structuredContent: receipt as unknown as Record<string, unknown>,
|
|
66
|
+
};
|
|
67
|
+
} catch (err) {
|
|
68
|
+
return apiErrorResult(err);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
mcp.registerTool(
|
|
74
|
+
'report_outcome',
|
|
75
|
+
{
|
|
76
|
+
title: 'Report Outcome',
|
|
77
|
+
description: 'Report the principal verdict (PASS or FAIL) on a receipt. PASS accepts the receipt; FAIL rejects it. This is the standard way to close the accountability loop.',
|
|
78
|
+
inputSchema: {
|
|
79
|
+
mandateId: z.string().describe('UUID of the mandate'),
|
|
80
|
+
receiptId: z.string().describe('UUID of the receipt to judge'),
|
|
81
|
+
outcome: z.enum(['PASS', 'FAIL']).describe('Verdict: PASS (accept) or FAIL (reject)'),
|
|
82
|
+
checks: z.record(z.string(), z.unknown()).optional().describe('Optional per-field check results'),
|
|
83
|
+
},
|
|
84
|
+
outputSchema: z.object({
|
|
85
|
+
mandateId: z.string().describe('Mandate UUID'),
|
|
86
|
+
receiptId: z.string().describe('Receipt UUID'),
|
|
87
|
+
outcome: z.enum(['PASS', 'FAIL']).describe('Reported outcome'),
|
|
88
|
+
signal: z.string().describe('Settlement signal: SETTLE, HOLD, or RELEASE'),
|
|
89
|
+
reporterType: z.string().describe('Who reported: principal'),
|
|
90
|
+
reportedAt: z.string().describe('ISO 8601 timestamp'),
|
|
91
|
+
nextSteps: NextStepsField,
|
|
92
|
+
}).passthrough().describe('Outcome result'),
|
|
93
|
+
annotations: {
|
|
94
|
+
readOnlyHint: false,
|
|
95
|
+
destructiveHint: false,
|
|
96
|
+
idempotentHint: true,
|
|
97
|
+
openWorldHint: true,
|
|
98
|
+
},
|
|
99
|
+
_meta: toolMeta('report_outcome'),
|
|
100
|
+
},
|
|
101
|
+
async (args) => {
|
|
102
|
+
try {
|
|
103
|
+
const { mandateId, ...outcomeParams } = args;
|
|
104
|
+
const result = await client.mandates.reportOutcome(mandateId, outcomeParams);
|
|
105
|
+
const verb = result.outcome === 'PASS' ? 'accepted' : 'rejected';
|
|
106
|
+
return {
|
|
107
|
+
content: [{ type: 'text', text: `Receipt ${args.receiptId} ${verb}. Signal: ${result.signal}.` }],
|
|
108
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
109
|
+
};
|
|
110
|
+
} catch (err) {
|
|
111
|
+
return apiErrorResult(err);
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
mcp.registerTool(
|
|
117
|
+
'get_receipt',
|
|
118
|
+
{
|
|
119
|
+
title: 'Get Receipt',
|
|
120
|
+
description: 'Get a specific receipt by ID. Use list_receipts to find receipt IDs first.',
|
|
121
|
+
inputSchema: {
|
|
122
|
+
mandateId: z.string().describe('UUID of the associated mandate'),
|
|
123
|
+
receiptId: z.string().describe('UUID of the receipt to retrieve'),
|
|
124
|
+
},
|
|
125
|
+
outputSchema: ReceiptOutputSchema,
|
|
126
|
+
annotations: {
|
|
127
|
+
readOnlyHint: true,
|
|
128
|
+
destructiveHint: false,
|
|
129
|
+
idempotentHint: true,
|
|
130
|
+
openWorldHint: true,
|
|
131
|
+
},
|
|
132
|
+
_meta: toolMeta('get_receipt'),
|
|
133
|
+
},
|
|
134
|
+
async (args) => {
|
|
135
|
+
try {
|
|
136
|
+
const receipt = await client.receipts.get(args.mandateId, args.receiptId);
|
|
137
|
+
return {
|
|
138
|
+
content: [{ type: 'text', text: `Receipt ${receipt.id}: status=${receipt.structuralValidation}, mandate=${receipt.mandateId}.` }],
|
|
139
|
+
structuredContent: receipt as unknown as Record<string, unknown>,
|
|
140
|
+
};
|
|
141
|
+
} catch (err) {
|
|
142
|
+
return apiErrorResult(err);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
mcp.registerTool(
|
|
148
|
+
'list_receipts',
|
|
149
|
+
{
|
|
150
|
+
title: 'List Receipts',
|
|
151
|
+
description: 'List all receipts (task attestations) submitted against a mandate.',
|
|
152
|
+
inputSchema: {
|
|
153
|
+
mandateId: z.string().describe('UUID of the mandate to list receipts for'),
|
|
154
|
+
limit: z.number().optional().describe('Page size (default: 20)'),
|
|
155
|
+
offset: z.number().optional().describe('Page offset (default: 0)'),
|
|
156
|
+
},
|
|
157
|
+
outputSchema: ReceiptListOutputSchema,
|
|
158
|
+
annotations: {
|
|
159
|
+
readOnlyHint: true,
|
|
160
|
+
destructiveHint: false,
|
|
161
|
+
idempotentHint: true,
|
|
162
|
+
openWorldHint: true,
|
|
163
|
+
},
|
|
164
|
+
_meta: toolMeta('list_receipts'),
|
|
165
|
+
},
|
|
166
|
+
async (args) => {
|
|
167
|
+
try {
|
|
168
|
+
const { mandateId, ...paginationParams } = args;
|
|
169
|
+
const result = await client.receipts.list(mandateId, paginationParams);
|
|
170
|
+
return {
|
|
171
|
+
content: [{ type: 'text', text: `Found ${result.data.length} receipts for mandate ${mandateId}.` }],
|
|
172
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
173
|
+
};
|
|
174
|
+
} catch (err) {
|
|
175
|
+
return apiErrorResult(err);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
);
|
|
179
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import type { AgledgerClient } from '@agledger/sdk';
|
|
4
|
+
import { apiErrorResult } from '../errors.js';
|
|
5
|
+
import { toolMeta } from '../tool-scopes.js';
|
|
6
|
+
|
|
7
|
+
export function registerReputationTools(mcp: McpServer, client: AgledgerClient): void {
|
|
8
|
+
mcp.registerTool(
|
|
9
|
+
'get_agent_reputation',
|
|
10
|
+
{
|
|
11
|
+
title: 'Get Agent Reputation',
|
|
12
|
+
description: 'Get per-contract-type reputation scores for an agent. Returns paginated list with reliability, accuracy, efficiency, and composite scores for each contract type.',
|
|
13
|
+
inputSchema: {
|
|
14
|
+
agentId: z.string().describe('UUID of the agent'),
|
|
15
|
+
},
|
|
16
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
17
|
+
_meta: toolMeta('get_agent_reputation'),
|
|
18
|
+
},
|
|
19
|
+
async (args) => {
|
|
20
|
+
try {
|
|
21
|
+
const page = await client.reputation.getAgent(args.agentId);
|
|
22
|
+
return {
|
|
23
|
+
content: [{ type: 'text', text: `Agent ${args.agentId}: ${page.data.length} contract type score(s).` }],
|
|
24
|
+
structuredContent: page as unknown as Record<string, unknown>,
|
|
25
|
+
};
|
|
26
|
+
} catch (err) { return apiErrorResult(err); }
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
mcp.registerTool(
|
|
31
|
+
'get_reputation_by_type',
|
|
32
|
+
{
|
|
33
|
+
title: 'Get Reputation by Contract Type',
|
|
34
|
+
description: 'Get an agent\'s reputation score for a specific contract type. Returns reliability, accuracy, efficiency, and composite scores.',
|
|
35
|
+
inputSchema: {
|
|
36
|
+
agentId: z.string().describe('UUID of the agent'),
|
|
37
|
+
contractType: z.string().describe('Contract type (e.g., ACH-PROC-v1)'),
|
|
38
|
+
},
|
|
39
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
40
|
+
_meta: toolMeta('get_reputation_by_type'),
|
|
41
|
+
},
|
|
42
|
+
async (args) => {
|
|
43
|
+
try {
|
|
44
|
+
const score = await client.reputation.getByContractType(args.agentId, args.contractType);
|
|
45
|
+
return {
|
|
46
|
+
content: [{ type: 'text', text: `Agent ${args.agentId} [${args.contractType}]: composite=${score.compositeScore}, reliability=${score.reliabilityScore}, accuracy=${score.accuracyScore}, efficiency=${score.efficiencyScore}.` }],
|
|
47
|
+
structuredContent: score as unknown as Record<string, unknown>,
|
|
48
|
+
};
|
|
49
|
+
} catch (err) { return apiErrorResult(err); }
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
mcp.registerTool(
|
|
54
|
+
'get_agent_history',
|
|
55
|
+
{
|
|
56
|
+
title: 'Get Agent Transaction History',
|
|
57
|
+
description: 'Get an agent\'s mandate transaction history. Filter by contract type, outcome, and date range.',
|
|
58
|
+
inputSchema: {
|
|
59
|
+
agentId: z.string().describe('UUID of the agent'),
|
|
60
|
+
contractType: z.string().optional().describe('Filter by contract type'),
|
|
61
|
+
outcome: z.enum(['PASS', 'FAIL']).optional().describe('Filter by verdict outcome'),
|
|
62
|
+
limit: z.number().optional().describe('Page size'),
|
|
63
|
+
},
|
|
64
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
65
|
+
_meta: toolMeta('get_agent_history'),
|
|
66
|
+
},
|
|
67
|
+
async (args) => {
|
|
68
|
+
try {
|
|
69
|
+
const { agentId, ...params } = args;
|
|
70
|
+
const page = await client.reputation.getHistory(agentId, params);
|
|
71
|
+
return {
|
|
72
|
+
content: [{ type: 'text', text: `Agent ${agentId}: ${page.data.length} transaction(s).` }],
|
|
73
|
+
structuredContent: page as unknown as Record<string, unknown>,
|
|
74
|
+
};
|
|
75
|
+
} catch (err) { return apiErrorResult(err); }
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
}
|