@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,181 +0,0 @@
1
- import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
2
- import { registerEnterpriseTools } from '../../src/tools/enterprises.js';
3
- import { createTestHarness, type TestHarness } from '../harness.js';
4
- import { assertErrorResult, assertSuccessResult } from '../conformance.js';
5
-
6
- const MOCK_ENTERPRISE = {
7
- id: 'ent-1',
8
- name: 'Acme Corp',
9
- slug: 'acme-corp',
10
- trustLevel: 'active',
11
- createdAt: '2026-04-13T00:00:00Z',
12
- };
13
-
14
- const MOCK_AGENT = {
15
- id: 'agent-1',
16
- displayName: 'Data Processor',
17
- slug: 'data-processor',
18
- trustLevel: 'sandbox',
19
- createdAt: '2026-04-13T00:00:00Z',
20
- };
21
-
22
- describe('enterprise tools', () => {
23
- let harness: TestHarness;
24
-
25
- const EXPECTED_TOOLS = [
26
- 'approve_enterprise_agent', 'create_agent', 'create_enterprise',
27
- 'list_enterprise_agents', 'revoke_enterprise_agent', 'set_enterprise_config',
28
- ];
29
-
30
- beforeAll(async () => {
31
- harness = await createTestHarness({
32
- registerFns: [registerEnterpriseTools],
33
- mockOverrides: {
34
- enterprises: {
35
- approveAgent: vi.fn().mockResolvedValue({ agentId: 'agent-1', enterpriseId: 'e-1', status: 'approved' }),
36
- revokeAgent: vi.fn().mockResolvedValue(undefined),
37
- listAgents: vi.fn().mockResolvedValue({ data: [{ agentId: 'agent-1', status: 'approved' }] }),
38
- },
39
- admin: {
40
- createEnterprise: vi.fn().mockResolvedValue(MOCK_ENTERPRISE),
41
- createAgent: vi.fn().mockResolvedValue(MOCK_AGENT),
42
- setEnterpriseConfig: vi.fn().mockResolvedValue({ enterpriseId: 'ent-1', config: {} }),
43
- },
44
- },
45
- });
46
- });
47
-
48
- afterAll(async () => { await harness.cleanup(); });
49
-
50
- it('registers exactly 6 tools', async () => {
51
- const { tools } = await harness.client.listTools();
52
- expect(tools.map((t: any) => t.name).sort()).toEqual(EXPECTED_TOOLS);
53
- });
54
-
55
- describe('approve_enterprise_agent', () => {
56
- it('approves an agent', async () => {
57
- const result = await harness.client.callTool({
58
- name: 'approve_enterprise_agent',
59
- arguments: { enterpriseId: 'ent-1', agentId: 'agent-1' },
60
- });
61
- assertSuccessResult(result as any);
62
- expect((result as any).content[0].text).toContain('agent-1');
63
- expect((result as any).content[0].text).toContain('approved');
64
- });
65
-
66
- it('returns error on failure', async () => {
67
- (harness.mockSdk.enterprises as any).approveAgent.mockRejectedValueOnce(new Error('Not found'));
68
- const result = await harness.client.callTool({
69
- name: 'approve_enterprise_agent',
70
- arguments: { enterpriseId: 'bad', agentId: 'bad' },
71
- });
72
- assertErrorResult(result as any);
73
- });
74
- });
75
-
76
- describe('revoke_enterprise_agent', () => {
77
- it('revokes an agent', async () => {
78
- const result = await harness.client.callTool({
79
- name: 'revoke_enterprise_agent',
80
- arguments: { enterpriseId: 'ent-1', agentId: 'agent-1', reason: 'No longer needed' },
81
- });
82
- assertSuccessResult(result as any);
83
- expect((result as any).content[0].text).toContain('revoked');
84
- });
85
-
86
- it('returns error on failure', async () => {
87
- (harness.mockSdk.enterprises as any).revokeAgent.mockRejectedValueOnce(new Error('Not found'));
88
- const result = await harness.client.callTool({
89
- name: 'revoke_enterprise_agent',
90
- arguments: { enterpriseId: 'bad', agentId: 'bad' },
91
- });
92
- assertErrorResult(result as any);
93
- });
94
- });
95
-
96
- describe('list_enterprise_agents', () => {
97
- it('returns agent list', async () => {
98
- const result = await harness.client.callTool({
99
- name: 'list_enterprise_agents',
100
- arguments: { enterpriseId: 'ent-1' },
101
- });
102
- assertSuccessResult(result as any);
103
- expect((result as any).content[0].text).toContain('1 agents');
104
- });
105
-
106
- it('returns error on failure', async () => {
107
- (harness.mockSdk.enterprises as any).listAgents.mockRejectedValueOnce(new Error('Unauthorized'));
108
- const result = await harness.client.callTool({
109
- name: 'list_enterprise_agents',
110
- arguments: { enterpriseId: 'bad' },
111
- });
112
- assertErrorResult(result as any);
113
- });
114
- });
115
-
116
- describe('create_enterprise', () => {
117
- it('creates an enterprise', async () => {
118
- const result = await harness.client.callTool({
119
- name: 'create_enterprise',
120
- arguments: { name: 'Acme Corp' },
121
- });
122
- assertSuccessResult(result as any);
123
- expect((result as any).content[0].text).toContain('Acme Corp');
124
- expect((result as any).content[0].text).toContain('created');
125
- });
126
-
127
- it('returns error on failure', async () => {
128
- (harness.mockSdk.admin as any).createEnterprise.mockRejectedValueOnce(new Error('Conflict'));
129
- const result = await harness.client.callTool({
130
- name: 'create_enterprise',
131
- arguments: { name: 'Duplicate' },
132
- });
133
- assertErrorResult(result as any);
134
- });
135
- });
136
-
137
- describe('create_agent', () => {
138
- it('creates an agent', async () => {
139
- const result = await harness.client.callTool({
140
- name: 'create_agent',
141
- arguments: { name: 'Data Processor', enterpriseId: 'ent-1' },
142
- });
143
- assertSuccessResult(result as any);
144
- expect((result as any).content[0].text).toContain('Data Processor');
145
- expect((result as any).content[0].text).toContain('created');
146
- });
147
-
148
- it('returns error on failure', async () => {
149
- (harness.mockSdk.admin as any).createAgent.mockRejectedValueOnce(new Error('Bad request'));
150
- const result = await harness.client.callTool({
151
- name: 'create_agent',
152
- arguments: { name: '' },
153
- });
154
- assertErrorResult(result as any);
155
- });
156
- });
157
-
158
- describe('set_enterprise_config', () => {
159
- it('replaces enterprise config', async () => {
160
- const result = await harness.client.callTool({
161
- name: 'set_enterprise_config',
162
- arguments: {
163
- enterpriseId: 'ent-1',
164
- config: { agentApprovalRequired: true, defaultScopes: ['mandates:read'] },
165
- },
166
- });
167
- assertSuccessResult(result as any);
168
- expect((result as any).content[0].text).toContain('replaced');
169
- expect((result as any).content[0].text).toContain('ent-1');
170
- });
171
-
172
- it('returns error on failure', async () => {
173
- (harness.mockSdk.admin as any).setEnterpriseConfig.mockRejectedValueOnce(new Error('Not found'));
174
- const result = await harness.client.callTool({
175
- name: 'set_enterprise_config',
176
- arguments: { enterpriseId: 'bad', config: {} },
177
- });
178
- assertErrorResult(result as any);
179
- });
180
- });
181
- });
@@ -1,61 +0,0 @@
1
- import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
2
- import { registerEventTools } from '../../src/tools/events.js';
3
- import { createTestHarness, type TestHarness } from '../harness.js';
4
- import { assertErrorResult, assertSuccessResult } from '../conformance.js';
5
-
6
- describe('event tools', () => {
7
- let harness: TestHarness;
8
-
9
- beforeAll(async () => {
10
- harness = await createTestHarness({
11
- registerFns: [registerEventTools],
12
- mockOverrides: {
13
- events: {
14
- getAuditChain: vi.fn().mockResolvedValue({
15
- mandateId: 'm-001',
16
- chainStart: '2026-04-01T00:00:00Z',
17
- entries: [
18
- { index: 0, hash: 'abc123', previousHash: null, event: 'CREATED', actor: 'agent-1', timestamp: '2026-04-01T00:00:00Z' },
19
- { index: 1, hash: 'def456', previousHash: 'abc123', event: 'ACTIVATED', actor: 'agent-1', timestamp: '2026-04-01T00:01:00Z' },
20
- ],
21
- isValid: true,
22
- }),
23
- },
24
- },
25
- });
26
- });
27
-
28
- afterAll(async () => {
29
- await harness.cleanup();
30
- });
31
-
32
- it('registers exactly 1 tool: get_audit_trail', async () => {
33
- const { tools } = await harness.client.listTools();
34
- expect(tools.map((t: any) => t.name)).toEqual(['get_audit_trail']);
35
- });
36
-
37
- describe('get_audit_trail', () => {
38
- it('returns audit trail on success', async () => {
39
- const result = await harness.client.callTool({
40
- name: 'get_audit_trail',
41
- arguments: { mandateId: 'm-001' },
42
- });
43
- assertSuccessResult(result as any);
44
- const text = (result as any).content[0].text;
45
- expect(text).toContain('m-001');
46
- expect(text).toContain('2 entries');
47
- expect(text).toContain('valid=true');
48
- expect((harness.mockSdk.events as any).getAuditChain).toHaveBeenCalledWith('m-001');
49
- });
50
-
51
- it('returns error on failure', async () => {
52
- (harness.mockSdk.events as any).getAuditChain.mockRejectedValueOnce(new Error('Mandate not found'));
53
- const result = await harness.client.callTool({
54
- name: 'get_audit_trail',
55
- arguments: { mandateId: 'm-missing' },
56
- });
57
- assertErrorResult(result as any);
58
- expect((result as any).content[0].text).toContain('Mandate not found');
59
- });
60
- });
61
- });