@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,461 +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 { AgledgerApiError } from '@agledger/sdk';
5
- import { apiErrorResult } from '../errors.js';
6
- import { toolMeta } from '../tool-scopes.js';
7
-
8
- const RESOURCE_MANIFEST: Record<string, string> = {
9
- mandates: `## client.mandates
10
- - create(params: CreateMandateParams): Promise<Mandate>
11
- - createAgent(params: CreateAgentMandateParams): Promise<Mandate>
12
- - get(id: string): Promise<Mandate>
13
- - list(params: ListMandatesParams): Promise<Page<Mandate>>
14
- - listAll(params: ListMandatesParams): AsyncGenerator<Mandate>
15
- - search(params: SearchMandatesParams): Promise<Page<Mandate>>
16
- - update(id: string, params: UpdateMandateParams): Promise<Mandate>
17
- - transition(id: string, action: MandateTransitionAction, reason?: string): Promise<Mandate>
18
- - cancel(id: string, reason?: string): Promise<Mandate>
19
- - accept(id: string): Promise<Mandate>
20
- - reject(id: string, reason?: string): Promise<Mandate>
21
- - counterPropose(id: string, params: CounterProposeParams): Promise<Mandate>
22
- - acceptCounter(id: string): Promise<Mandate>
23
- - getChain(id: string): Promise<Mandate[]>
24
- - getSubMandates(id: string): Promise<Page<Mandate>>
25
- - delegate(id: string, params: DelegateMandateParams): Promise<Mandate>
26
- - bulkCreate(mandates: CreateMandateParams[]): Promise<BulkCreateResult>
27
- - getAudit(id: string): Promise<AuditChain>
28
- - listAsPrincipal(): Promise<Page<Mandate>>
29
- - listProposals(): Promise<Page<Mandate>>
30
- - requestRevision(id: string, reason?: string): Promise<Mandate>
31
- - createAndActivate(params: CreateMandateParams): Promise<Mandate>
32
- - reportOutcome(id: string, params: ReportOutcomeParams): Promise<OutcomeResult>
33
- - getSummary(params?: { enterpriseId?: string }): Promise<MandateStatusSummary>
34
- - getGraph(id: string): Promise<Record<string, unknown>>
35
- - batchGet(ids: string[]): Promise<Mandate[]>
36
- - getValidTransitions(mandate: Mandate): readonly string[] (client-side, no API call)`,
37
-
38
- receipts: `## client.receipts
39
- - submit(mandateId: string, params: SubmitReceiptParams): Promise<Receipt>
40
- - get(mandateId: string, receiptId: string): Promise<Receipt>
41
- - list(mandateId: string, params?: ListParams): Promise<Page<Receipt>>
42
- - listAll(mandateId: string, params?: ListParams): AsyncGenerator<Receipt>`,
43
-
44
- verification: `## client.verification
45
- - verify(mandateId: string, receiptIds?: string[]): Promise<VerificationResult>
46
- - getStatus(mandateId: string): Promise<VerificationStatus>`,
47
-
48
- disputes: `## client.disputes
49
- - create(mandateId: string, params: CreateDisputeParams): Promise<Dispute>
50
- - get(mandateId: string): Promise<DisputeResponse>
51
- - escalate(mandateId: string): Promise<Dispute>
52
- - submitEvidence(mandateId: string, params: { evidenceType: EvidenceType; payload: Record<string, unknown> }): Promise<Record<string, unknown>>`,
53
-
54
- webhooks: `## client.webhooks
55
- - create(params: CreateWebhookParams): Promise<Webhook>
56
- - list(params?: ListWebhooksParams): Promise<Page<Webhook>>
57
- - get(webhookId: string): Promise<Webhook>
58
- - update(webhookId: string, params: Partial<CreateWebhookParams>): Promise<Webhook>
59
- - delete(webhookId: string): Promise<void>
60
- - pause(webhookId: string): Promise<Webhook>
61
- - resume(webhookId: string): Promise<Webhook>
62
- - rotate(webhookId: string): Promise<Webhook>
63
- - ping(webhookId: string): Promise<WebhookTestResult>
64
- - listDeliveries(webhookId: string, params?: ListParams & { status?: string }): Promise<Page<WebhookDelivery>>
65
- - listDlq(webhookId: string, params?: ListParams): Promise<Page<WebhookDlqEntry>>
66
- - retryAllDlq(webhookId: string): Promise<{ retried: number }>
67
- - retryDlq(webhookId: string, dlqId: string): Promise<Record<string, unknown>>`,
68
-
69
- reputation: `## client.reputation
70
- - getAgent(agentId: string): Promise<Page<ReputationScore>>
71
- - getByContractType(agentId: string, contractType: string): Promise<ReputationScore>
72
- - getHistory(agentId: string, params?: ListParams & { from?: string; to?: string; contractType?: string; outcome?: 'PASS' | 'FAIL' }): Promise<Page<ReputationHistoryEntry>>`,
73
-
74
- events: `## client.events
75
- - list(params: { since: string; order?: 'asc' | 'desc' } & ListParams): Promise<Page<AgledgerEvent>>
76
- - listAll(params: { since: string; order?: 'asc' | 'desc' } & ListParams): AsyncGenerator<AgledgerEvent>
77
- - getAuditChain(mandateId: string): Promise<AuditChain>`,
78
-
79
- schemas: `## client.schemas
80
- - list(params?: { enterpriseId?: string }): Promise<Page<ContractType>>
81
- - get(contractType: string): Promise<ContractSchema>
82
- - delete(contractType: string): Promise<void>
83
- - getRules(contractType: string): Promise<{ contractType; syncRuleIds; asyncRuleIds }>
84
- - validateReceipt(contractType: string, evidence: Record<string, unknown>): Promise<SchemaValidationResult>
85
- - getMetaSchema(): Promise<MetaSchema>
86
- - getTemplate(contractType: string): Promise<SchemaTemplate>
87
- - getBlankTemplate(): Promise<SchemaTemplate>
88
- - getVersions(contractType: string): Promise<SchemaVersionDetail[]>
89
- - getVersion(contractType: string, version: number): Promise<SchemaVersionDetail>
90
- - diff(contractType: string, from: number, to: number): Promise<SchemaDiffResult>
91
- - preview(input: SchemaPreviewInput): Promise<SchemaPreviewResult>
92
- - checkCompatibility(contractType: string, schemas: { mandateSchema; receiptSchema }): Promise<SchemaCompatibilityResult>
93
- - register(input: RegisterSchemaParams): Promise<SchemaVersionDetail>
94
- - updateVersion(contractType: string, version: number, params: UpdateSchemaVersionParams): Promise<SchemaVersionDetail>
95
- - exportSchema(contractType: string, opts?: ExportSchemaOptions): Promise<SchemaExportResult>
96
- - importSchema(payload: SchemaImportPayload, opts?: ImportSchemaOptions): Promise<SchemaImportResult>
97
- - previewImport(payload: SchemaImportPayload, opts?: ImportSchemaOptions): Promise<SchemaImportDryRunResult>`,
98
-
99
- dashboard: `## client.dashboard
100
- - getSummary(): Promise<DashboardSummary>
101
- - getMetrics(params?: DashboardMetricsParams): Promise<DashboardMetrics>
102
- - listAgents(params?: DashboardAgentParams): Promise<Page<DashboardAgent>>
103
- - getAlerts(params?: ListParams): Promise<Page<DashboardAlert>>
104
- - getDisputes(params?: ListParams): Promise<Page<Record<string, unknown>>>
105
- - getAuditTrail(params?: ListParams): Promise<Page<Record<string, unknown>>>`,
106
-
107
- compliance: `## client.compliance
108
- - export(params: ExportComplianceParams): Promise<ComplianceExport>
109
- - getExportStatus(exportId: string): Promise<ComplianceExport>
110
- - downloadExport(exportId: string): Promise<Record<string, unknown>>
111
- - waitForExport(exportId: string, opts?: { pollIntervalMs?; timeoutMs?; signal? }): Promise<ComplianceExport>
112
- - createAssessment(mandateId: string, params: CreateAiImpactAssessmentParams): Promise<AiImpactAssessment>
113
- - getAssessment(mandateId: string): Promise<AiImpactAssessment>
114
- - getEuAiActReport(params?: { from?; to? }): Promise<EuAiActReport>
115
- - getEnterpriseReport(params?: { from?; to?; format? }): Promise<Record<string, unknown>>
116
- - analyzeAudit(mandateId: string): Promise<Record<string, unknown>>
117
- - createRecord(mandateId: string, params: CreateComplianceRecordParams): Promise<ComplianceRecord>
118
- - listRecords(mandateId: string, params?: ListParams): Promise<Page<ComplianceRecord>>
119
- - getRecord(mandateId: string, recordId: string): Promise<ComplianceRecord>
120
- - exportMandate(mandateId: string, params?: { format?: 'json' | 'csv' | 'ndjson' }): Promise<MandateAuditExport>
121
- - stream(params: AuditStreamParams): Promise<AuditStreamResult>
122
- - streamAll(params: AuditStreamParams): AsyncGenerator<Record<string, unknown>>`,
123
-
124
- registration: `## client.registration
125
- - getMe(): Promise<AccountProfile>
126
- - register(params: RegisterParams): Promise<RegisterResult>
127
- - registerEnterprise(params: { name: string; email?: string }): Promise<RegisterResult>
128
- - registerAgent(params: { name: string; email?: string; agentCardUrl?: string; enterpriseId?: string }): Promise<RegisterResult>
129
- - verifyAgentCard(agentCardUrl: string): Promise<Record<string, unknown>>
130
- - rotateApiKey(): Promise<{ apiKey: string }>
131
- - verifyEmail(token: string): Promise<{ sandboxMode: boolean; status: string }>
132
- - sendVerificationEmail(email: string): Promise<{ sandboxMode: boolean; status: string }>`,
133
-
134
- health: `## client.health
135
- - check(): Promise<HealthResponse>
136
- - status(): Promise<StatusResponse>
137
- - conformance(): Promise<ConformanceResponse>`,
138
-
139
- proxy: `## client.proxy
140
- Unified resource with sub-resources for governance sidecar proxy operations.
141
- - syncSession(params: SyncSessionParams): Promise<SyncSessionResult>
142
-
143
- ### client.proxy.sessions
144
- - create(params: CreateSessionParams): Promise<ProxySession>
145
- - get(sessionId: string): Promise<ProxySession>
146
- - list(params?: ListParams): Promise<Page<ProxySession>>
147
- - sync(params: SyncSessionParams): Promise<SyncSessionResult>
148
-
149
- ### client.proxy.toolCalls
150
- - ingest(sessionId: string, items: ToolCallBatchItem[]): Promise<BatchResult<ProxyToolCall>>
151
- - list(sessionId: string, params?: ListParams): Promise<Page<ProxyToolCall>>
152
-
153
- ### client.proxy.sidecarMandates
154
- - ingest(sessionId: string, items: SidecarMandateBatchItem[]): Promise<BatchResult<ProxySidecarMandate>>
155
- - list(params?: ListParams & { sessionId?: string }): Promise<Page<ProxySidecarMandate>>
156
- - listBySession(sessionId: string, params?: ListParams): Promise<Page<ProxySidecarMandate>>
157
- - update(id: string, params: UpdateSidecarMandateParams): Promise<ProxySidecarMandate>
158
- - formalize(id: string, formalizedMandateId: string): Promise<ProxySidecarMandate>
159
- - dismiss(id: string): Promise<ProxySidecarMandate>
160
-
161
- ### client.proxy.sidecarReceipts
162
- - ingest(sessionId: string, items: SidecarReceiptBatchItem[]): Promise<BatchResult<ProxySidecarReceipt>>
163
- - listBySession(sessionId: string, params?: ListParams): Promise<Page<ProxySidecarReceipt>>
164
-
165
- ### client.proxy.toolCatalog
166
- - ingest(sessionId: string, items: ToolCatalogBatchItem[]): Promise<BatchResult<ProxyToolCatalogEntry>>
167
- - list(sessionId: string): Promise<Page<ProxyToolCatalogEntry>>
168
-
169
- ### client.proxy.analytics
170
- - getSession(sessionId: string): Promise<SessionAnalytics>
171
- - getSummary(params?: { from?; to? }): Promise<AnalyticsSummary>
172
- - getMandateSummary(sessionId: string): Promise<MandateSummary>
173
- - getAlignment(sessionId: string): Promise<AlignmentAnalysis>`,
174
-
175
- admin: `## client.admin
176
- Platform-level administration. Requires platform API key.
177
- - listEnterprises(params?: ListParams): Promise<Page<AdminEnterprise>>
178
- - createEnterprise(params: CreateEnterpriseParams): Promise<AdminEnterprise>
179
- - listAgents(params?: ListParams): Promise<Page<AdminAgent>>
180
- - createAgent(params: CreateAgentParams): Promise<AdminAgent>
181
- - updateTrustLevel(accountId: string, params: UpdateTrustLevelParams): Promise<Record<string, unknown>>
182
- - deactivateAccount(accountId: string, params: { accountType: 'enterprise' | 'agent'; reason?: string }): Promise<Record<string, unknown>>
183
- - setCapabilities(agentId: string, params: SetCapabilitiesParams): Promise<Record<string, unknown>>
184
- - getFleetCapabilities(): Promise<Page<{ agentId; capabilities }>>
185
- - getEnterpriseConfig(enterpriseId: string): Promise<EnterpriseConfig>
186
- - replaceEnterpriseConfig(enterpriseId: string, params: SetEnterpriseConfigParams): Promise<EnterpriseConfig>
187
- - updateEnterpriseConfig(enterpriseId: string, params: SetEnterpriseConfigParams): Promise<EnterpriseConfig>
188
- - listApiKeys(params?: ListParams): Promise<Page<AdminApiKey>>
189
- - createApiKey(params: CreateApiKeyParams): Promise<CreateApiKeyResult>
190
- - toggleApiKey(keyId: string, isActive: boolean): Promise<AdminApiKey>
191
- - bulkRevokeApiKeys(keyIds: string[]): Promise<{ revoked: number }>
192
- - getLicense(): Promise<LicenseInfo>
193
- - listMandates(params?: QueryAdminMandatesParams): Promise<Page<Record<string, unknown>>>
194
- - listDlq(params?: ListParams): Promise<Page<WebhookDlqEntry>>
195
- - retryDlq(dlqId: string): Promise<Record<string, unknown>>
196
- - retryAllDlq(): Promise<{ retried: number }>
197
- - getSystemHealth(): Promise<SystemHealth>
198
- - listRateLimitExemptions(): Promise<Page<string>>
199
- - setRateLimitExemption(ip: string): Promise<{ ip; exempt }>
200
- - deleteRateLimitExemption(ip: string): Promise<{ ip; exempt }>
201
- - getWebhookHealth(params?: ListParams): Promise<Page<Record<string, unknown>>>
202
- - updateCircuitBreaker(webhookId: string, params: UpdateCircuitBreakerParams): Promise<CircuitBreakerResult>
203
- - listVaultSigningKeys(): Promise<VaultSigningKey[]>
204
- - rotateVaultSigningKey(): Promise<VaultSigningKey>
205
- - listVaultAnchors(): Promise<VaultAnchor[]>
206
- - verifyVaultAnchors(): Promise<VaultAnchorVerifyResult>
207
- - startVaultScan(): Promise<VaultScanJob>
208
- - getVaultScanStatus(jobId: string): Promise<VaultScanJob>
209
- - flushAuthCache(): Promise<{ flushed: boolean }>
210
- - getAuthCacheStats(): Promise<AuthCacheStats>
211
- - flushSchemaCache(): Promise<{ flushed: boolean }>
212
- - listOwnerRateLimitExemptions(): Promise<Record<string, unknown>[]>
213
- - setOwnerRateLimitExemption(ownerId: string): Promise<Record<string, unknown>>
214
- - deleteOwnerRateLimitExemption(ownerId: string): Promise<Record<string, unknown>>`,
215
-
216
- a2a: `## client.a2a
217
- Agent-to-Agent protocol (A2A). JSON-RPC 2.0 dispatch.
218
- - getAgentCard(): Promise<AgentCard>
219
- - dispatch(request: JsonRpcRequest): Promise<JsonRpcResponse>
220
- - call(method: string, params?: Record<string, unknown>): Promise<JsonRpcResponse>`,
221
-
222
- capabilities: `## client.capabilities
223
- - get(agentId: string): Promise<{ agentId; capabilities: ContractType[] }>
224
- - set(agentId: string, params: SetCapabilitiesParams): Promise<{ agentId; capabilities: ContractType[] }> (PUT — replaces all)`,
225
-
226
- notarize: `## client.notarize
227
- Agent-to-agent agreement notarization (OpenClaw flow).
228
- - createMandate(params: NotarizeMandateParams): Promise<NotarizeMandateResult>
229
- - getMandate(id: string): Promise<NotarizedMandate>
230
- - getHistory(id: string): Promise<NotarizeHistory>
231
- - acceptMandate(id: string): Promise<NotarizedMandate>
232
- - counterPropose(id: string, params: NotarizeCounterProposeParams): Promise<NotarizeMandateResult>
233
- - submitReceipt(id: string, params: NotarizeReceiptParams): Promise<NotarizeReceiptResult>
234
- - renderVerdict(id: string, params: NotarizeVerdictParams): Promise<NotarizedMandate>
235
- - verify(params: NotarizeVerifyParams): Promise<NotarizeVerifyResult>`,
236
-
237
- enterprises: `## client.enterprises
238
- Enterprise agent approval registry.
239
- - approveAgent(enterpriseId: string, agentId: string, params?: ApproveAgentParams): Promise<EnterpriseAgentRecord>
240
- - revokeAgent(enterpriseId: string, agentId: string, params?: RevokeAgentParams): Promise<void>
241
- - updateAgentStatus(enterpriseId: string, agentId: string, params: UpdateAgentStatusParams): Promise<EnterpriseAgentRecord>
242
- - bulkApprove(enterpriseId: string, params: BulkApproveAgentParams): Promise<BulkApproveResult>
243
- - listAgents(enterpriseId: string, params?: ListEnterpriseAgentsParams): Promise<Page<EnterpriseAgentRecord>>
244
- - getAgent(enterpriseId: string, agentId: string): Promise<EnterpriseAgentRecord>
245
- `,
246
-
247
- projects: `## client.projects
248
- - create(params: CreateProjectParams): Promise<Project>
249
- - list(params?: ListParams): Promise<Page<Project>>
250
- - get(projectId: string): Promise<Project>
251
- - update(projectId: string, params: UpdateProjectParams): Promise<Project>
252
- - delete(projectId: string): Promise<void>`,
253
-
254
- federation: `## client.federation
255
- Gateway-facing federation operations. Most methods require a bearer token from register().
256
- - register(params: RegisterGatewayParams): Promise<RegisterGatewayResult> (no auth header)
257
- - heartbeat(params: HeartbeatParams): Promise<HeartbeatResult>
258
- - registerAgent(params: RegisterFederatedAgentParams): Promise<{ registered: boolean }>
259
- - listAgents(params?: ListFederatedAgentsParams): Promise<Page<FederationAgent>>
260
- - submitStateTransition(params: SubmitStateTransitionParams): Promise<StateTransitionResult>
261
- - relaySignal(params: RelaySignalParams): Promise<SignalRelayResult>
262
- - rotateKey(gatewayId: string, params: RotateGatewayKeyParams): Promise<{ rotated: boolean }>
263
- - revoke(gatewayId: string, params: RevokeGatewayParams): Promise<{ revoked; revokedAt }> (no auth header)
264
- - catchUp(params: FederationCatchUpParams): Promise<{ data: FederationAuditEntry[]; hasMore }>
265
- - stream(params?: { since?: string }): Promise<Record<string, unknown>>
266
- - publishSchema(contractType: string, params: SchemaPublishParams): Promise<ContractSchema>
267
- - confirmSchemaPublish(contractType: string, params: SchemaConfirmParams): Promise<ContractSchema>
268
- - listContractTypes(): Promise<ContractSchema[]>
269
- - getContractType(contractType: string): Promise<ContractSchema>
270
- - getMandateCriteria(mandateId: string): Promise<FederationMandateCriteria>
271
- - submitMandateCriteria(mandateId: string, params: SubmitMandateCriteriaParams): Promise<FederationMandateCriteria>
272
- - contributeReputation(params: ContributeReputationParams): Promise<{ contributed: boolean }>
273
- - getAgentReputation(agentId: string): Promise<FederationAgentReputation>
274
- - broadcastRevocations(params: RevocationBroadcastParams): Promise<{ broadcast: boolean }>
275
- - syncAgentDirectory(params: AgentDirectorySyncParams): Promise<{ synced: boolean }>`,
276
-
277
- federationAdmin: `## client.federationAdmin
278
- Platform admin operations for federation. Requires admin:system scope.
279
- - createRegistrationToken(params?: CreateRegistrationTokenParams): Promise<FederationRegistrationToken>
280
- - listGateways(params?: ListFederationGatewaysParams): Promise<Page<FederationGateway>>
281
- - revokeGateway(gatewayId: string, params: AdminRevokeGatewayParams): Promise<{ revoked; nextSteps }>
282
- - queryMandates(params?: QueryFederationMandatesParams): Promise<Page<FederationMandate>>
283
- - getAuditLog(params?: FederationAuditLogParams): Promise<Page<FederationAuditEntry>>
284
- - getHealth(): Promise<FederationHealthSummary>
285
- - resetSequence(gatewayId: string, params?: ResetSequenceParams): Promise<{ reset; nextSteps }>
286
- - listDlq(params?: ListOutboundDlqParams): Promise<Page<FederationDlqEntry>>
287
- - retryDlq(dlqId: string): Promise<{ retried; nextSteps }>
288
- - deleteDlq(dlqId: string): Promise<{ deleted: boolean }>
289
- - rotateHubKey(): Promise<HubSigningKey>
290
- - listHubKeys(): Promise<HubSigningKey[]>
291
- - activateHubKey(keyId: string): Promise<HubSigningKey>
292
- - expireHubKey(keyId: string): Promise<HubSigningKey>
293
- - registerPeer(params: PeerRegistrationParams): Promise<FederationPeer>
294
- - listPeers(): Promise<Page<FederationPeer>>
295
- - getPeer(hubId: string): Promise<FederationPeer>
296
- - revokePeer(hubId: string): Promise<{ revoked: boolean }>
297
- - resyncPeer(hubId: string): Promise<{ synced: boolean }>
298
- - createPeeringToken(): Promise<PeeringToken>
299
- - deleteSchemaVersion(contractType: string, version: string): Promise<{ deleted: boolean }>
300
- - listReputationContributions(agentId: string): Promise<ReputationContribution[]>
301
- - resetReputation(agentId: string): Promise<{ reset: boolean }>
302
- - getMandateCriteriaStatus(mandateId: string): Promise<MandateCriteriaStatus>`,
303
-
304
- agents: `## client.agents
305
- Agent identity management.
306
- - get(agentId: string): Promise<AgentProfile>
307
- - update(agentId: string, params: UpdateAgentParams): Promise<AgentProfile>
308
- - addReferences(agentId: string, references: Record<string, unknown>[]): Promise<Record<string, unknown>>
309
- - getReferences(agentId: string): Promise<Record<string, unknown>>`,
310
-
311
- references: `## client.references
312
- Reverse lookup for external references.
313
- - lookup(params: { system: string; refType: string; refId: string }): Promise<ReferenceLookupResult>
314
- - addMandateReferences(mandateId: string, references: Record<string, unknown>[]): Promise<Record<string, unknown>>
315
- - getMandateReferences(mandateId: string): Promise<Record<string, unknown>>`,
316
-
317
- verificationKeys: `## client.verificationKeys
318
- Public vault signing keys for independent audit chain verification. No auth required.
319
- - list(): Promise<VerificationKeysResponse> — returns { data: VerificationKey[], canonicalization, hashAlgorithm, signatureAlgorithm }`,
320
- };
321
-
322
- const RESOURCE_NAMES = Object.keys(RESOURCE_MANIFEST);
323
-
324
- function buildFullManifest(): string {
325
- const header = `# AGLedger SDK — Resource Manifest
326
- 24 resources, ~200 methods. Use \`sdk_execute\` to call any method.
327
- The \`client\` variable is a pre-configured AgledgerClient instance.
328
-
329
- **Pagination**: \`list()\` returns \`Page<T>\` with \`.data\`, \`.total\`, \`.hasMore\`, \`.cursor\`. Use \`listAll()\` for auto-paginating async iterators.
330
- **Options**: All methods accept an optional trailing \`RequestOptions\` parameter (timeout, idempotencyKey, authOverride).
331
- **Errors**: SDK throws typed errors — \`AgledgerApiError\`, \`AuthenticationError\`, \`PermissionError\`, \`NotFoundError\`, \`RateLimitError\`, etc.
332
-
333
- ---
334
-
335
- `;
336
- return header + RESOURCE_NAMES.map((name) => RESOURCE_MANIFEST[name]).join('\n\n');
337
- }
338
-
339
- const FULL_MANIFEST = buildFullManifest();
340
-
341
- export function registerCodeModeTools(mcp: McpServer, client: AgledgerClient): void {
342
- mcp.registerTool(
343
- 'sdk_execute',
344
- {
345
- title: 'Execute SDK Code',
346
- description: `Execute TypeScript/JavaScript code against the AGLedger SDK client. The \`client\` variable is a pre-configured AgledgerClient instance with all 23 resources available.
347
-
348
- Example usage:
349
- - \`const mandate = await client.mandates.get("mnd-abc123"); return mandate;\`
350
- - \`const page = await client.mandates.list({ status: "ACTIVE", limit: 10 }); return page.data;\`
351
- - \`await client.mandates.transition("mnd-abc123", { action: "register" }); return "done";\`
352
-
353
- The code runs in an async context — use \`await\` freely. Return a value to see it in the response. Use \`sdk_describe\` first to discover available resources and method signatures.
354
-
355
- Available resources: ${RESOURCE_NAMES.join(', ')}.
356
-
357
- SECURITY: This tool executes code in the MCP server process. It is intended for trusted agents only — the caller has the same access as the API key. Do not expose this tool to untrusted clients. A 30-second timeout prevents runaway execution.`,
358
- inputSchema: {
359
- code: z.string().describe('TypeScript/JavaScript code to execute. Use `client` to access the SDK. Return a value to see results.'),
360
- },
361
- outputSchema: z.object({
362
- result: z.unknown().describe('The return value of the executed code'),
363
- executionTimeMs: z.number().describe('Execution time in milliseconds'),
364
- }),
365
- annotations: {
366
- readOnlyHint: false,
367
- destructiveHint: true,
368
- idempotentHint: false,
369
- openWorldHint: true,
370
- },
371
- _meta: toolMeta('sdk_execute'),
372
- },
373
- async (args) => {
374
- const TIMEOUT_MS = 30_000;
375
- const start = Date.now();
376
- try {
377
- // Use AsyncFunction constructor to support top-level await
378
- // NOTE: This executes in the same process as the MCP server — the caller
379
- // (agent) is already trusted with the API key. The timeout prevents runaway
380
- // code from hanging the server. For untrusted execution, use a sandbox.
381
- const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
382
- const fn = new AsyncFunction('client', args.code);
383
- const timeout = new Promise((_, reject) =>
384
- setTimeout(() => reject(new Error(`Execution timed out after ${TIMEOUT_MS}ms`)), TIMEOUT_MS),
385
- );
386
- const result = await Promise.race([fn(client), timeout]);
387
- const executionTimeMs = Date.now() - start;
388
- let serialized: string;
389
- try {
390
- serialized = JSON.stringify(result, null, 2) ?? 'undefined';
391
- } catch {
392
- serialized = '[Result contains circular references]';
393
- }
394
- return {
395
- content: [{ type: 'text', text: `Execution completed in ${executionTimeMs}ms.\n\n${serialized}` }],
396
- structuredContent: { result, executionTimeMs },
397
- };
398
- } catch (err) {
399
- const executionTimeMs = Date.now() - start;
400
- if (err instanceof AgledgerApiError) {
401
- return apiErrorResult(err);
402
- }
403
- return {
404
- content: [{ type: 'text', text: `Execution error after ${executionTimeMs}ms: ${err instanceof Error ? err.message : String(err)}` }],
405
- isError: true,
406
- };
407
- }
408
- },
409
- );
410
-
411
- mcp.registerTool(
412
- 'sdk_describe',
413
- {
414
- title: 'Describe SDK Resources',
415
- description: `Returns the AGLedger SDK resource manifest — all 23 resources with method signatures, parameters, and return types. Use this to discover what code to write for \`sdk_execute\`.
416
-
417
- Pass a \`resource\` name (e.g., "mandates", "federation") for detailed info on one resource, or omit it for the full manifest.
418
-
419
- Available resources: ${RESOURCE_NAMES.join(', ')}.`,
420
- inputSchema: {
421
- resource: z.string().optional().describe('Resource name to describe (e.g., "mandates", "federation"). Omit for full manifest.'),
422
- },
423
- outputSchema: z.object({
424
- manifest: z.string().describe('SDK resource manifest with method signatures'),
425
- resourceCount: z.number().describe('Number of resources described'),
426
- }),
427
- annotations: {
428
- readOnlyHint: true,
429
- destructiveHint: false,
430
- idempotentHint: true,
431
- openWorldHint: false,
432
- },
433
- _meta: toolMeta('sdk_describe'),
434
- },
435
- async (args) => {
436
- if (args.resource) {
437
- const name = args.resource.toLowerCase().replace(/[-_\s]/g, '');
438
- // Try exact match first, then normalized match
439
- const key = RESOURCE_NAMES.find(
440
- (k) => k === args.resource || k.toLowerCase().replace(/[-_\s]/g, '') === name,
441
- );
442
- if (!key) {
443
- return {
444
- content: [{ type: 'text', text: `Unknown resource "${args.resource}". Available: ${RESOURCE_NAMES.join(', ')}` }],
445
- isError: true,
446
- };
447
- }
448
- const manifest = RESOURCE_MANIFEST[key];
449
- return {
450
- content: [{ type: 'text', text: manifest }],
451
- structuredContent: { manifest, resourceCount: 1 },
452
- };
453
- }
454
-
455
- return {
456
- content: [{ type: 'text', text: FULL_MANIFEST }],
457
- structuredContent: { manifest: FULL_MANIFEST, resourceCount: RESOURCE_NAMES.length },
458
- };
459
- },
460
- );
461
- }
@@ -1,104 +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 registerComplianceTools(mcp: McpServer, client: AgledgerClient): void {
8
- mcp.registerTool(
9
- 'create_compliance_record',
10
- {
11
- title: 'Create Compliance Record',
12
- description: 'Create a per-mandate compliance attestation. Record types: workplace_notification, affected_persons, input_data_quality, fundamental_rights_impact_assessment.',
13
- inputSchema: {
14
- mandateId: z.string().describe('Mandate ID to attach the record to'),
15
- recordType: z.string().describe('Record type (e.g. workplace_notification, affected_persons)'),
16
- attestation: z.record(z.string(), z.unknown()).describe('Attestation data'),
17
- attestedBy: z.string().describe('Who attested (name or ID)'),
18
- },
19
- outputSchema: z.object({
20
- id: z.string().describe('Compliance record ID'),
21
- mandateId: z.string().describe('Associated mandate ID'),
22
- recordType: z.string().describe('Record type'),
23
- attestedBy: z.string().describe('Who attested'),
24
- createdAt: z.string().nullable().optional().describe('ISO 8601 creation timestamp'),
25
- }).passthrough().describe('Created compliance attestation record'),
26
- annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
27
- _meta: toolMeta('create_compliance_record'),
28
- },
29
- async (args) => {
30
- try {
31
- const record = await client.compliance.createRecord(args.mandateId, {
32
- recordType: args.recordType as 'workplace_notification',
33
- attestation: args.attestation,
34
- attestedBy: args.attestedBy,
35
- });
36
- return {
37
- content: [{ type: 'text', text: `Compliance record created for mandate ${args.mandateId} (type: ${args.recordType}).` }],
38
- structuredContent: toStructuredContent(record),
39
- };
40
- } catch (err) { return apiErrorResult(err); }
41
- },
42
- );
43
-
44
- mcp.registerTool(
45
- 'list_compliance_records',
46
- {
47
- title: 'List Compliance Records',
48
- description: 'List compliance attestation records for a mandate.',
49
- inputSchema: {
50
- mandateId: z.string().describe('Mandate ID'),
51
- limit: z.number().optional().describe('Page size'),
52
- },
53
- outputSchema: z.object({
54
- data: z.array(z.object({
55
- id: z.string().optional().describe('Compliance record ID'),
56
- mandateId: z.string().optional().describe('Associated mandate ID'),
57
- recordType: z.string().optional().describe('Record type'),
58
- attestedBy: z.string().optional().describe('Who attested'),
59
- createdAt: z.string().nullable().optional().describe('ISO 8601 creation timestamp'),
60
- }).passthrough()).describe('Array of compliance records'),
61
- total: z.number().nullable().optional().describe('Total count'),
62
- }).passthrough().describe('Paginated list of compliance records for a mandate'),
63
- annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
64
- _meta: toolMeta('list_compliance_records'),
65
- },
66
- async (args) => {
67
- try {
68
- const result = await client.compliance.listRecords(args.mandateId, { limit: args.limit });
69
- return {
70
- content: [{ type: 'text', text: `Found ${result.data.length} compliance records for mandate ${args.mandateId}.` }],
71
- structuredContent: toStructuredContent(result),
72
- };
73
- } catch (err) { return apiErrorResult(err); }
74
- },
75
- );
76
-
77
- mcp.registerTool(
78
- 'get_eu_ai_act_report',
79
- {
80
- title: 'EU AI Act Report',
81
- description: 'Get EU AI Act compliance report showing risk classifications, human oversight designations, and audit status across all mandates.',
82
- inputSchema: {},
83
- outputSchema: z.object({
84
- summary: z.object({
85
- highRiskCount: z.number().describe('Count of high-risk mandates'),
86
- auditedCount: z.number().describe('Count of audited mandates'),
87
- totalCount: z.number().nullable().optional().describe('Total mandate count'),
88
- }).passthrough().describe('Report summary counts'),
89
- mandates: z.array(z.record(z.string(), z.unknown())).nullable().optional().describe('Detailed mandate-level compliance data'),
90
- }).passthrough().describe('EU AI Act compliance report'),
91
- annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
92
- _meta: toolMeta('get_eu_ai_act_report'),
93
- },
94
- async () => {
95
- try {
96
- const report = await client.compliance.getEuAiActReport();
97
- return {
98
- content: [{ type: 'text', text: `EU AI Act report: ${report.summary.highRiskCount} high-risk mandates, ${report.summary.auditedCount} audited.` }],
99
- structuredContent: toStructuredContent(report),
100
- };
101
- } catch (err) { return apiErrorResult(err); }
102
- },
103
- );
104
- }
@@ -1,98 +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 registerDashboardTools(mcp: McpServer, client: AgledgerClient): void {
8
- mcp.registerTool(
9
- 'get_dashboard_summary',
10
- {
11
- title: 'Dashboard Summary',
12
- description: 'Get a high-level dashboard summary: mandate counts, active agents, fulfillment rates, settlement signals. Start here for situational awareness.',
13
- inputSchema: {},
14
- outputSchema: z.object({
15
- totalMandates: z.number().describe('Total number of mandates'),
16
- activeCount: z.number().describe('Count of active mandates'),
17
- fulfilledCount: z.number().describe('Count of fulfilled mandates'),
18
- failedCount: z.number().nullable().optional().describe('Count of failed mandates'),
19
- disputeCount: z.number().nullable().optional().describe('Count of open disputes'),
20
- }).passthrough().describe('High-level dashboard summary with mandate counts and rates'),
21
- annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
22
- _meta: toolMeta('get_dashboard_summary'),
23
- },
24
- async () => {
25
- try {
26
- const summary = await client.dashboard.getSummary();
27
- return {
28
- content: [{ type: 'text', text: `Dashboard: ${summary.totalMandates} mandates, ${summary.activeCount} active, ${summary.fulfilledCount} fulfilled.` }],
29
- structuredContent: toStructuredContent(summary),
30
- };
31
- } catch (err) { return apiErrorResult(err); }
32
- },
33
- );
34
-
35
- mcp.registerTool(
36
- 'get_dashboard_metrics',
37
- {
38
- title: 'Dashboard Metrics',
39
- description: 'Get time-series dashboard metrics (mandates, receipts, disputes) over a date range. Use for trend analysis.',
40
- inputSchema: {
41
- from: z.string().optional().describe('Start date (ISO 8601)'),
42
- to: z.string().optional().describe('End date (ISO 8601)'),
43
- granularity: z.enum(['daily', 'weekly', 'monthly']).optional().describe('Time bucket size'),
44
- },
45
- outputSchema: z.object({
46
- series: z.array(z.object({
47
- date: z.string().describe('ISO 8601 date for this data point'),
48
- mandates: z.number().nullable().optional().describe('Mandate count for this period'),
49
- receipts: z.number().nullable().optional().describe('Receipt count for this period'),
50
- disputes: z.number().nullable().optional().describe('Dispute count for this period'),
51
- }).passthrough()).nullable().optional().describe('Time-series data points'),
52
- }).passthrough().describe('Dashboard time-series metrics'),
53
- annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
54
- _meta: toolMeta('get_dashboard_metrics'),
55
- },
56
- async (args) => {
57
- try {
58
- const metrics = await client.dashboard.getMetrics(args);
59
- return {
60
- content: [{ type: 'text', text: `Metrics: ${metrics.series?.length ?? 0} data points.` }],
61
- structuredContent: toStructuredContent(metrics),
62
- };
63
- } catch (err) { return apiErrorResult(err); }
64
- },
65
- );
66
-
67
- mcp.registerTool(
68
- 'get_dashboard_alerts',
69
- {
70
- title: 'Dashboard Alerts',
71
- description: 'Get active dashboard alerts (overdue mandates, failed verifications, circuit-breaker trips). Check this for issues requiring attention.',
72
- inputSchema: {
73
- limit: z.number().optional().describe('Page size'),
74
- },
75
- outputSchema: z.object({
76
- data: z.array(z.object({
77
- id: z.string().optional().describe('Alert ID'),
78
- type: z.string().optional().describe('Alert type (e.g. overdue, failed_verification)'),
79
- message: z.string().optional().describe('Human-readable alert message'),
80
- severity: z.string().nullable().optional().describe('Alert severity level'),
81
- createdAt: z.string().nullable().optional().describe('ISO 8601 creation timestamp'),
82
- }).passthrough()).describe('Array of active alerts'),
83
- total: z.number().nullable().optional().describe('Total count of alerts'),
84
- }).passthrough().describe('Dashboard alerts requiring attention'),
85
- annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
86
- _meta: toolMeta('get_dashboard_alerts'),
87
- },
88
- async (args) => {
89
- try {
90
- const result = await client.dashboard.getAlerts(args);
91
- return {
92
- content: [{ type: 'text', text: `Found ${result.data.length} alerts.` }],
93
- structuredContent: toStructuredContent(result),
94
- };
95
- } catch (err) { return apiErrorResult(err); }
96
- },
97
- );
98
- }