@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,159 +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
- import { DisputeStatusEnum, NextStepsField } from '../enums.js';
7
-
8
- const DisputeOutputSchema = z.object({
9
- id: z.string().describe('Dispute UUID'),
10
- mandateId: z.string().describe('Associated mandate UUID'),
11
- receiptId: z.string().describe('Associated receipt UUID'),
12
- status: DisputeStatusEnum,
13
- reason: z.string().describe('Dispute reason/grounds'),
14
- evidence: z.record(z.string(), z.unknown()).nullable().optional().describe('Supporting evidence'),
15
- currentTier: z.number().describe('Current dispute resolution tier (1-3)'),
16
- tierHistory: z.array(z.record(z.string(), z.unknown())).nullable().optional().describe('History of tier transitions'),
17
- resolution: z.string().nullable().optional().describe('Resolution description'),
18
- amount: z.number().nullable().optional().describe('Settlement amount if applicable'),
19
- createdAt: z.string().describe('ISO 8601 creation timestamp'),
20
- updatedAt: z.string().nullable().optional().describe('ISO 8601 last update timestamp'),
21
- resolvedAt: z.string().nullable().optional().describe('ISO 8601 resolution timestamp'),
22
- nextSteps: NextStepsField,
23
- }).passthrough().describe('AGLedger dispute object');
24
-
25
- export function registerDisputeTools(mcp: McpServer, client: AgledgerClient): void {
26
- mcp.registerTool(
27
- 'create_dispute',
28
- {
29
- title: 'Create Dispute',
30
- description: 'Open a dispute on a mandate. Grounds examples: "pricing_dispute", "mandate_ambiguity", "quality_issue".',
31
- inputSchema: {
32
- mandateId: z.string().describe('UUID of the mandate to dispute'),
33
- grounds: z.string().describe('Dispute grounds (e.g. "pricing_dispute", "mandate_ambiguity")'),
34
- context: z.string().optional().describe('Additional context for the dispute'),
35
- },
36
- outputSchema: DisputeOutputSchema,
37
- annotations: {
38
- readOnlyHint: false,
39
- destructiveHint: false,
40
- idempotentHint: false,
41
- openWorldHint: true,
42
- },
43
- _meta: toolMeta('create_dispute'),
44
- },
45
- async (args) => {
46
- try {
47
- const { mandateId, ...disputeParams } = args;
48
- const dispute = await client.disputes.create(mandateId, disputeParams);
49
- return {
50
- content: [{ type: 'text', text: `Dispute ${dispute.id} opened on mandate ${mandateId}. Status: ${dispute.status}, tier: ${dispute.currentTier}.` }],
51
- structuredContent: toStructuredContent(dispute),
52
- };
53
- } catch (err) {
54
- return apiErrorResult(err);
55
- }
56
- },
57
- );
58
-
59
- mcp.registerTool(
60
- 'get_dispute',
61
- {
62
- title: 'Get Dispute',
63
- description: 'Get the dispute details for a mandate.',
64
- inputSchema: {
65
- mandateId: z.string().describe('UUID of the mandate with the dispute'),
66
- },
67
- outputSchema: DisputeOutputSchema,
68
- annotations: {
69
- readOnlyHint: true,
70
- destructiveHint: false,
71
- idempotentHint: true,
72
- openWorldHint: true,
73
- },
74
- _meta: toolMeta('get_dispute'),
75
- },
76
- async (args) => {
77
- try {
78
- const result = await client.disputes.get(args.mandateId);
79
- const dispute = result.dispute;
80
- return {
81
- content: [{ type: 'text', text: `Dispute ${dispute.id}: status=${dispute.status}, tier=${dispute.currentTier}, grounds="${dispute.grounds}". ${result.evidence?.length ?? 0} evidence item(s).` }],
82
- structuredContent: toStructuredContent(dispute),
83
- };
84
- } catch (err) {
85
- return apiErrorResult(err);
86
- }
87
- },
88
- );
89
-
90
- mcp.registerTool(
91
- 'escalate_dispute',
92
- {
93
- title: 'Escalate Dispute',
94
- description: 'Escalate a dispute to the next review tier. Use when tier-1 auto-resolution was insufficient.',
95
- inputSchema: {
96
- mandateId: z.string().describe('UUID of the mandate whose dispute to escalate'),
97
- },
98
- outputSchema: DisputeOutputSchema,
99
- annotations: {
100
- readOnlyHint: false,
101
- destructiveHint: false,
102
- idempotentHint: false,
103
- openWorldHint: true,
104
- },
105
- _meta: toolMeta('escalate_dispute'),
106
- },
107
- async (args) => {
108
- try {
109
- const dispute = await client.disputes.escalate(args.mandateId);
110
- return {
111
- content: [{ type: 'text', text: `Dispute on mandate ${args.mandateId} escalated to tier ${dispute.currentTier}. Status: ${dispute.status}.` }],
112
- structuredContent: toStructuredContent(dispute),
113
- };
114
- } catch (err) {
115
- return apiErrorResult(err);
116
- }
117
- },
118
- );
119
-
120
- mcp.registerTool(
121
- 'submit_dispute_evidence',
122
- {
123
- title: 'Submit Dispute Evidence',
124
- description: 'Submit additional evidence for an open dispute. Evidence types: screenshot, external_lookup, document, communication, other.',
125
- inputSchema: {
126
- mandateId: z.string().describe('UUID of the mandate whose dispute to submit evidence for'),
127
- evidenceType: z.enum(['screenshot', 'external_lookup', 'document', 'communication', 'other']).describe('Type of evidence being submitted'),
128
- payload: z.record(z.string(), z.unknown()).describe('Evidence payload object'),
129
- },
130
- outputSchema: z.object({
131
- id: z.string().describe('Evidence record ID'),
132
- evidenceType: z.string().describe('Type of evidence submitted'),
133
- createdAt: z.string().nullable().optional().describe('ISO 8601 creation timestamp'),
134
- }).passthrough().describe('Submitted dispute evidence confirmation'),
135
- annotations: {
136
- readOnlyHint: false,
137
- destructiveHint: false,
138
- idempotentHint: false,
139
- openWorldHint: true,
140
- },
141
- _meta: toolMeta('submit_dispute_evidence'),
142
- },
143
- async (args) => {
144
- try {
145
- const result = await client.disputes.submitEvidence(args.mandateId, {
146
- evidenceType: args.evidenceType,
147
- payload: args.payload,
148
- });
149
- return {
150
- content: [{ type: 'text', text: `Evidence submitted for dispute on mandate ${args.mandateId}. Type: ${args.evidenceType}.` }],
151
- structuredContent: toStructuredContent(result),
152
- };
153
- } catch (err) {
154
- return apiErrorResult(err);
155
- }
156
- },
157
- );
158
-
159
- }
@@ -1,259 +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
- export function registerEnterpriseTools(mcp: McpServer, client: AgledgerClient): void {
8
- mcp.registerTool(
9
- 'approve_enterprise_agent',
10
- {
11
- title: 'Approve Enterprise Agent',
12
- description: 'Approve an agent for use within an enterprise. The agent will be allowed to create mandates and submit receipts.',
13
- inputSchema: {
14
- enterpriseId: z.string().describe('Enterprise ID'),
15
- agentId: z.string().describe('Agent ID to approve'),
16
- reason: z.string().optional().describe('Reason for approval'),
17
- },
18
- outputSchema: z.object({
19
- agentId: z.string().describe('Approved agent ID'),
20
- enterpriseId: z.string().describe('Enterprise ID'),
21
- status: z.string().describe('Agent approval status'),
22
- approvedAt: z.string().nullable().optional().describe('ISO 8601 approval timestamp'),
23
- }).passthrough().describe('Enterprise agent approval result'),
24
- annotations: {
25
- readOnlyHint: false,
26
- destructiveHint: false,
27
- idempotentHint: true,
28
- openWorldHint: true,
29
- },
30
- _meta: toolMeta('approve_enterprise_agent'),
31
- },
32
- async (args) => {
33
- try {
34
- const record = await client.enterprises.approveAgent(args.enterpriseId, args.agentId, {
35
- reason: args.reason,
36
- });
37
- return {
38
- content: [{ type: 'text', text: `Agent ${args.agentId} approved for enterprise ${args.enterpriseId}.` }],
39
- structuredContent: toStructuredContent(record),
40
- };
41
- } catch (err) {
42
- return apiErrorResult(err);
43
- }
44
- },
45
- );
46
-
47
- mcp.registerTool(
48
- 'revoke_enterprise_agent',
49
- {
50
- title: 'Revoke Enterprise Agent',
51
- description: 'Revoke an agent\'s access to an enterprise. The agent will no longer be able to create mandates or submit receipts.',
52
- inputSchema: {
53
- enterpriseId: z.string().describe('Enterprise ID'),
54
- agentId: z.string().describe('Agent ID to revoke'),
55
- reason: z.string().optional().describe('Reason for revocation'),
56
- },
57
- outputSchema: z.object({
58
- enterpriseId: z.string().describe('Enterprise ID'),
59
- agentId: z.string().describe('Revoked agent ID'),
60
- status: z.string().describe('Agent status after revocation'),
61
- }).passthrough().describe('Enterprise agent revocation result'),
62
- annotations: {
63
- readOnlyHint: false,
64
- destructiveHint: true,
65
- idempotentHint: false,
66
- openWorldHint: true,
67
- },
68
- _meta: toolMeta('revoke_enterprise_agent'),
69
- },
70
- async (args) => {
71
- try {
72
- await client.enterprises.revokeAgent(args.enterpriseId, args.agentId, {
73
- reason: args.reason,
74
- });
75
- return {
76
- content: [{ type: 'text', text: `Agent ${args.agentId} revoked from enterprise ${args.enterpriseId}.` }],
77
- structuredContent: { enterpriseId: args.enterpriseId, agentId: args.agentId, status: 'revoked' },
78
- };
79
- } catch (err) {
80
- return apiErrorResult(err);
81
- }
82
- },
83
- );
84
-
85
- mcp.registerTool(
86
- 'list_enterprise_agents',
87
- {
88
- title: 'List Enterprise Agents',
89
- description: 'List agents registered with an enterprise, optionally filtered by status.',
90
- inputSchema: {
91
- enterpriseId: z.string().describe('Enterprise ID'),
92
- status: z.enum(['approved', 'suspended', 'revoked']).optional().describe('Filter by agent status'),
93
- limit: z.number().optional().describe('Page size'),
94
- offset: z.number().optional().describe('Page offset'),
95
- },
96
- outputSchema: z.object({
97
- data: z.array(z.object({
98
- agentId: z.string().describe('Agent ID'),
99
- status: z.string().describe('Agent approval status'),
100
- }).passthrough()).describe('Array of enterprise agents'),
101
- total: z.number().nullable().optional().describe('Total count of matching agents'),
102
- limit: z.number().nullable().optional().describe('Page size'),
103
- offset: z.number().nullable().optional().describe('Page offset'),
104
- }).passthrough().describe('Paginated list of enterprise agents'),
105
- annotations: {
106
- readOnlyHint: true,
107
- destructiveHint: false,
108
- idempotentHint: true,
109
- openWorldHint: true,
110
- },
111
- _meta: toolMeta('list_enterprise_agents'),
112
- },
113
- async (args) => {
114
- try {
115
- const result = await client.enterprises.listAgents(args.enterpriseId, {
116
- status: args.status,
117
- limit: args.limit,
118
- offset: args.offset,
119
- });
120
- return {
121
- content: [{ type: 'text', text: `Found ${result.data.length} agents for enterprise ${args.enterpriseId}.` }],
122
- structuredContent: toStructuredContent(result),
123
- };
124
- } catch (err) {
125
- return apiErrorResult(err);
126
- }
127
- },
128
- );
129
-
130
- mcp.registerTool(
131
- 'create_enterprise',
132
- {
133
- title: 'Create Enterprise',
134
- description:
135
- 'Provision a new enterprise on the platform. Returns a flat enterprise resource. ' +
136
- 'Slug is auto-generated from name if omitted. ' +
137
- 'Workflow: create_enterprise → create API key → create_agent → approve agent → set capabilities.',
138
- inputSchema: {
139
- name: z.string().describe('Legal or display name for the enterprise'),
140
- slug: z.string().optional().describe('URL-safe slug (auto-generated if omitted)'),
141
- email: z.string().optional().describe('Contact email'),
142
- trustLevel: z.enum(['sandbox', 'active', 'verified']).optional().describe('Initial trust level (default: sandbox)'),
143
- },
144
- outputSchema: {
145
- id: z.string().describe('Enterprise UUID'),
146
- name: z.string().describe('Enterprise display name'),
147
- slug: z.string().describe('URL-safe identifier'),
148
- trustLevel: z.string(),
149
- createdAt: z.string().describe('ISO 8601 creation timestamp'),
150
- },
151
- annotations: {
152
- readOnlyHint: false,
153
- destructiveHint: false,
154
- idempotentHint: false,
155
- openWorldHint: true,
156
- },
157
- _meta: toolMeta('create_enterprise'),
158
- },
159
- async (args) => {
160
- try {
161
- const enterprise = await client.admin.createEnterprise({ name: args.name, slug: args.slug });
162
- return {
163
- content: [{ type: 'text', text: `Enterprise "${enterprise.name}" created (${enterprise.id}, slug: ${enterprise.slug}). Next: create an API key with POST /v1/admin/api-keys, then register agents.` }],
164
- structuredContent: toStructuredContent(enterprise),
165
- };
166
- } catch (err) {
167
- return apiErrorResult(err);
168
- }
169
- },
170
- );
171
-
172
- mcp.registerTool(
173
- 'create_agent',
174
- {
175
- title: 'Create Agent',
176
- description:
177
- 'Provision a new agent on the platform. Returns the agent resource and a nextSteps array ' +
178
- 'Slug is auto-generated from name if omitted. ' +
179
- 'Prerequisites: enterprise must exist. ' +
180
- 'Workflow: create_enterprise → create_agent → create API key → set capabilities → approve agent.',
181
- inputSchema: {
182
- name: z.string().describe('Display name for the agent'),
183
- slug: z.string().optional().describe('URL-safe slug (auto-generated if omitted)'),
184
- enterpriseId: z.string().optional().describe('Enterprise ID the agent belongs to'),
185
- email: z.string().optional().describe('Contact email'),
186
- trustLevel: z.enum(['sandbox', 'active', 'verified']).optional().describe('Initial trust level (default: sandbox)'),
187
- },
188
- outputSchema: {
189
- id: z.string().describe('Agent UUID'),
190
- displayName: z.string().nullable().describe('Agent display name'),
191
- slug: z.string().describe('URL-safe identifier'),
192
- trustLevel: z.string(),
193
- createdAt: z.string().describe('ISO 8601 creation timestamp'),
194
- },
195
- annotations: {
196
- readOnlyHint: false,
197
- destructiveHint: false,
198
- idempotentHint: false,
199
- openWorldHint: true,
200
- },
201
- _meta: toolMeta('create_agent'),
202
- },
203
- async (args) => {
204
- try {
205
- const agent = await client.admin.createAgent({
206
- name: args.name,
207
- slug: args.slug,
208
- enterpriseId: args.enterpriseId,
209
- });
210
- return {
211
- content: [{ type: 'text', text: `Agent "${agent.displayName}" created (${agent.id}, slug: ${agent.slug}). Next: create an API key with POST /v1/admin/api-keys, then set capabilities.` }],
212
- structuredContent: toStructuredContent(agent),
213
- };
214
- } catch (err) {
215
- return apiErrorResult(err);
216
- }
217
- },
218
- );
219
-
220
- mcp.registerTool(
221
- 'set_enterprise_config',
222
- {
223
- title: 'Set Enterprise Config',
224
- description:
225
- 'Replace an enterprise\'s configuration using desired-state semantics (PUT). ' +
226
- 'The entire config object is replaced — omitted fields are removed. ' +
227
- 'Use this after create_enterprise to configure approval policies, default scopes, and operational settings.',
228
- inputSchema: {
229
- enterpriseId: z.string().describe('Enterprise ID to configure'),
230
- config: z.record(z.string(), z.unknown()).describe(
231
- 'Full configuration object. Common fields: agentApprovalRequired (boolean), ' +
232
- 'allowSelfApproval (boolean), defaultScopes (string[])',
233
- ),
234
- },
235
- outputSchema: z.object({
236
- enterpriseId: z.string().nullable().optional().describe('Enterprise ID'),
237
- config: z.record(z.string(), z.unknown()).nullable().optional().describe('Applied configuration'),
238
- }).passthrough().describe('Enterprise configuration update result'),
239
- annotations: {
240
- readOnlyHint: false,
241
- destructiveHint: false,
242
- idempotentHint: true,
243
- openWorldHint: true,
244
- },
245
- _meta: toolMeta('set_enterprise_config'),
246
- },
247
- async (args) => {
248
- try {
249
- const result = await client.admin.setEnterpriseConfig(args.enterpriseId, args.config);
250
- return {
251
- content: [{ type: 'text', text: `Configuration replaced for enterprise ${args.enterpriseId}.` }],
252
- structuredContent: toStructuredContent(result),
253
- };
254
- } catch (err) {
255
- return apiErrorResult(err);
256
- }
257
- },
258
- );
259
- }
@@ -1,52 +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 AuditChainOutputSchema = z.object({
8
- mandateId: z.string().describe('Mandate UUID'),
9
- chainStart: z.string().describe('ISO 8601 timestamp of the first audit entry'),
10
- entries: z.array(z.object({
11
- index: z.number().describe('Entry index in the chain'),
12
- hash: z.string().describe('SHA-256 hash of this entry'),
13
- previousHash: z.string().nullable().describe('Hash of the previous entry (null for first)'),
14
- event: z.string().describe('Event type'),
15
- actor: z.string().describe('Actor who triggered the event'),
16
- timestamp: z.string().describe('ISO 8601 timestamp'),
17
- signature: z.string().optional().describe('Optional cryptographic signature'),
18
- })).describe('Ordered chain of audit entries'),
19
- isValid: z.boolean().describe('Whether the hash chain is valid (tamper-proof check)'),
20
- }).passthrough().describe('Hash-chained audit trail for a mandate');
21
-
22
- export function registerEventTools(mcp: McpServer, client: AgledgerClient): void {
23
- mcp.registerTool(
24
- 'get_audit_trail',
25
- {
26
- title: 'Get Audit Trail',
27
- description: 'Get the hash-chained audit trail for a mandate. Returns an ordered, tamper-evident chain of all events.',
28
- inputSchema: {
29
- mandateId: z.string().describe('UUID of the mandate to get the audit trail for'),
30
- },
31
- outputSchema: AuditChainOutputSchema,
32
- annotations: {
33
- readOnlyHint: true,
34
- destructiveHint: false,
35
- idempotentHint: true,
36
- openWorldHint: true,
37
- },
38
- _meta: toolMeta('get_audit_trail'),
39
- },
40
- async (args) => {
41
- try {
42
- const chain = await client.events.getAuditChain(args.mandateId);
43
- return {
44
- content: [{ type: 'text', text: `Audit trail for mandate ${chain.mandateId}: ${chain.entries.length} entries, chain valid=${chain.isValid}.` }],
45
- structuredContent: toStructuredContent(chain),
46
- };
47
- } catch (err) {
48
- return apiErrorResult(err);
49
- }
50
- },
51
- );
52
- }