@agledger/mcp-server 1.2.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 (103) hide show
  1. package/LICENSE +34 -0
  2. package/README.md +81 -0
  3. package/dist/enums.d.ts +108 -0
  4. package/dist/enums.d.ts.map +1 -0
  5. package/dist/enums.js +42 -0
  6. package/dist/enums.js.map +1 -0
  7. package/dist/errors.d.ts +5 -0
  8. package/dist/errors.d.ts.map +1 -0
  9. package/dist/errors.js +42 -0
  10. package/dist/errors.js.map +1 -0
  11. package/dist/index.d.ts +5 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +91 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/resources/contract-types.d.ts +5 -0
  16. package/dist/resources/contract-types.d.ts.map +1 -0
  17. package/dist/resources/contract-types.js +107 -0
  18. package/dist/resources/contract-types.js.map +1 -0
  19. package/dist/server.d.ts +21 -0
  20. package/dist/server.d.ts.map +1 -0
  21. package/dist/server.js +116 -0
  22. package/dist/server.js.map +1 -0
  23. package/dist/tool-scopes.d.ts +23 -0
  24. package/dist/tool-scopes.d.ts.map +1 -0
  25. package/dist/tool-scopes.js +173 -0
  26. package/dist/tool-scopes.js.map +1 -0
  27. package/dist/tools/a2a.d.ts +9 -0
  28. package/dist/tools/a2a.d.ts.map +1 -0
  29. package/dist/tools/a2a.js +492 -0
  30. package/dist/tools/a2a.js.map +1 -0
  31. package/dist/tools/agent-mandates.d.ts +5 -0
  32. package/dist/tools/agent-mandates.d.ts.map +1 -0
  33. package/dist/tools/agent-mandates.js +296 -0
  34. package/dist/tools/agent-mandates.js.map +1 -0
  35. package/dist/tools/agents-refs.d.ts +5 -0
  36. package/dist/tools/agents-refs.d.ts.map +1 -0
  37. package/dist/tools/agents-refs.js +255 -0
  38. package/dist/tools/agents-refs.js.map +1 -0
  39. package/dist/tools/capabilities.d.ts +5 -0
  40. package/dist/tools/capabilities.d.ts.map +1 -0
  41. package/dist/tools/capabilities.js +69 -0
  42. package/dist/tools/capabilities.js.map +1 -0
  43. package/dist/tools/code-mode.d.ts +5 -0
  44. package/dist/tools/code-mode.d.ts.map +1 -0
  45. package/dist/tools/code-mode.js +426 -0
  46. package/dist/tools/code-mode.js.map +1 -0
  47. package/dist/tools/compliance.d.ts +5 -0
  48. package/dist/tools/compliance.d.ts.map +1 -0
  49. package/dist/tools/compliance.js +73 -0
  50. package/dist/tools/compliance.js.map +1 -0
  51. package/dist/tools/dashboard.d.ts +5 -0
  52. package/dist/tools/dashboard.d.ts.map +1 -0
  53. package/dist/tools/dashboard.js +67 -0
  54. package/dist/tools/dashboard.js.map +1 -0
  55. package/dist/tools/disputes.d.ts +5 -0
  56. package/dist/tools/disputes.d.ts.map +1 -0
  57. package/dist/tools/disputes.js +140 -0
  58. package/dist/tools/disputes.js.map +1 -0
  59. package/dist/tools/enterprises.d.ts +5 -0
  60. package/dist/tools/enterprises.d.ts.map +1 -0
  61. package/dist/tools/enterprises.js +212 -0
  62. package/dist/tools/enterprises.js.map +1 -0
  63. package/dist/tools/events.d.ts +5 -0
  64. package/dist/tools/events.d.ts.map +1 -0
  65. package/dist/tools/events.js +48 -0
  66. package/dist/tools/events.js.map +1 -0
  67. package/dist/tools/federation-admin.d.ts +5 -0
  68. package/dist/tools/federation-admin.d.ts.map +1 -0
  69. package/dist/tools/federation-admin.js +824 -0
  70. package/dist/tools/federation-admin.js.map +1 -0
  71. package/dist/tools/federation.d.ts +5 -0
  72. package/dist/tools/federation.d.ts.map +1 -0
  73. package/dist/tools/federation.js +703 -0
  74. package/dist/tools/federation.js.map +1 -0
  75. package/dist/tools/health.d.ts +5 -0
  76. package/dist/tools/health.d.ts.map +1 -0
  77. package/dist/tools/health.js +39 -0
  78. package/dist/tools/health.js.map +1 -0
  79. package/dist/tools/mandates.d.ts +5 -0
  80. package/dist/tools/mandates.d.ts.map +1 -0
  81. package/dist/tools/mandates.js +350 -0
  82. package/dist/tools/mandates.js.map +1 -0
  83. package/dist/tools/openclaw.d.ts +9 -0
  84. package/dist/tools/openclaw.d.ts.map +1 -0
  85. package/dist/tools/openclaw.js +142 -0
  86. package/dist/tools/openclaw.js.map +1 -0
  87. package/dist/tools/receipts.d.ts +5 -0
  88. package/dist/tools/receipts.d.ts.map +1 -0
  89. package/dist/tools/receipts.js +166 -0
  90. package/dist/tools/receipts.js.map +1 -0
  91. package/dist/tools/reputation.d.ts +5 -0
  92. package/dist/tools/reputation.d.ts.map +1 -0
  93. package/dist/tools/reputation.js +72 -0
  94. package/dist/tools/reputation.js.map +1 -0
  95. package/dist/tools/schemas.d.ts +5 -0
  96. package/dist/tools/schemas.d.ts.map +1 -0
  97. package/dist/tools/schemas.js +595 -0
  98. package/dist/tools/schemas.js.map +1 -0
  99. package/dist/tools/verification.d.ts +5 -0
  100. package/dist/tools/verification.d.ts.map +1 -0
  101. package/dist/tools/verification.js +77 -0
  102. package/dist/tools/verification.js.map +1 -0
  103. package/package.json +54 -0
@@ -0,0 +1,69 @@
1
+ /** AGLedger™ — Capability MCP tools (get, declare). Patent Pending. Copyright 2026 AGLedger LLC. All rights reserved. */
2
+ import { z } from 'zod';
3
+ import { apiErrorResult } from '../errors.js';
4
+ import { toolMeta } from '../tool-scopes.js';
5
+ import { ContractTypeEnum } from '../enums.js';
6
+ const CapabilitiesOutputSchema = z.object({
7
+ agentId: z.string().describe('Agent ID'),
8
+ capabilities: z.array(ContractTypeEnum).describe('Supported contract types'),
9
+ }).describe('Agent capabilities');
10
+ export function registerCapabilityTools(mcp, client) {
11
+ // --- get_agent_capabilities ---
12
+ mcp.registerTool('get_agent_capabilities', {
13
+ title: 'Get Agent Capabilities',
14
+ description: 'Get the declared contract type capabilities for an agent.',
15
+ inputSchema: {
16
+ agentId: z.string().describe('Agent ID to check capabilities for'),
17
+ },
18
+ outputSchema: CapabilitiesOutputSchema,
19
+ annotations: {
20
+ readOnlyHint: true,
21
+ destructiveHint: false,
22
+ idempotentHint: true,
23
+ openWorldHint: true,
24
+ },
25
+ _meta: toolMeta('get_agent_capabilities'),
26
+ }, async (args) => {
27
+ try {
28
+ const result = await client.capabilities.get(args.agentId);
29
+ return {
30
+ content: [{ type: 'text', text: `Agent ${result.agentId} supports ${result.capabilities.length} contract types.` }],
31
+ structuredContent: result,
32
+ };
33
+ }
34
+ catch (err) {
35
+ return apiErrorResult(err);
36
+ }
37
+ });
38
+ // --- declare_capabilities ---
39
+ mcp.registerTool('declare_capabilities', {
40
+ title: 'Declare Capabilities',
41
+ description: 'Declare the contract types this agent supports.',
42
+ inputSchema: {
43
+ agentId: z.string().describe('Agent ID to set capabilities for'),
44
+ contractTypes: z.array(ContractTypeEnum).describe('Contract types this agent supports'),
45
+ },
46
+ outputSchema: CapabilitiesOutputSchema,
47
+ annotations: {
48
+ readOnlyHint: false,
49
+ destructiveHint: false,
50
+ idempotentHint: true,
51
+ openWorldHint: true,
52
+ },
53
+ _meta: toolMeta('declare_capabilities'),
54
+ }, async (args) => {
55
+ try {
56
+ const result = await client.capabilities.set(args.agentId, {
57
+ contractTypes: args.contractTypes,
58
+ });
59
+ return {
60
+ content: [{ type: 'text', text: `Capabilities declared for ${result.agentId}: ${result.capabilities.join(', ')}.` }],
61
+ structuredContent: result,
62
+ };
63
+ }
64
+ catch (err) {
65
+ return apiErrorResult(err);
66
+ }
67
+ });
68
+ }
69
+ //# sourceMappingURL=capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/tools/capabilities.ts"],"names":[],"mappings":"AAAA,yHAAyH;AAEzH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,OAAO,EAAE,CA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QAC9D,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;YAChE,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,oCAAoC,CAAC;SACxF;QACD,YAAY,EAAE,wBAAwB;QACtC,WAAW,EAAE;YACX,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,IAAI;SACpB;QACD,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC;KACxC,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE;gBACzD,aAAa,EAAE,IAAI,CAAC,aAAa;aAClC,CAAC,CAAC;YACH,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,6BAA6B,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;gBACpH,iBAAiB,EAAE,MAA4C;aAChE,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** AGLedger™ — Code Mode MCP tools. Patent Pending. Copyright 2026 AGLedger LLC. All rights reserved. */
2
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import type { AgledgerClient } from '@agledger/sdk';
4
+ export declare function registerCodeModeTools(mcp: McpServer, client: AgledgerClient): void;
5
+ //# sourceMappingURL=code-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-mode.d.ts","sourceRoot":"","sources":["../../src/tools/code-mode.ts"],"names":[],"mappings":"AAAA,yGAAyG;AAGzG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAsVpD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CA0HlF"}
@@ -0,0 +1,426 @@
1
+ /** AGLedger™ — Code Mode MCP tools. Patent Pending. Copyright 2026 AGLedger LLC. All rights reserved. */
2
+ import { z } from 'zod';
3
+ import { AgledgerApiError } from '@agledger/sdk';
4
+ import { apiErrorResult } from '../errors.js';
5
+ import { toolMeta } from '../tool-scopes.js';
6
+ // ---------------------------------------------------------------------------
7
+ // SDK Manifest — static description of all resources and methods
8
+ // ---------------------------------------------------------------------------
9
+ const RESOURCE_MANIFEST = {
10
+ mandates: `## client.mandates
11
+ - create(params: CreateMandateParams): Promise<Mandate>
12
+ - createAgent(params: CreateAgentMandateParams): Promise<Mandate>
13
+ - get(id: string): Promise<Mandate>
14
+ - list(params: ListMandatesParams): Promise<Page<Mandate>>
15
+ - listAll(params: ListMandatesParams): AsyncGenerator<Mandate>
16
+ - search(params: SearchMandatesParams): Promise<Page<Mandate>>
17
+ - update(id: string, params: UpdateMandateParams): Promise<Mandate>
18
+ - transition(id: string, action: MandateTransitionAction, reason?: string): Promise<Mandate>
19
+ - cancel(id: string, reason?: string): Promise<Mandate>
20
+ - accept(id: string): Promise<Mandate>
21
+ - reject(id: string, reason?: string): Promise<Mandate>
22
+ - counterPropose(id: string, params: CounterProposeParams): Promise<Mandate>
23
+ - acceptCounter(id: string): Promise<Mandate>
24
+ - getChain(id: string): Promise<Mandate[]>
25
+ - getSubMandates(id: string): Promise<Page<Mandate>>
26
+ - delegate(id: string, params: DelegateMandateParams): Promise<Mandate>
27
+ - bulkCreate(mandates: CreateMandateParams[]): Promise<BulkCreateResult>
28
+ - getAudit(id: string): Promise<AuditChain>
29
+ - listAsPrincipal(): Promise<Page<Mandate>>
30
+ - listProposals(): Promise<Page<Mandate>>
31
+ - requestRevision(id: string, reason?: string): Promise<Mandate>
32
+ - createAndActivate(params: CreateMandateParams): Promise<Mandate>
33
+ - reportOutcome(id: string, params: ReportOutcomeParams): Promise<OutcomeResult>
34
+ - getSummary(params?: { enterpriseId?: string }): Promise<MandateStatusSummary>
35
+ - getGraph(id: string): Promise<Record<string, unknown>>
36
+ - batchGet(ids: string[]): Promise<Mandate[]>
37
+ - getValidTransitions(mandate: Mandate): readonly string[] (client-side, no API call)`,
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
+ verification: `## client.verification
44
+ - verify(mandateId: string, receiptIds?: string[]): Promise<VerificationResult>
45
+ - getStatus(mandateId: string): Promise<VerificationStatus>`,
46
+ disputes: `## client.disputes
47
+ - create(mandateId: string, params: CreateDisputeParams): Promise<Dispute>
48
+ - get(mandateId: string): Promise<DisputeResponse>
49
+ - escalate(mandateId: string): Promise<Dispute>
50
+ - submitEvidence(mandateId: string, params: { evidenceType: EvidenceType; payload: Record<string, unknown> }): Promise<Record<string, unknown>>`,
51
+ webhooks: `## client.webhooks
52
+ - create(params: CreateWebhookParams): Promise<Webhook>
53
+ - list(params?: ListWebhooksParams): Promise<Page<Webhook>>
54
+ - get(webhookId: string): Promise<Webhook>
55
+ - update(webhookId: string, params: Partial<CreateWebhookParams>): Promise<Webhook>
56
+ - delete(webhookId: string): Promise<void>
57
+ - pause(webhookId: string): Promise<Webhook>
58
+ - resume(webhookId: string): Promise<Webhook>
59
+ - rotate(webhookId: string): Promise<Webhook>
60
+ - ping(webhookId: string): Promise<WebhookTestResult>
61
+ - listDeliveries(webhookId: string, params?: ListParams & { status?: string }): Promise<Page<WebhookDelivery>>
62
+ - listDlq(webhookId: string, params?: ListParams): Promise<Page<WebhookDlqEntry>>
63
+ - retryAllDlq(webhookId: string): Promise<{ retried: number }>
64
+ - retryDlq(webhookId: string, dlqId: string): Promise<Record<string, unknown>>`,
65
+ reputation: `## client.reputation
66
+ - getAgent(agentId: string): Promise<Page<ReputationScore>>
67
+ - getByContractType(agentId: string, contractType: string): Promise<ReputationScore>
68
+ - getHistory(agentId: string, params?: ListParams & { from?: string; to?: string; contractType?: string; outcome?: 'PASS' | 'FAIL' }): Promise<Page<ReputationHistoryEntry>>`,
69
+ events: `## client.events
70
+ - list(params: { since: string; order?: 'asc' | 'desc' } & ListParams): Promise<Page<AgledgerEvent>>
71
+ - listAll(params: { since: string; order?: 'asc' | 'desc' } & ListParams): AsyncGenerator<AgledgerEvent>
72
+ - getAuditChain(mandateId: string): Promise<AuditChain>`,
73
+ schemas: `## client.schemas
74
+ - list(params?: { enterpriseId?: string }): Promise<Page<ContractType>>
75
+ - get(contractType: string): Promise<ContractSchema>
76
+ - delete(contractType: string): Promise<void>
77
+ - getRules(contractType: string): Promise<{ contractType; syncRuleIds; asyncRuleIds }>
78
+ - validateReceipt(contractType: string, evidence: Record<string, unknown>): Promise<SchemaValidationResult>
79
+ - getMetaSchema(): Promise<MetaSchema>
80
+ - getTemplate(contractType: string): Promise<SchemaTemplate>
81
+ - getBlankTemplate(): Promise<SchemaTemplate>
82
+ - getVersions(contractType: string): Promise<SchemaVersionDetail[]>
83
+ - getVersion(contractType: string, version: number): Promise<SchemaVersionDetail>
84
+ - diff(contractType: string, from: number, to: number): Promise<SchemaDiffResult>
85
+ - preview(input: SchemaPreviewInput): Promise<SchemaPreviewResult>
86
+ - checkCompatibility(contractType: string, schemas: { mandateSchema; receiptSchema }): Promise<SchemaCompatibilityResult>
87
+ - register(input: RegisterSchemaParams): Promise<SchemaVersionDetail>
88
+ - updateVersion(contractType: string, version: number, params: UpdateSchemaVersionParams): Promise<SchemaVersionDetail>
89
+ - exportSchema(contractType: string, opts?: ExportSchemaOptions): Promise<SchemaExportResult>
90
+ - importSchema(payload: SchemaImportPayload, opts?: ImportSchemaOptions): Promise<SchemaImportResult>
91
+ - previewImport(payload: SchemaImportPayload, opts?: ImportSchemaOptions): Promise<SchemaImportDryRunResult>`,
92
+ dashboard: `## client.dashboard
93
+ - getSummary(): Promise<DashboardSummary>
94
+ - getMetrics(params?: DashboardMetricsParams): Promise<DashboardMetrics>
95
+ - listAgents(params?: DashboardAgentParams): Promise<Page<DashboardAgent>>
96
+ - getAlerts(params?: ListParams): Promise<Page<DashboardAlert>>
97
+ - getDisputes(params?: ListParams): Promise<Page<Record<string, unknown>>>
98
+ - getAuditTrail(params?: ListParams): Promise<Page<Record<string, unknown>>>`,
99
+ compliance: `## client.compliance
100
+ - export(params: ExportComplianceParams): Promise<ComplianceExport>
101
+ - getExportStatus(exportId: string): Promise<ComplianceExport>
102
+ - downloadExport(exportId: string): Promise<Record<string, unknown>>
103
+ - waitForExport(exportId: string, opts?: { pollIntervalMs?; timeoutMs?; signal? }): Promise<ComplianceExport>
104
+ - createAssessment(mandateId: string, params: CreateAiImpactAssessmentParams): Promise<AiImpactAssessment>
105
+ - getAssessment(mandateId: string): Promise<AiImpactAssessment>
106
+ - getEuAiActReport(params?: { from?; to? }): Promise<EuAiActReport>
107
+ - getEnterpriseReport(params?: { from?; to?; format? }): Promise<Record<string, unknown>>
108
+ - analyzeAudit(mandateId: string): Promise<Record<string, unknown>>
109
+ - createRecord(mandateId: string, params: CreateComplianceRecordParams): Promise<ComplianceRecord>
110
+ - listRecords(mandateId: string, params?: ListParams): Promise<Page<ComplianceRecord>>
111
+ - getRecord(mandateId: string, recordId: string): Promise<ComplianceRecord>
112
+ - exportMandate(mandateId: string, params?: { format?: 'json' | 'csv' | 'ndjson' }): Promise<MandateAuditExport>
113
+ - stream(params: AuditStreamParams): Promise<AuditStreamResult>
114
+ - streamAll(params: AuditStreamParams): AsyncGenerator<Record<string, unknown>>`,
115
+ registration: `## client.registration
116
+ - getMe(): Promise<AccountProfile>
117
+ - register(params: RegisterParams): Promise<RegisterResult>
118
+ - registerEnterprise(params: { name: string; email?: string }): Promise<RegisterResult>
119
+ - registerAgent(params: { name: string; email?: string; agentCardUrl?: string; enterpriseId?: string }): Promise<RegisterResult>
120
+ - verifyAgentCard(agentCardUrl: string): Promise<Record<string, unknown>>
121
+ - rotateApiKey(): Promise<{ apiKey: string }>
122
+ - verifyEmail(token: string): Promise<{ sandboxMode: boolean; status: string }>
123
+ - sendVerificationEmail(email: string): Promise<{ sandboxMode: boolean; status: string }>`,
124
+ health: `## client.health
125
+ - check(): Promise<HealthResponse>
126
+ - status(): Promise<StatusResponse>
127
+ - conformance(): Promise<ConformanceResponse>`,
128
+ proxy: `## client.proxy
129
+ Unified resource with sub-resources for governance sidecar proxy operations.
130
+ - syncSession(params: SyncSessionParams): Promise<SyncSessionResult>
131
+
132
+ ### client.proxy.sessions
133
+ - create(params: CreateSessionParams): Promise<ProxySession>
134
+ - get(sessionId: string): Promise<ProxySession>
135
+ - list(params?: ListParams): Promise<Page<ProxySession>>
136
+ - sync(params: SyncSessionParams): Promise<SyncSessionResult>
137
+
138
+ ### client.proxy.toolCalls
139
+ - ingest(sessionId: string, items: ToolCallBatchItem[]): Promise<BatchResult<ProxyToolCall>>
140
+ - list(sessionId: string, params?: ListParams): Promise<Page<ProxyToolCall>>
141
+
142
+ ### client.proxy.sidecarMandates
143
+ - ingest(sessionId: string, items: SidecarMandateBatchItem[]): Promise<BatchResult<ProxySidecarMandate>>
144
+ - list(params?: ListParams & { sessionId?: string }): Promise<Page<ProxySidecarMandate>>
145
+ - listBySession(sessionId: string, params?: ListParams): Promise<Page<ProxySidecarMandate>>
146
+ - update(id: string, params: UpdateSidecarMandateParams): Promise<ProxySidecarMandate>
147
+ - formalize(id: string, formalizedMandateId: string): Promise<ProxySidecarMandate>
148
+ - dismiss(id: string): Promise<ProxySidecarMandate>
149
+
150
+ ### client.proxy.sidecarReceipts
151
+ - ingest(sessionId: string, items: SidecarReceiptBatchItem[]): Promise<BatchResult<ProxySidecarReceipt>>
152
+ - listBySession(sessionId: string, params?: ListParams): Promise<Page<ProxySidecarReceipt>>
153
+
154
+ ### client.proxy.toolCatalog
155
+ - ingest(sessionId: string, items: ToolCatalogBatchItem[]): Promise<BatchResult<ProxyToolCatalogEntry>>
156
+ - list(sessionId: string): Promise<Page<ProxyToolCatalogEntry>>
157
+
158
+ ### client.proxy.analytics
159
+ - getSession(sessionId: string): Promise<SessionAnalytics>
160
+ - getSummary(params?: { from?; to? }): Promise<AnalyticsSummary>
161
+ - getMandateSummary(sessionId: string): Promise<MandateSummary>
162
+ - getAlignment(sessionId: string): Promise<AlignmentAnalysis>`,
163
+ admin: `## client.admin
164
+ Platform-level administration. Requires platform API key.
165
+ - listEnterprises(params?: ListParams): Promise<Page<AdminEnterprise>>
166
+ - createEnterprise(params: CreateEnterpriseParams): Promise<AdminEnterprise>
167
+ - listAgents(params?: ListParams): Promise<Page<AdminAgent>>
168
+ - createAgent(params: CreateAgentParams): Promise<AdminAgent>
169
+ - updateTrustLevel(accountId: string, params: UpdateTrustLevelParams): Promise<Record<string, unknown>>
170
+ - deactivateAccount(accountId: string, params: { accountType: 'enterprise' | 'agent'; reason?: string }): Promise<Record<string, unknown>>
171
+ - setCapabilities(agentId: string, params: SetCapabilitiesParams): Promise<Record<string, unknown>>
172
+ - getFleetCapabilities(): Promise<Page<{ agentId; capabilities }>>
173
+ - getEnterpriseConfig(enterpriseId: string): Promise<EnterpriseConfig>
174
+ - replaceEnterpriseConfig(enterpriseId: string, params: SetEnterpriseConfigParams): Promise<EnterpriseConfig>
175
+ - updateEnterpriseConfig(enterpriseId: string, params: SetEnterpriseConfigParams): Promise<EnterpriseConfig>
176
+ - listApiKeys(params?: ListParams): Promise<Page<AdminApiKey>>
177
+ - createApiKey(params: CreateApiKeyParams): Promise<CreateApiKeyResult>
178
+ - toggleApiKey(keyId: string, isActive: boolean): Promise<AdminApiKey>
179
+ - bulkRevokeApiKeys(keyIds: string[]): Promise<{ revoked: number }>
180
+ - getLicense(): Promise<LicenseInfo>
181
+ - listMandates(params?: QueryAdminMandatesParams): Promise<Page<Record<string, unknown>>>
182
+ - listDlq(params?: ListParams): Promise<Page<WebhookDlqEntry>>
183
+ - retryDlq(dlqId: string): Promise<Record<string, unknown>>
184
+ - retryAllDlq(): Promise<{ retried: number }>
185
+ - getSystemHealth(): Promise<SystemHealth>
186
+ - listRateLimitExemptions(): Promise<Page<string>>
187
+ - setRateLimitExemption(ip: string): Promise<{ ip; exempt }>
188
+ - deleteRateLimitExemption(ip: string): Promise<{ ip; exempt }>
189
+ - getWebhookHealth(params?: ListParams): Promise<Page<Record<string, unknown>>>
190
+ - updateCircuitBreaker(webhookId: string, params: UpdateCircuitBreakerParams): Promise<CircuitBreakerResult>
191
+ - listVaultSigningKeys(): Promise<VaultSigningKey[]>
192
+ - rotateVaultSigningKey(): Promise<VaultSigningKey>
193
+ - listVaultAnchors(): Promise<VaultAnchor[]>
194
+ - verifyVaultAnchors(): Promise<VaultAnchorVerifyResult>
195
+ - startVaultScan(): Promise<VaultScanJob>
196
+ - getVaultScanStatus(jobId: string): Promise<VaultScanJob>
197
+ - flushAuthCache(): Promise<{ flushed: boolean }>
198
+ - getAuthCacheStats(): Promise<AuthCacheStats>
199
+ - flushSchemaCache(): Promise<{ flushed: boolean }>
200
+ - listOwnerRateLimitExemptions(): Promise<Record<string, unknown>[]>
201
+ - setOwnerRateLimitExemption(ownerId: string): Promise<Record<string, unknown>>
202
+ - deleteOwnerRateLimitExemption(ownerId: string): Promise<Record<string, unknown>>`,
203
+ a2a: `## client.a2a
204
+ Agent-to-Agent protocol (A2A). JSON-RPC 2.0 dispatch.
205
+ - getAgentCard(): Promise<AgentCard>
206
+ - dispatch(request: JsonRpcRequest): Promise<JsonRpcResponse>
207
+ - call(method: string, params?: Record<string, unknown>): Promise<JsonRpcResponse>`,
208
+ capabilities: `## client.capabilities
209
+ - get(agentId: string): Promise<{ agentId; capabilities: ContractType[] }>
210
+ - set(agentId: string, params: SetCapabilitiesParams): Promise<{ agentId; capabilities: ContractType[] }> (PUT — replaces all)`,
211
+ notarize: `## client.notarize
212
+ Agent-to-agent agreement notarization (OpenClaw flow).
213
+ - createMandate(params: NotarizeMandateParams): Promise<NotarizeMandateResult>
214
+ - getMandate(id: string): Promise<NotarizedMandate>
215
+ - getHistory(id: string): Promise<NotarizeHistory>
216
+ - acceptMandate(id: string): Promise<NotarizedMandate>
217
+ - counterPropose(id: string, params: NotarizeCounterProposeParams): Promise<NotarizeMandateResult>
218
+ - submitReceipt(id: string, params: NotarizeReceiptParams): Promise<NotarizeReceiptResult>
219
+ - renderVerdict(id: string, params: NotarizeVerdictParams): Promise<NotarizedMandate>
220
+ - verify(params: NotarizeVerifyParams): Promise<NotarizeVerifyResult>`,
221
+ enterprises: `## client.enterprises
222
+ Enterprise agent approval registry.
223
+ - approveAgent(enterpriseId: string, agentId: string, params?: ApproveAgentParams): Promise<EnterpriseAgentRecord>
224
+ - revokeAgent(enterpriseId: string, agentId: string, params?: RevokeAgentParams): Promise<void>
225
+ - updateAgentStatus(enterpriseId: string, agentId: string, params: UpdateAgentStatusParams): Promise<EnterpriseAgentRecord>
226
+ - bulkApprove(enterpriseId: string, params: BulkApproveAgentParams): Promise<BulkApproveResult>
227
+ - listAgents(enterpriseId: string, params?: ListEnterpriseAgentsParams): Promise<Page<EnterpriseAgentRecord>>
228
+ - getAgent(enterpriseId: string, agentId: string): Promise<EnterpriseAgentRecord>
229
+ `,
230
+ projects: `## client.projects
231
+ - create(params: CreateProjectParams): Promise<Project>
232
+ - list(params?: ListParams): Promise<Page<Project>>
233
+ - get(projectId: string): Promise<Project>
234
+ - update(projectId: string, params: UpdateProjectParams): Promise<Project>
235
+ - delete(projectId: string): Promise<void>`,
236
+ federation: `## client.federation
237
+ Gateway-facing federation operations. Most methods require a bearer token from register().
238
+ - register(params: RegisterGatewayParams): Promise<RegisterGatewayResult> (no auth header)
239
+ - heartbeat(params: HeartbeatParams): Promise<HeartbeatResult>
240
+ - registerAgent(params: RegisterFederatedAgentParams): Promise<{ registered: boolean }>
241
+ - listAgents(params?: ListFederatedAgentsParams): Promise<Page<FederationAgent>>
242
+ - submitStateTransition(params: SubmitStateTransitionParams): Promise<StateTransitionResult>
243
+ - relaySignal(params: RelaySignalParams): Promise<SignalRelayResult>
244
+ - rotateKey(gatewayId: string, params: RotateGatewayKeyParams): Promise<{ rotated: boolean }>
245
+ - revoke(gatewayId: string, params: RevokeGatewayParams): Promise<{ revoked; revokedAt }> (no auth header)
246
+ - catchUp(params: FederationCatchUpParams): Promise<{ data: FederationAuditEntry[]; hasMore }>
247
+ - stream(params?: { since?: string }): Promise<Record<string, unknown>>
248
+ - publishSchema(contractType: string, params: SchemaPublishParams): Promise<ContractSchema>
249
+ - confirmSchemaPublish(contractType: string, params: SchemaConfirmParams): Promise<ContractSchema>
250
+ - listContractTypes(): Promise<ContractSchema[]>
251
+ - getContractType(contractType: string): Promise<ContractSchema>
252
+ - getMandateCriteria(mandateId: string): Promise<FederationMandateCriteria>
253
+ - submitMandateCriteria(mandateId: string, params: SubmitMandateCriteriaParams): Promise<FederationMandateCriteria>
254
+ - contributeReputation(params: ContributeReputationParams): Promise<{ contributed: boolean }>
255
+ - getAgentReputation(agentId: string): Promise<FederationAgentReputation>
256
+ - broadcastRevocations(params: RevocationBroadcastParams): Promise<{ broadcast: boolean }>
257
+ - syncAgentDirectory(params: AgentDirectorySyncParams): Promise<{ synced: boolean }>`,
258
+ federationAdmin: `## client.federationAdmin
259
+ Platform admin operations for federation. Requires admin:system scope.
260
+ - createRegistrationToken(params?: CreateRegistrationTokenParams): Promise<FederationRegistrationToken>
261
+ - listGateways(params?: ListFederationGatewaysParams): Promise<Page<FederationGateway>>
262
+ - revokeGateway(gatewayId: string, params: AdminRevokeGatewayParams): Promise<{ revoked; nextSteps }>
263
+ - queryMandates(params?: QueryFederationMandatesParams): Promise<Page<FederationMandate>>
264
+ - getAuditLog(params?: FederationAuditLogParams): Promise<Page<FederationAuditEntry>>
265
+ - getHealth(): Promise<FederationHealthSummary>
266
+ - resetSequence(gatewayId: string, params?: ResetSequenceParams): Promise<{ reset; nextSteps }>
267
+ - listDlq(params?: ListOutboundDlqParams): Promise<Page<FederationDlqEntry>>
268
+ - retryDlq(dlqId: string): Promise<{ retried; nextSteps }>
269
+ - deleteDlq(dlqId: string): Promise<{ deleted: boolean }>
270
+ - rotateHubKey(): Promise<HubSigningKey>
271
+ - listHubKeys(): Promise<HubSigningKey[]>
272
+ - activateHubKey(keyId: string): Promise<HubSigningKey>
273
+ - expireHubKey(keyId: string): Promise<HubSigningKey>
274
+ - registerPeer(params: PeerRegistrationParams): Promise<FederationPeer>
275
+ - listPeers(): Promise<Page<FederationPeer>>
276
+ - getPeer(hubId: string): Promise<FederationPeer>
277
+ - revokePeer(hubId: string): Promise<{ revoked: boolean }>
278
+ - resyncPeer(hubId: string): Promise<{ synced: boolean }>
279
+ - createPeeringToken(): Promise<PeeringToken>
280
+ - deleteSchemaVersion(contractType: string, version: string): Promise<{ deleted: boolean }>
281
+ - listReputationContributions(agentId: string): Promise<ReputationContribution[]>
282
+ - resetReputation(agentId: string): Promise<{ reset: boolean }>
283
+ - getMandateCriteriaStatus(mandateId: string): Promise<MandateCriteriaStatus>`,
284
+ agents: `## client.agents
285
+ Agent identity management.
286
+ - get(agentId: string): Promise<AgentProfile>
287
+ - update(agentId: string, params: UpdateAgentParams): Promise<AgentProfile>
288
+ - addReferences(agentId: string, references: Record<string, unknown>[]): Promise<Record<string, unknown>>
289
+ - getReferences(agentId: string): Promise<Record<string, unknown>>`,
290
+ references: `## client.references
291
+ Reverse lookup for external references.
292
+ - lookup(params: { system: string; refType: string; refId: string }): Promise<ReferenceLookupResult>
293
+ - addMandateReferences(mandateId: string, references: Record<string, unknown>[]): Promise<Record<string, unknown>>
294
+ - getMandateReferences(mandateId: string): Promise<Record<string, unknown>>`,
295
+ };
296
+ const RESOURCE_NAMES = Object.keys(RESOURCE_MANIFEST);
297
+ function buildFullManifest() {
298
+ const header = `# AGLedger SDK — Resource Manifest
299
+ 23 resources, ~200 methods. Use \`sdk_execute\` to call any method.
300
+ The \`client\` variable is a pre-configured AgledgerClient instance.
301
+
302
+ **Pagination**: \`list()\` returns \`Page<T>\` with \`.data\`, \`.total\`, \`.hasMore\`, \`.cursor\`. Use \`listAll()\` for auto-paginating async iterators.
303
+ **Options**: All methods accept an optional trailing \`RequestOptions\` parameter (timeout, idempotencyKey, authOverride).
304
+ **Errors**: SDK throws typed errors — \`AgledgerApiError\`, \`AuthenticationError\`, \`PermissionError\`, \`NotFoundError\`, \`RateLimitError\`, etc.
305
+
306
+ ---
307
+
308
+ `;
309
+ return header + RESOURCE_NAMES.map((name) => RESOURCE_MANIFEST[name]).join('\n\n');
310
+ }
311
+ const FULL_MANIFEST = buildFullManifest();
312
+ // ---------------------------------------------------------------------------
313
+ // Tool Registration
314
+ // ---------------------------------------------------------------------------
315
+ export function registerCodeModeTools(mcp, client) {
316
+ // --- sdk_execute ---
317
+ mcp.registerTool('sdk_execute', {
318
+ title: 'Execute SDK Code',
319
+ description: `Execute TypeScript/JavaScript code against the AGLedger SDK client. The \`client\` variable is a pre-configured AgledgerClient instance with all 23 resources available.
320
+
321
+ Example usage:
322
+ - \`const mandate = await client.mandates.get("mnd-abc123"); return mandate;\`
323
+ - \`const page = await client.mandates.list({ status: "ACTIVE", limit: 10 }); return page.data;\`
324
+ - \`await client.mandates.transition("mnd-abc123", { action: "register" }); return "done";\`
325
+
326
+ 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.
327
+
328
+ Available resources: ${RESOURCE_NAMES.join(', ')}.
329
+
330
+ 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.`,
331
+ inputSchema: {
332
+ code: z.string().describe('TypeScript/JavaScript code to execute. Use `client` to access the SDK. Return a value to see results.'),
333
+ },
334
+ outputSchema: z.object({
335
+ result: z.unknown().describe('The return value of the executed code'),
336
+ executionTimeMs: z.number().describe('Execution time in milliseconds'),
337
+ }),
338
+ annotations: {
339
+ readOnlyHint: false,
340
+ destructiveHint: true,
341
+ idempotentHint: false,
342
+ openWorldHint: true,
343
+ },
344
+ _meta: toolMeta('sdk_execute'),
345
+ }, async (args) => {
346
+ const TIMEOUT_MS = 30_000;
347
+ const start = Date.now();
348
+ try {
349
+ // Use AsyncFunction constructor to support top-level await
350
+ // NOTE: This executes in the same process as the MCP server — the caller
351
+ // (agent) is already trusted with the API key. The timeout prevents runaway
352
+ // code from hanging the server. For untrusted execution, use a sandbox.
353
+ const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
354
+ const fn = new AsyncFunction('client', args.code);
355
+ const timeout = new Promise((_, reject) => setTimeout(() => reject(new Error(`Execution timed out after ${TIMEOUT_MS}ms`)), TIMEOUT_MS));
356
+ const result = await Promise.race([fn(client), timeout]);
357
+ const executionTimeMs = Date.now() - start;
358
+ let serialized;
359
+ try {
360
+ serialized = JSON.stringify(result, null, 2) ?? 'undefined';
361
+ }
362
+ catch {
363
+ serialized = '[Result contains circular references]';
364
+ }
365
+ return {
366
+ content: [{ type: 'text', text: `Execution completed in ${executionTimeMs}ms.\n\n${serialized}` }],
367
+ structuredContent: { result, executionTimeMs },
368
+ };
369
+ }
370
+ catch (err) {
371
+ const executionTimeMs = Date.now() - start;
372
+ if (err instanceof AgledgerApiError) {
373
+ return apiErrorResult(err);
374
+ }
375
+ return {
376
+ content: [{ type: 'text', text: `Execution error after ${executionTimeMs}ms: ${err instanceof Error ? err.message : String(err)}` }],
377
+ isError: true,
378
+ };
379
+ }
380
+ });
381
+ // --- sdk_describe ---
382
+ mcp.registerTool('sdk_describe', {
383
+ title: 'Describe SDK Resources',
384
+ 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\`.
385
+
386
+ Pass a \`resource\` name (e.g., "mandates", "federation") for detailed info on one resource, or omit it for the full manifest.
387
+
388
+ Available resources: ${RESOURCE_NAMES.join(', ')}.`,
389
+ inputSchema: {
390
+ resource: z.string().optional().describe('Resource name to describe (e.g., "mandates", "federation"). Omit for full manifest.'),
391
+ },
392
+ outputSchema: z.object({
393
+ manifest: z.string().describe('SDK resource manifest with method signatures'),
394
+ resourceCount: z.number().describe('Number of resources described'),
395
+ }),
396
+ annotations: {
397
+ readOnlyHint: true,
398
+ destructiveHint: false,
399
+ idempotentHint: true,
400
+ openWorldHint: false,
401
+ },
402
+ _meta: toolMeta('sdk_describe'),
403
+ }, async (args) => {
404
+ if (args.resource) {
405
+ const name = args.resource.toLowerCase().replace(/[-_\s]/g, '');
406
+ // Try exact match first, then normalized match
407
+ const key = RESOURCE_NAMES.find((k) => k === args.resource || k.toLowerCase().replace(/[-_\s]/g, '') === name);
408
+ if (!key) {
409
+ return {
410
+ content: [{ type: 'text', text: `Unknown resource "${args.resource}". Available: ${RESOURCE_NAMES.join(', ')}` }],
411
+ isError: true,
412
+ };
413
+ }
414
+ const manifest = RESOURCE_MANIFEST[key];
415
+ return {
416
+ content: [{ type: 'text', text: manifest }],
417
+ structuredContent: { manifest, resourceCount: 1 },
418
+ };
419
+ }
420
+ return {
421
+ content: [{ type: 'text', text: FULL_MANIFEST }],
422
+ structuredContent: { manifest: FULL_MANIFEST, resourceCount: RESOURCE_NAMES.length },
423
+ };
424
+ });
425
+ }
426
+ //# sourceMappingURL=code-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-mode.js","sourceRoot":"","sources":["../../src/tools/code-mode.ts"],"names":[],"mappings":"AAAA,yGAAyG;AAEzG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC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IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,IAAI,CAAC,QAAQ,iBAAiB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;oBACjH,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;YACD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;YACxC,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;gBAC3C,iBAAiB,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,EAAE;aAClD,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;YAChD,iBAAiB,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,CAAC,MAAM,EAAE;SACrF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** AGLedger™ — Compliance MCP tools. Patent Pending. Copyright 2026 AGLedger LLC. All rights reserved. */
2
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import type { AgledgerClient } from '@agledger/sdk';
4
+ export declare function registerComplianceTools(mcp: McpServer, client: AgledgerClient): void;
5
+ //# sourceMappingURL=compliance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compliance.d.ts","sourceRoot":"","sources":["../../src/tools/compliance.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAG1G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpD,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAwEpF"}
@@ -0,0 +1,73 @@
1
+ /** AGLedger™ — Compliance MCP tools. Patent Pending. Copyright 2026 AGLedger LLC. All rights reserved. */
2
+ import { z } from 'zod';
3
+ import { apiErrorResult } from '../errors.js';
4
+ import { toolMeta } from '../tool-scopes.js';
5
+ export function registerComplianceTools(mcp, client) {
6
+ mcp.registerTool('create_compliance_record', {
7
+ title: 'Create Compliance Record',
8
+ description: 'Create a per-mandate compliance attestation. Record types: workplace_notification, affected_persons, input_data_quality, fundamental_rights_impact_assessment.',
9
+ inputSchema: {
10
+ mandateId: z.string().describe('Mandate ID to attach the record to'),
11
+ recordType: z.string().describe('Record type (e.g. workplace_notification, affected_persons)'),
12
+ attestation: z.record(z.string(), z.unknown()).describe('Attestation data'),
13
+ attestedBy: z.string().describe('Who attested (name or ID)'),
14
+ },
15
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
16
+ _meta: toolMeta('create_compliance_record'),
17
+ }, async (args) => {
18
+ try {
19
+ const record = await client.compliance.createRecord(args.mandateId, {
20
+ recordType: args.recordType,
21
+ attestation: args.attestation,
22
+ attestedBy: args.attestedBy,
23
+ });
24
+ return {
25
+ content: [{ type: 'text', text: `Compliance record created for mandate ${args.mandateId} (type: ${args.recordType}).` }],
26
+ structuredContent: record,
27
+ };
28
+ }
29
+ catch (err) {
30
+ return apiErrorResult(err);
31
+ }
32
+ });
33
+ mcp.registerTool('list_compliance_records', {
34
+ title: 'List Compliance Records',
35
+ description: 'List compliance attestation records for a mandate.',
36
+ inputSchema: {
37
+ mandateId: z.string().describe('Mandate ID'),
38
+ limit: z.number().optional().describe('Page size'),
39
+ },
40
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
41
+ _meta: toolMeta('list_compliance_records'),
42
+ }, async (args) => {
43
+ try {
44
+ const result = await client.compliance.listRecords(args.mandateId, { limit: args.limit });
45
+ return {
46
+ content: [{ type: 'text', text: `Found ${result.data.length} compliance records for mandate ${args.mandateId}.` }],
47
+ structuredContent: result,
48
+ };
49
+ }
50
+ catch (err) {
51
+ return apiErrorResult(err);
52
+ }
53
+ });
54
+ mcp.registerTool('get_eu_ai_act_report', {
55
+ title: 'EU AI Act Report',
56
+ description: 'Get EU AI Act compliance report showing risk classifications, human oversight designations, and audit status across all mandates.',
57
+ inputSchema: {},
58
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
59
+ _meta: toolMeta('get_eu_ai_act_report'),
60
+ }, async () => {
61
+ try {
62
+ const report = await client.compliance.getEuAiActReport();
63
+ return {
64
+ content: [{ type: 'text', text: `EU AI Act report: ${report.summary.highRiskCount} high-risk mandates, ${report.summary.auditedCount} audited.` }],
65
+ structuredContent: report,
66
+ };
67
+ }
68
+ catch (err) {
69
+ return apiErrorResult(err);
70
+ }
71
+ });
72
+ }
73
+ //# sourceMappingURL=compliance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compliance.js","sourceRoot":"","sources":["../../src/tools/compliance.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAE1G,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,UAAU,uBAAuB,CAAC,GAAc,EAAE,MAAsB;IAC5E,GAAG,CAAC,YAAY,CACd,0BAA0B,EAC1B;QACE,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE,gKAAgK;QAC7K,WAAW,EAAE;YACX,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;YACpE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6DAA6D,CAAC;YAC9F,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,kBAAkB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AAG,EAAE,CAAC;YAAC,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC;QAAC,CAAC;IAC/C,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** AGLedger™ — Dashboard MCP tools. Patent Pending. Copyright 2026 AGLedger LLC. All rights reserved. */
2
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import type { AgledgerClient } from '@agledger/sdk';
4
+ export declare function registerDashboardTools(mcp: McpServer, client: AgledgerClient): void;
5
+ //# sourceMappingURL=dashboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../src/tools/dashboard.ts"],"names":[],"mappings":"AAAA,yGAAyG;AAGzG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAkEnF"}