@agledger/mcp-server 1.2.0 → 1.2.1
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.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/index.js +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -2
- package/dist/server.js.map +1 -1
- package/dist/tool-scopes.d.ts.map +1 -1
- package/dist/tool-scopes.js +2 -0
- package/dist/tool-scopes.js.map +1 -1
- package/dist/tools/code-mode.d.ts.map +1 -1
- package/dist/tools/code-mode.js +4 -1
- package/dist/tools/code-mode.js.map +1 -1
- package/dist/tools/verification-keys.d.ts +5 -0
- package/dist/tools/verification-keys.d.ts.map +1 -0
- package/dist/tools/verification-keys.js +49 -0
- package/dist/tools/verification-keys.js.map +1 -0
- package/package.json +1 -6
- package/src/enums.ts +48 -0
- package/src/errors.ts +37 -0
- package/src/index.ts +102 -0
- package/src/resources/contract-types.ts +134 -0
- package/src/server.ts +134 -0
- package/src/tool-scopes.ts +193 -0
- package/src/tools/a2a.ts +551 -0
- package/src/tools/agent-mandates.ts +336 -0
- package/src/tools/agents-refs.ts +296 -0
- package/src/tools/capabilities.ts +80 -0
- package/src/tools/code-mode.ts +473 -0
- package/src/tools/compliance.ts +81 -0
- package/src/tools/dashboard.ts +75 -0
- package/src/tools/disputes.ts +160 -0
- package/src/tools/enterprises.ts +243 -0
- package/src/tools/events.ts +55 -0
- package/src/tools/federation-admin.ts +948 -0
- package/src/tools/federation.ts +806 -0
- package/src/tools/health.ts +46 -0
- package/src/tools/mandates.ts +394 -0
- package/src/tools/openclaw.ts +174 -0
- package/src/tools/receipts.ts +185 -0
- package/src/tools/reputation.ts +80 -0
- package/src/tools/schemas.ts +685 -0
- package/src/tools/verification-keys.ts +58 -0
- package/src/tools/verification.ts +89 -0
- package/tests/code-mode-manifest.test.ts +144 -0
- package/tests/enterprises.test.ts +96 -0
- package/tests/schemas.test.ts +531 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** AGLedger™ — Verification keys MCP tool. Patent Pending. Copyright 2026 AGLedger LLC. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import type { AgledgerClient } from '@agledger/sdk';
|
|
6
|
+
import { apiErrorResult } from '../errors.js';
|
|
7
|
+
import { toolMeta } from '../tool-scopes.js';
|
|
8
|
+
|
|
9
|
+
const VerificationKeySchema = z.object({
|
|
10
|
+
keyId: z.string().describe('Unique key identifier'),
|
|
11
|
+
algorithm: z.string().describe('Signing algorithm (e.g. Ed25519)'),
|
|
12
|
+
publicKey: z.string().describe('Base64-encoded public key'),
|
|
13
|
+
status: z.string().describe('Key status: active or retired'),
|
|
14
|
+
activatedAt: z.string().describe('Date the key was activated (YYYY-MM-DD)'),
|
|
15
|
+
retiredAt: z.string().nullable().describe('Date the key was retired, or null if active'),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const VerificationKeysOutputSchema = z.object({
|
|
19
|
+
data: z.array(VerificationKeySchema).describe('Vault signing public keys'),
|
|
20
|
+
canonicalization: z.string().describe('Canonicalization standard (e.g. RFC8785)'),
|
|
21
|
+
hashAlgorithm: z.string().describe('Hash algorithm used in audit chain'),
|
|
22
|
+
signatureAlgorithm: z.string().describe('Signature algorithm for audit entries'),
|
|
23
|
+
}).describe('Vault signing public keys for independent audit chain verification');
|
|
24
|
+
|
|
25
|
+
export function registerVerificationKeysTools(mcp: McpServer, client: AgledgerClient): void {
|
|
26
|
+
mcp.registerTool(
|
|
27
|
+
'list_verification_keys',
|
|
28
|
+
{
|
|
29
|
+
title: 'List Verification Keys',
|
|
30
|
+
description:
|
|
31
|
+
'List all vault signing public keys (active and retired) for independent audit chain verification. ' +
|
|
32
|
+
'No authentication required. Use these keys to verify Ed25519 signatures on audit chain exports. ' +
|
|
33
|
+
'Next step: fetch an audit export with `export_mandate_audit` and verify signatures locally.',
|
|
34
|
+
inputSchema: {},
|
|
35
|
+
outputSchema: VerificationKeysOutputSchema,
|
|
36
|
+
annotations: {
|
|
37
|
+
readOnlyHint: true,
|
|
38
|
+
destructiveHint: false,
|
|
39
|
+
idempotentHint: true,
|
|
40
|
+
openWorldHint: true,
|
|
41
|
+
},
|
|
42
|
+
_meta: toolMeta('list_verification_keys'),
|
|
43
|
+
},
|
|
44
|
+
async () => {
|
|
45
|
+
try {
|
|
46
|
+
const result = await client.verificationKeys.list();
|
|
47
|
+
const count = result.data.length;
|
|
48
|
+
const active = result.data.filter((k) => k.status === 'active').length;
|
|
49
|
+
return {
|
|
50
|
+
content: [{ type: 'text', text: `${count} verification key(s): ${active} active, ${count - active} retired. Algorithm: ${result.signatureAlgorithm}.` }],
|
|
51
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
52
|
+
};
|
|
53
|
+
} catch (err) {
|
|
54
|
+
return apiErrorResult(err);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** AGLedger™ — Verification MCP tools (verify mandate, get verification status). Patent Pending. Copyright 2026 AGLedger LLC. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
+
import type { AgledgerClient } from '@agledger/sdk';
|
|
6
|
+
import { apiErrorResult } from '../errors.js';
|
|
7
|
+
import { toolMeta } from '../tool-scopes.js';
|
|
8
|
+
|
|
9
|
+
const VerificationResultOutputSchema = z.object({
|
|
10
|
+
mandateId: z.string().describe('Mandate UUID that was verified'),
|
|
11
|
+
receipts: z.array(z.object({
|
|
12
|
+
receiptId: z.string().describe('Receipt UUID'),
|
|
13
|
+
phase1Result: z.record(z.string(), z.unknown()).optional().describe('Phase 1 (sync) verification result'),
|
|
14
|
+
phase2Result: z.record(z.string(), z.unknown()).optional().describe('Phase 2 (async) verification result'),
|
|
15
|
+
})).describe('Per-receipt verification results'),
|
|
16
|
+
overallStatus: z.string().describe('Overall verification outcome'),
|
|
17
|
+
}).passthrough().describe('Mandate verification result');
|
|
18
|
+
|
|
19
|
+
const VerificationStatusOutputSchema = z.object({
|
|
20
|
+
mandateId: z.string().describe('Mandate UUID'),
|
|
21
|
+
phase1Status: z.string().describe('Phase 1 (sync rules) verification status'),
|
|
22
|
+
phase2Status: z.string().describe('Phase 2 (async rules) verification status'),
|
|
23
|
+
lastVerifiedAt: z.string().nullable().optional().describe('ISO 8601 timestamp of last verification'),
|
|
24
|
+
pendingRules: z.array(z.string()).nullable().optional().describe('Rule IDs still pending verification'),
|
|
25
|
+
}).passthrough().describe('Current verification status for a mandate');
|
|
26
|
+
|
|
27
|
+
export function registerVerificationTools(mcp: McpServer, client: AgledgerClient): void {
|
|
28
|
+
// --- verify_mandate ---
|
|
29
|
+
mcp.registerTool(
|
|
30
|
+
'verify_mandate',
|
|
31
|
+
{
|
|
32
|
+
title: 'Verify Mandate',
|
|
33
|
+
description: 'Trigger verification of a mandate against its submitted receipts. Runs all sync and async verification rules.',
|
|
34
|
+
inputSchema: {
|
|
35
|
+
mandateId: z.string().describe('UUID of the mandate to verify'),
|
|
36
|
+
},
|
|
37
|
+
outputSchema: VerificationResultOutputSchema,
|
|
38
|
+
annotations: {
|
|
39
|
+
readOnlyHint: false,
|
|
40
|
+
destructiveHint: false,
|
|
41
|
+
idempotentHint: true,
|
|
42
|
+
openWorldHint: true,
|
|
43
|
+
},
|
|
44
|
+
_meta: toolMeta('verify_mandate'),
|
|
45
|
+
},
|
|
46
|
+
async (args) => {
|
|
47
|
+
try {
|
|
48
|
+
const result = await client.verification.verify(args.mandateId);
|
|
49
|
+
return {
|
|
50
|
+
content: [{ type: 'text', text: `Verification for mandate ${result.mandateId}: ${result.overallStatus}. ${result.receipts.length} receipt(s) evaluated.` }],
|
|
51
|
+
structuredContent: result as unknown as Record<string, unknown>,
|
|
52
|
+
};
|
|
53
|
+
} catch (err) {
|
|
54
|
+
return apiErrorResult(err);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
// --- get_verification_status ---
|
|
60
|
+
mcp.registerTool(
|
|
61
|
+
'get_verification_status',
|
|
62
|
+
{
|
|
63
|
+
title: 'Get Verification Status',
|
|
64
|
+
description: 'Get the current verification status for a mandate, including phase 1/2 progress and pending rules.',
|
|
65
|
+
inputSchema: {
|
|
66
|
+
mandateId: z.string().describe('UUID of the mandate to check verification status for'),
|
|
67
|
+
},
|
|
68
|
+
outputSchema: VerificationStatusOutputSchema,
|
|
69
|
+
annotations: {
|
|
70
|
+
readOnlyHint: true,
|
|
71
|
+
destructiveHint: false,
|
|
72
|
+
idempotentHint: true,
|
|
73
|
+
openWorldHint: true,
|
|
74
|
+
},
|
|
75
|
+
_meta: toolMeta('get_verification_status'),
|
|
76
|
+
},
|
|
77
|
+
async (args) => {
|
|
78
|
+
try {
|
|
79
|
+
const status = await client.verification.getStatus(args.mandateId);
|
|
80
|
+
return {
|
|
81
|
+
content: [{ type: 'text', text: `Verification status for ${status.mandateId}: phase1=${status.phase1Status}, phase2=${status.phase2Status}.` }],
|
|
82
|
+
structuredContent: status as unknown as Record<string, unknown>,
|
|
83
|
+
};
|
|
84
|
+
} catch (err) {
|
|
85
|
+
return apiErrorResult(err);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
);
|
|
89
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RESOURCE_MANIFEST drift test
|
|
3
|
+
*
|
|
4
|
+
* Verifies that the RESOURCE_MANIFEST in code-mode.ts stays in sync with the
|
|
5
|
+
* actual AgledgerClient resource properties. If a resource is added to or
|
|
6
|
+
* removed from the SDK client, this test will fail until the manifest is updated.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, it, expect } from 'vitest';
|
|
10
|
+
import { readFileSync } from 'node:fs';
|
|
11
|
+
import { resolve, dirname } from 'node:path';
|
|
12
|
+
import { fileURLToPath } from 'node:url';
|
|
13
|
+
|
|
14
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Extract resource names from the SDK client source
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
function getClientResourceNames(): string[] {
|
|
21
|
+
const clientPath = resolve(__dirname, '../../../agledger-sdk/src/client.ts');
|
|
22
|
+
const source = readFileSync(clientPath, 'utf8');
|
|
23
|
+
|
|
24
|
+
// Match "readonly <name>: <Type>Resource" property declarations
|
|
25
|
+
const pattern = /^\s+readonly\s+(\w+)\s*:\s+\w+Resource/gm;
|
|
26
|
+
const names: string[] = [];
|
|
27
|
+
let match: RegExpExecArray | null;
|
|
28
|
+
while ((match = pattern.exec(source)) !== null) {
|
|
29
|
+
names.push(match[1]);
|
|
30
|
+
}
|
|
31
|
+
return names.sort();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// Extract resource names from the RESOURCE_MANIFEST in code-mode.ts
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
function getManifestResourceNames(): string[] {
|
|
39
|
+
const codePath = resolve(__dirname, '../src/tools/code-mode.ts');
|
|
40
|
+
const source = readFileSync(codePath, 'utf8');
|
|
41
|
+
|
|
42
|
+
// The manifest is defined as: const RESOURCE_MANIFEST: Record<string, string> = { key: `...`, ... };
|
|
43
|
+
// Extract the keys by finding the block between the opening { and closing };
|
|
44
|
+
const startMarker = 'const RESOURCE_MANIFEST: Record<string, string> = {';
|
|
45
|
+
const startIdx = source.indexOf(startMarker);
|
|
46
|
+
if (startIdx === -1) {
|
|
47
|
+
throw new Error('Could not find RESOURCE_MANIFEST in code-mode.ts');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Find matching closing brace by counting depth
|
|
51
|
+
let depth = 0;
|
|
52
|
+
let inString = false;
|
|
53
|
+
let stringChar = '';
|
|
54
|
+
let endIdx = -1;
|
|
55
|
+
|
|
56
|
+
for (let i = startIdx + startMarker.length - 1; i < source.length; i++) {
|
|
57
|
+
const ch = source[i];
|
|
58
|
+
const prev = i > 0 ? source[i - 1] : '';
|
|
59
|
+
|
|
60
|
+
if (inString) {
|
|
61
|
+
if (ch === stringChar && prev !== '\\') {
|
|
62
|
+
inString = false;
|
|
63
|
+
}
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (ch === '`' || ch === '"' || ch === "'") {
|
|
68
|
+
inString = true;
|
|
69
|
+
stringChar = ch;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (ch === '{') depth++;
|
|
74
|
+
if (ch === '}') {
|
|
75
|
+
depth--;
|
|
76
|
+
if (depth === 0) {
|
|
77
|
+
endIdx = i;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (endIdx === -1) {
|
|
84
|
+
throw new Error('Could not parse RESOURCE_MANIFEST block');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const block = source.slice(startIdx + startMarker.length, endIdx);
|
|
88
|
+
|
|
89
|
+
// Extract top-level keys: lines matching " <key>: `" at the start
|
|
90
|
+
const keyPattern = /^\s+(\w+)\s*:\s*`/gm;
|
|
91
|
+
const names: string[] = [];
|
|
92
|
+
let m: RegExpExecArray | null;
|
|
93
|
+
while ((m = keyPattern.exec(block)) !== null) {
|
|
94
|
+
names.push(m[1]);
|
|
95
|
+
}
|
|
96
|
+
return names.sort();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ---------------------------------------------------------------------------
|
|
100
|
+
// Tests
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
|
|
103
|
+
describe('RESOURCE_MANIFEST ↔ SDK Client drift', () => {
|
|
104
|
+
const clientResources = getClientResourceNames();
|
|
105
|
+
const manifestResources = getManifestResourceNames();
|
|
106
|
+
|
|
107
|
+
it('SDK client has at least one resource', () => {
|
|
108
|
+
expect(clientResources.length).toBeGreaterThan(0);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('RESOURCE_MANIFEST has at least one resource', () => {
|
|
112
|
+
expect(manifestResources.length).toBeGreaterThan(0);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('every SDK resource is present in RESOURCE_MANIFEST', () => {
|
|
116
|
+
const missing = clientResources.filter((r) => !manifestResources.includes(r));
|
|
117
|
+
if (missing.length > 0) {
|
|
118
|
+
expect.fail(
|
|
119
|
+
`${missing.length} SDK resource(s) missing from RESOURCE_MANIFEST in code-mode.ts:\n` +
|
|
120
|
+
missing.map((r) => ` - ${r}`).join('\n') +
|
|
121
|
+
'\n\nFix: add entries to RESOURCE_MANIFEST for these resources.',
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('every RESOURCE_MANIFEST entry corresponds to an SDK resource', () => {
|
|
127
|
+
const extra = manifestResources.filter((r) => !clientResources.includes(r));
|
|
128
|
+
if (extra.length > 0) {
|
|
129
|
+
expect.fail(
|
|
130
|
+
`${extra.length} RESOURCE_MANIFEST entry/entries have no corresponding SDK resource:\n` +
|
|
131
|
+
extra.map((r) => ` - ${r}`).join('\n') +
|
|
132
|
+
'\n\nFix: remove stale entries from RESOURCE_MANIFEST, or add missing resources to the SDK client.',
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('resource counts match exactly', () => {
|
|
138
|
+
expect(manifestResources.length).toBe(clientResources.length);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('resource names match exactly (sorted)', () => {
|
|
142
|
+
expect(manifestResources).toEqual(clientResources);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { registerEnterpriseTools } from '../src/tools/enterprises.js';
|
|
4
|
+
|
|
5
|
+
/** Create a mock AgledgerClient with a mocked enterprises resource. */
|
|
6
|
+
function createMockClient() {
|
|
7
|
+
return {
|
|
8
|
+
enterprises: {
|
|
9
|
+
approveAgent: vi.fn().mockResolvedValue({
|
|
10
|
+
enterpriseId: 'ent-1', agentId: 'agent-1', status: 'approved',
|
|
11
|
+
approvedBy: 'key-1', approvedAt: '2026-01-01T00:00:00Z',
|
|
12
|
+
suspendedAt: null, revokedAt: null, reason: 'Test',
|
|
13
|
+
}),
|
|
14
|
+
revokeAgent: vi.fn().mockResolvedValue(undefined),
|
|
15
|
+
listAgents: vi.fn().mockResolvedValue({ data: [], hasMore: false }),
|
|
16
|
+
},
|
|
17
|
+
} as any;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe('registerEnterpriseTools', () => {
|
|
21
|
+
it('registers 5 tools on the MCP server', () => {
|
|
22
|
+
const mcp = new McpServer({ name: 'test', version: '0.0.0' }, { capabilities: { tools: {} } });
|
|
23
|
+
const client = createMockClient();
|
|
24
|
+
registerEnterpriseTools(mcp, client);
|
|
25
|
+
|
|
26
|
+
// McpServer doesn't expose a tool listing API directly, but we can verify
|
|
27
|
+
// registration doesn't throw and the function completes
|
|
28
|
+
expect(true).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('enterprise tool handlers', () => {
|
|
33
|
+
// To test handlers, we register tools then invoke them through the McpServer.
|
|
34
|
+
// Since McpServer's internal tool registry isn't directly callable,
|
|
35
|
+
// we test the SDK calls indirectly by calling registerEnterpriseTools
|
|
36
|
+
// and verifying the mock client methods get called with correct args.
|
|
37
|
+
|
|
38
|
+
let mcp: McpServer;
|
|
39
|
+
let client: ReturnType<typeof createMockClient>;
|
|
40
|
+
let handlers: Map<string, (args: any) => Promise<any>>;
|
|
41
|
+
|
|
42
|
+
function setup() {
|
|
43
|
+
mcp = new McpServer({ name: 'test', version: '0.0.0' }, { capabilities: { tools: {} } });
|
|
44
|
+
client = createMockClient();
|
|
45
|
+
handlers = new Map();
|
|
46
|
+
|
|
47
|
+
// Intercept registerTool to capture handlers
|
|
48
|
+
const origRegister = mcp.registerTool.bind(mcp);
|
|
49
|
+
vi.spyOn(mcp, 'registerTool').mockImplementation((name: string, config: any, handler: any) => {
|
|
50
|
+
handlers.set(name, handler);
|
|
51
|
+
return origRegister(name, config, handler);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
registerEnterpriseTools(mcp, client);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
it('approve_enterprise_agent calls client.enterprises.approveAgent', async () => {
|
|
58
|
+
setup();
|
|
59
|
+
const handler = handlers.get('approve_enterprise_agent')!;
|
|
60
|
+
const result = await handler({ enterpriseId: 'ent-1', agentId: 'agent-1', reason: 'Trusted' });
|
|
61
|
+
|
|
62
|
+
expect(client.enterprises.approveAgent).toHaveBeenCalledWith('ent-1', 'agent-1', { reason: 'Trusted' });
|
|
63
|
+
expect(result.content[0].text).toContain('approved');
|
|
64
|
+
expect(result.isError).toBeUndefined();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('revoke_enterprise_agent calls client.enterprises.revokeAgent', async () => {
|
|
68
|
+
setup();
|
|
69
|
+
const handler = handlers.get('revoke_enterprise_agent')!;
|
|
70
|
+
const result = await handler({ enterpriseId: 'ent-1', agentId: 'agent-1', reason: 'Policy' });
|
|
71
|
+
|
|
72
|
+
expect(client.enterprises.revokeAgent).toHaveBeenCalledWith('ent-1', 'agent-1', { reason: 'Policy' });
|
|
73
|
+
expect(result.content[0].text).toContain('revoked');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('list_enterprise_agents calls client.enterprises.listAgents', async () => {
|
|
77
|
+
setup();
|
|
78
|
+
const handler = handlers.get('list_enterprise_agents')!;
|
|
79
|
+
const result = await handler({ enterpriseId: 'ent-1', status: 'approved' });
|
|
80
|
+
|
|
81
|
+
expect(client.enterprises.listAgents).toHaveBeenCalledWith('ent-1', {
|
|
82
|
+
status: 'approved', limit: undefined, offset: undefined,
|
|
83
|
+
});
|
|
84
|
+
expect(result.content[0].text).toContain('Found');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('returns error result on API failure', async () => {
|
|
88
|
+
setup();
|
|
89
|
+
client.enterprises.approveAgent.mockRejectedValueOnce(new Error('API unreachable'));
|
|
90
|
+
const handler = handlers.get('approve_enterprise_agent')!;
|
|
91
|
+
const result = await handler({ enterpriseId: 'ent-1', agentId: 'agent-1' });
|
|
92
|
+
|
|
93
|
+
expect(result.isError).toBe(true);
|
|
94
|
+
expect(result.content[0].text).toContain('API unreachable');
|
|
95
|
+
});
|
|
96
|
+
});
|