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