@agledger/mcp-server 2.2.0 → 2.3.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/CHANGELOG.md +28 -0
- package/README.md +8 -8
- package/dist/index.js +1 -1
- package/dist/server.js +13 -13
- package/dist/server.js.map +1 -1
- package/dist/verify/verify-export.d.ts +5 -5
- package/dist/verify/verify-export.d.ts.map +1 -1
- package/dist/verify/verify-export.js +2 -2
- package/dist/verify/verify-export.js.map +1 -1
- package/package.json +2 -1
- package/src/index.ts +1 -1
- package/src/server.ts +16 -16
- package/src/verify/verify-export.ts +8 -8
- package/tests/api-client.test.ts +4 -4
- package/tests/integration.test.ts +54 -54
- package/tests/server.test.ts +28 -28
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the AGLedger MCP Server will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [2.3.0] - 2026-04-27
|
|
8
|
+
|
|
9
|
+
Tracks AGLedger API v0.21.5. Every `/v1/mandates/*` route is now `/v1/records/*`; `Contract Type` is `Type`. The MCP server is a thin pass-through, so this release sweeps tool descriptions, the quickstart returned by `agledger_discover`, and the offline verifier's field names.
|
|
10
|
+
|
|
11
|
+
### Changed (BREAKING)
|
|
12
|
+
|
|
13
|
+
- **Offline verifier output field rename.** `verify-export.ts` exports `RecordAuditExport` (was `MandateAuditExport`). Metadata fields: `mandateId` → `recordId`, `contractType` → `type`. `VerifyExportResult.mandateId` → `recordId`. Crypto primitives (RFC 8785 JCS, SHA-256, Ed25519) and the signature input `{position}:{payloadHash}:{previousHash}` are unchanged.
|
|
14
|
+
- **`agledger_verify` tool description** points at `/v1/records/{id}/audit-export`. The `INVALID_EXPORT` error suggestion was updated similarly.
|
|
15
|
+
|
|
16
|
+
### Changed (tool description / quickstart sweep)
|
|
17
|
+
|
|
18
|
+
- **`agledger_discover` quickstart** now reads:
|
|
19
|
+
1. `GET /v1/schemas` — list Record types.
|
|
20
|
+
2. `GET /v1/schemas/{type}` — get required fields and examples.
|
|
21
|
+
3. `POST /v1/records` — create a record.
|
|
22
|
+
4. `POST /v1/records/{id}/receipts` — submit evidence when done.
|
|
23
|
+
- **`agledger_api` tool description** uses the new vocabulary throughout (workflow steps, path examples, `PATH_INVALID` error message and suggestion).
|
|
24
|
+
- **README** Tools table, Agent workflow section, and "What is AGLedger?" bullet list use Record / Type vocabulary.
|
|
25
|
+
|
|
26
|
+
### Build
|
|
27
|
+
|
|
28
|
+
- `prebuild` now wipes `dist/` so stale outputs from prior builds cannot leak into the next one.
|
package/README.md
CHANGED
|
@@ -7,8 +7,8 @@ Connects any MCP-compatible AI agent (Claude, Cursor, Windsurf, etc.) to the AGL
|
|
|
7
7
|
**Learn more**
|
|
8
8
|
|
|
9
9
|
- [agledger.ai](https://agledger.ai) — what AGLedger is and why Layer 3 accountability matters
|
|
10
|
-
- [How it works](https://agledger.ai/how-it-works) — the four-endpoint lifecycle:
|
|
11
|
-
- [Glossary](https://agledger.ai/glossary) — canonical definitions of
|
|
10
|
+
- [How it works](https://agledger.ai/how-it-works) — the four-endpoint lifecycle: record, receipt, verdict, fulfill
|
|
11
|
+
- [Glossary](https://agledger.ai/glossary) — canonical definitions of Record, Receipt, Verdict, Settlement Signal
|
|
12
12
|
- [MCP Server guide](https://agledger.ai/docs/guides/mcp-server) — installation and agent workflow
|
|
13
13
|
- [Protocol (AOAP)](https://agledger.ai/protocol) — the coordination language behind AGLedger
|
|
14
14
|
|
|
@@ -45,16 +45,16 @@ agledger-mcp --api-key <key> [--api-url <url>]
|
|
|
45
45
|
|------|-------------|
|
|
46
46
|
| `agledger_discover` | Returns API health, your identity, available scopes, and a quickstart workflow. Call this first. |
|
|
47
47
|
| `agledger_api` | Make any AGLedger API call (method, path, params). The API returns `nextSteps` on every response for self-guided workflow discovery. |
|
|
48
|
-
| `agledger_verify` | Verify a
|
|
48
|
+
| `agledger_verify` | Verify a record audit export offline (RFC 8785 hash chain + Ed25519 signatures). No network calls. Returns `valid`, `verifiedEntries`, and a `brokenAt` pointer on failure. |
|
|
49
49
|
|
|
50
50
|
### Agent workflow
|
|
51
51
|
|
|
52
52
|
The `agledger_discover` tool returns a quickstart workflow that guides agents through the accountability flow:
|
|
53
53
|
|
|
54
|
-
1. `GET /v1/schemas` -- list available
|
|
54
|
+
1. `GET /v1/schemas` -- list available Record types
|
|
55
55
|
2. `GET /v1/schemas/{type}` -- get required fields and examples
|
|
56
|
-
3. `POST /v1/
|
|
57
|
-
4. `POST /v1/
|
|
56
|
+
3. `POST /v1/records` -- create a record
|
|
57
|
+
4. `POST /v1/records/{id}/receipts` -- submit evidence when done
|
|
58
58
|
|
|
59
59
|
Every API error response includes a `suggestion` field with actionable recovery guidance -- agents can self-correct without human intervention.
|
|
60
60
|
|
|
@@ -69,10 +69,10 @@ Every API error response includes a `suggestion` field with actionable recovery
|
|
|
69
69
|
|
|
70
70
|
AGLedger is the accountability layer for automated operations. It records what was agreed to, by whom, when -- and tracks the delegation of that agreement through other systems.
|
|
71
71
|
|
|
72
|
-
- **
|
|
72
|
+
- **Records** -- structured commitments with acceptance criteria and tolerance bands
|
|
73
73
|
- **Receipts** -- task attestations recording what was reported to be done
|
|
74
74
|
- **Verdicts** -- principal acceptance decisions (PASS/FAIL) with settlement signals
|
|
75
|
-
- **Audit trail** -- hash-chained, Ed25519-signed, tamper-evident
|
|
75
|
+
- **Audit trail** -- hash-chained, Ed25519-signed, tamper-evident chain
|
|
76
76
|
|
|
77
77
|
Learn more at [agledger.ai](https://www.agledger.ai) | [API docs](https://www.agledger.ai/docs/)
|
|
78
78
|
|
package/dist/index.js
CHANGED
package/dist/server.js
CHANGED
|
@@ -5,10 +5,10 @@ import { ApiClient } from './api-client.js';
|
|
|
5
5
|
const QUICKSTART = {
|
|
6
6
|
description: 'To track accountability for your work, follow these steps in order:',
|
|
7
7
|
steps: [
|
|
8
|
-
{ step: 1, action: 'List available
|
|
9
|
-
{ step: 2, action: 'Get schema for your
|
|
10
|
-
{ step: 3, action: 'Create a
|
|
11
|
-
{ step: 4, action: 'Do your work, then submit a receipt', method: 'POST', path: '/v1/
|
|
8
|
+
{ step: 1, action: 'List available Record types', method: 'GET', path: '/v1/schemas' },
|
|
9
|
+
{ step: 2, action: 'Get schema for your Record type', method: 'GET', path: '/v1/schemas/{type}' },
|
|
10
|
+
{ step: 3, action: 'Create a record', method: 'POST', path: '/v1/records' },
|
|
11
|
+
{ step: 4, action: 'Do your work, then submit a receipt', method: 'POST', path: '/v1/records/{id}/receipts' },
|
|
12
12
|
],
|
|
13
13
|
};
|
|
14
14
|
const DOCS = {
|
|
@@ -40,7 +40,7 @@ export class AgledgerMcpServer {
|
|
|
40
40
|
constructor(options) {
|
|
41
41
|
const apiUrl = options.apiUrl ?? 'https://agledger.example.com';
|
|
42
42
|
this.client = new ApiClient(apiUrl, options.apiKey, options.timeoutMs);
|
|
43
|
-
this.mcp = new McpServer({ name: 'agledger-mcp-server', version: '2.
|
|
43
|
+
this.mcp = new McpServer({ name: 'agledger-mcp-server', version: '2.3.0' }, { capabilities: { tools: {}, resources: {} } });
|
|
44
44
|
this.registerTools();
|
|
45
45
|
this.registerResources();
|
|
46
46
|
}
|
|
@@ -98,10 +98,10 @@ export class AgledgerMcpServer {
|
|
|
98
98
|
title: 'AGLedger API',
|
|
99
99
|
description: 'Make any AGLedger API call. All paths start with /v1/. ' +
|
|
100
100
|
'The API returns nextSteps on every response — follow them. Workflow: ' +
|
|
101
|
-
'1. GET /v1/schemas — list
|
|
101
|
+
'1. GET /v1/schemas — list Record types. ' +
|
|
102
102
|
'2. GET /v1/schemas/{type} — get required fields and examples. ' +
|
|
103
|
-
'3. POST /v1/
|
|
104
|
-
'4. POST /v1/
|
|
103
|
+
'3. POST /v1/records — create a record. ' +
|
|
104
|
+
'4. POST /v1/records/{id}/receipts — submit evidence when done. ' +
|
|
105
105
|
'If a call fails, read the suggestion field in the error response. ' +
|
|
106
106
|
'For the full API catalog, GET /openapi.json (or read the agledger://openapi resource). ' +
|
|
107
107
|
'For GET/DELETE, params become query parameters. For POST/PUT/PATCH, params become the JSON body.',
|
|
@@ -109,7 +109,7 @@ export class AgledgerMcpServer {
|
|
|
109
109
|
method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']).describe('HTTP method'),
|
|
110
110
|
path: z
|
|
111
111
|
.string()
|
|
112
|
-
.describe('API path starting with / (e.g. /v1/
|
|
112
|
+
.describe('API path starting with / (e.g. /v1/records, /v1/schemas, /v1/records/{id}/receipts)'),
|
|
113
113
|
params: z
|
|
114
114
|
.record(z.string(), z.unknown())
|
|
115
115
|
.optional()
|
|
@@ -126,7 +126,7 @@ export class AgledgerMcpServer {
|
|
|
126
126
|
const { method, path, params } = args;
|
|
127
127
|
if (!path.startsWith('/')) {
|
|
128
128
|
return errorResult('Path must start with /. All API routes use /v1/ prefix. ' +
|
|
129
|
-
'Example: /v1/
|
|
129
|
+
'Example: /v1/records, /v1/schemas. Call agledger_discover for the full workflow.', 'PATH_INVALID', 'Prefix the path with /v1/ (e.g. /v1/records). Call agledger_discover if unsure which path to use.');
|
|
130
130
|
}
|
|
131
131
|
const options = {};
|
|
132
132
|
if (params) {
|
|
@@ -174,11 +174,11 @@ export class AgledgerMcpServer {
|
|
|
174
174
|
'the publicKeys override). On failure, brokenAt pinpoints the first entry that failed ' +
|
|
175
175
|
'and why (payload_hash_mismatch, chain_break, signature_invalid, unknown_key, ' +
|
|
176
176
|
'position_gap, malformed_entry, unsupported_algorithm). ' +
|
|
177
|
-
'Obtain the export via agledger_api with method=GET, path=/v1/
|
|
177
|
+
'Obtain the export via agledger_api with method=GET, path=/v1/records/{id}/audit-export.',
|
|
178
178
|
inputSchema: {
|
|
179
179
|
export: z
|
|
180
180
|
.record(z.string(), z.unknown())
|
|
181
|
-
.describe('The parsed audit export JSON (the response body from GET /v1/
|
|
181
|
+
.describe('The parsed audit export JSON (the response body from GET /v1/records/{id}/audit-export).'),
|
|
182
182
|
publicKeys: z
|
|
183
183
|
.record(z.string(), z.string())
|
|
184
184
|
.optional()
|
|
@@ -200,7 +200,7 @@ export class AgledgerMcpServer {
|
|
|
200
200
|
try {
|
|
201
201
|
const { export: exportData, publicKeys, requireKeyId } = args;
|
|
202
202
|
if (!exportData || typeof exportData !== 'object' || !('entries' in exportData)) {
|
|
203
|
-
return errorResult('Input is not a valid audit export. Expected an object with exportMetadata and entries.', 'INVALID_EXPORT', 'Call agledger_api with method=GET and path=/v1/
|
|
203
|
+
return errorResult('Input is not a valid audit export. Expected an object with exportMetadata and entries.', 'INVALID_EXPORT', 'Call agledger_api with method=GET and path=/v1/records/{id}/audit-export, then pass the response body as the `export` argument.');
|
|
204
204
|
}
|
|
205
205
|
const result = verifyExport(exportData, {
|
|
206
206
|
publicKeys,
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,YAAY,EAA0B,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,UAAU,GAAG;IACjB,WAAW,EAAE,qEAAqE;IAClF,KAAK,EAAE;QACL,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,6BAA6B,EAAE,M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AG,EAAE,CAAC;gBACb,OAAO,WAAW,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,eAAe,CAAC,CAAC;YACxF,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;IAEO,iBAAiB;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAE3B;;;;;WAKG;QACH,IAAI,CAAC,GAAG,CAAC,gBAAgB,CACvB,kBAAkB,EAClB,oBAAoB,EACpB;YACE,WAAW,EACT,iIAAiI;YACnI,QAAQ,EAAE,kBAAkB;SAC7B,EACD,KAAK,IAAI,EAAE;YACT,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;YAC9D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,uCAAuC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YAC5E,CAAC;YACD,OAAO;gBACL,QAAQ,EAAE;oBACR;wBACE,GAAG,EAAE,oBAAoB;wBACzB,QAAQ,EAAE,kBAAkB;wBAC5B,IAAI,EAAE,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC;qBACxF;iBACF;aACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -27,11 +27,11 @@ export interface AuditExportEntry {
|
|
|
27
27
|
valid: boolean;
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
export interface
|
|
30
|
+
export interface RecordAuditExport {
|
|
31
31
|
exportMetadata: {
|
|
32
|
-
|
|
32
|
+
recordId: string;
|
|
33
33
|
enterpriseId: string | null;
|
|
34
|
-
|
|
34
|
+
type: string;
|
|
35
35
|
exportDate: string;
|
|
36
36
|
totalEntries: number;
|
|
37
37
|
chainIntegrity: boolean;
|
|
@@ -59,12 +59,12 @@ export interface VerifyExportResult {
|
|
|
59
59
|
detail?: string;
|
|
60
60
|
};
|
|
61
61
|
entries: EntryVerificationResult[];
|
|
62
|
-
|
|
62
|
+
recordId: string;
|
|
63
63
|
}
|
|
64
64
|
export interface VerifyExportOptions {
|
|
65
65
|
publicKeys?: Record<string, string>;
|
|
66
66
|
requireKeyId?: string;
|
|
67
67
|
}
|
|
68
|
-
export declare function verifyExport(exportData:
|
|
68
|
+
export declare function verifyExport(exportData: RecordAuditExport, options?: VerifyExportOptions): VerifyExportResult;
|
|
69
69
|
export declare function canonicalize(value: unknown): string;
|
|
70
70
|
//# sourceMappingURL=verify-export.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-export.d.ts","sourceRoot":"","sources":["../../src/verify/verify-export.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,EAAE;QACT,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"verify-export.d.ts","sourceRoot":"","sources":["../../src/verify/verify-export.ts"],"names":[],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b,cAAc,GACd,mBAAmB,GACnB,aAAa,GACb,iBAAiB,GACjB,uBAAuB,CAAC;AAE5B,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,kBAAkB,CAAC;QAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,OAAO,EAAE,uBAAuB,EAAE,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAMD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,iBAAiB,EAC7B,OAAO,GAAE,mBAAwB,GAChC,kBAAkB,CA+CpB;AAoID,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAkBnD"}
|
|
@@ -23,7 +23,7 @@ export function verifyExport(exportData, options = {}) {
|
|
|
23
23
|
verifiedEntries: 0,
|
|
24
24
|
brokenAt: { position: 0, reason: 'unsupported_algorithm', detail },
|
|
25
25
|
entries: [result],
|
|
26
|
-
|
|
26
|
+
recordId: meta.recordId,
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
let prevPayloadHash = null;
|
|
@@ -45,7 +45,7 @@ export function verifyExport(exportData, options = {}) {
|
|
|
45
45
|
verifiedEntries,
|
|
46
46
|
brokenAt,
|
|
47
47
|
entries: entryResults,
|
|
48
|
-
|
|
48
|
+
recordId: meta.recordId,
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
function resolveKeys(exportData, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-export.js","sourceRoot":"","sources":["../../src/verify/verify-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AC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YACzE,GAAG,CACJ,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,aAAa,CAAC,SAAoB,EAAE,OAAe,EAAE,YAAoB;IAChF,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/F,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agledger/mcp-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "AGLedger MCP Server — Thin API pass-through for AI agents via MCP protocol",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "AGLedger LLC",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
|
+
"prebuild": "rm -rf dist",
|
|
36
37
|
"build": "tsc",
|
|
37
38
|
"typecheck": "tsc --noEmit",
|
|
38
39
|
"clean": "rm -rf dist *.tsbuildinfo",
|
package/src/index.ts
CHANGED
package/src/server.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
-
import { verifyExport, type
|
|
4
|
+
import { verifyExport, type RecordAuditExport } from './verify/verify-export.js';
|
|
5
5
|
import { ApiClient } from './api-client.js';
|
|
6
6
|
|
|
7
7
|
export interface AgledgerMcpServerOptions {
|
|
@@ -14,10 +14,10 @@ export interface AgledgerMcpServerOptions {
|
|
|
14
14
|
const QUICKSTART = {
|
|
15
15
|
description: 'To track accountability for your work, follow these steps in order:',
|
|
16
16
|
steps: [
|
|
17
|
-
{ step: 1, action: 'List available
|
|
18
|
-
{ step: 2, action: 'Get schema for your
|
|
19
|
-
{ step: 3, action: 'Create a
|
|
20
|
-
{ step: 4, action: 'Do your work, then submit a receipt', method: 'POST', path: '/v1/
|
|
17
|
+
{ step: 1, action: 'List available Record types', method: 'GET', path: '/v1/schemas' },
|
|
18
|
+
{ step: 2, action: 'Get schema for your Record type', method: 'GET', path: '/v1/schemas/{type}' },
|
|
19
|
+
{ step: 3, action: 'Create a record', method: 'POST', path: '/v1/records' },
|
|
20
|
+
{ step: 4, action: 'Do your work, then submit a receipt', method: 'POST', path: '/v1/records/{id}/receipts' },
|
|
21
21
|
],
|
|
22
22
|
} as const;
|
|
23
23
|
|
|
@@ -55,7 +55,7 @@ export class AgledgerMcpServer {
|
|
|
55
55
|
this.client = new ApiClient(apiUrl, options.apiKey, options.timeoutMs);
|
|
56
56
|
|
|
57
57
|
this.mcp = new McpServer(
|
|
58
|
-
{ name: 'agledger-mcp-server', version: '2.
|
|
58
|
+
{ name: 'agledger-mcp-server', version: '2.3.0' },
|
|
59
59
|
{ capabilities: { tools: {}, resources: {} } },
|
|
60
60
|
);
|
|
61
61
|
|
|
@@ -131,10 +131,10 @@ export class AgledgerMcpServer {
|
|
|
131
131
|
description:
|
|
132
132
|
'Make any AGLedger API call. All paths start with /v1/. ' +
|
|
133
133
|
'The API returns nextSteps on every response — follow them. Workflow: ' +
|
|
134
|
-
'1. GET /v1/schemas — list
|
|
134
|
+
'1. GET /v1/schemas — list Record types. ' +
|
|
135
135
|
'2. GET /v1/schemas/{type} — get required fields and examples. ' +
|
|
136
|
-
'3. POST /v1/
|
|
137
|
-
'4. POST /v1/
|
|
136
|
+
'3. POST /v1/records — create a record. ' +
|
|
137
|
+
'4. POST /v1/records/{id}/receipts — submit evidence when done. ' +
|
|
138
138
|
'If a call fails, read the suggestion field in the error response. ' +
|
|
139
139
|
'For the full API catalog, GET /openapi.json (or read the agledger://openapi resource). ' +
|
|
140
140
|
'For GET/DELETE, params become query parameters. For POST/PUT/PATCH, params become the JSON body.',
|
|
@@ -142,7 +142,7 @@ export class AgledgerMcpServer {
|
|
|
142
142
|
method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']).describe('HTTP method'),
|
|
143
143
|
path: z
|
|
144
144
|
.string()
|
|
145
|
-
.describe('API path starting with / (e.g. /v1/
|
|
145
|
+
.describe('API path starting with / (e.g. /v1/records, /v1/schemas, /v1/records/{id}/receipts)'),
|
|
146
146
|
params: z
|
|
147
147
|
.record(z.string(), z.unknown())
|
|
148
148
|
.optional()
|
|
@@ -164,9 +164,9 @@ export class AgledgerMcpServer {
|
|
|
164
164
|
if (!path.startsWith('/')) {
|
|
165
165
|
return errorResult(
|
|
166
166
|
'Path must start with /. All API routes use /v1/ prefix. ' +
|
|
167
|
-
'Example: /v1/
|
|
167
|
+
'Example: /v1/records, /v1/schemas. Call agledger_discover for the full workflow.',
|
|
168
168
|
'PATH_INVALID',
|
|
169
|
-
'Prefix the path with /v1/ (e.g. /v1/
|
|
169
|
+
'Prefix the path with /v1/ (e.g. /v1/records). Call agledger_discover if unsure which path to use.',
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
172
|
|
|
@@ -232,12 +232,12 @@ export class AgledgerMcpServer {
|
|
|
232
232
|
'the publicKeys override). On failure, brokenAt pinpoints the first entry that failed ' +
|
|
233
233
|
'and why (payload_hash_mismatch, chain_break, signature_invalid, unknown_key, ' +
|
|
234
234
|
'position_gap, malformed_entry, unsupported_algorithm). ' +
|
|
235
|
-
'Obtain the export via agledger_api with method=GET, path=/v1/
|
|
235
|
+
'Obtain the export via agledger_api with method=GET, path=/v1/records/{id}/audit-export.',
|
|
236
236
|
inputSchema: {
|
|
237
237
|
export: z
|
|
238
238
|
.record(z.string(), z.unknown())
|
|
239
239
|
.describe(
|
|
240
|
-
'The parsed audit export JSON (the response body from GET /v1/
|
|
240
|
+
'The parsed audit export JSON (the response body from GET /v1/records/{id}/audit-export).',
|
|
241
241
|
),
|
|
242
242
|
publicKeys: z
|
|
243
243
|
.record(z.string(), z.string())
|
|
@@ -268,11 +268,11 @@ export class AgledgerMcpServer {
|
|
|
268
268
|
return errorResult(
|
|
269
269
|
'Input is not a valid audit export. Expected an object with exportMetadata and entries.',
|
|
270
270
|
'INVALID_EXPORT',
|
|
271
|
-
'Call agledger_api with method=GET and path=/v1/
|
|
271
|
+
'Call agledger_api with method=GET and path=/v1/records/{id}/audit-export, then pass the response body as the `export` argument.',
|
|
272
272
|
);
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
const result = verifyExport(exportData as unknown as
|
|
275
|
+
const result = verifyExport(exportData as unknown as RecordAuditExport, {
|
|
276
276
|
publicKeys,
|
|
277
277
|
requireKeyId,
|
|
278
278
|
});
|
|
@@ -31,11 +31,11 @@ export interface AuditExportEntry {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export interface
|
|
34
|
+
export interface RecordAuditExport {
|
|
35
35
|
exportMetadata: {
|
|
36
|
-
|
|
36
|
+
recordId: string;
|
|
37
37
|
enterpriseId: string | null;
|
|
38
|
-
|
|
38
|
+
type: string;
|
|
39
39
|
exportDate: string;
|
|
40
40
|
totalEntries: number;
|
|
41
41
|
chainIntegrity: boolean;
|
|
@@ -73,7 +73,7 @@ export interface VerifyExportResult {
|
|
|
73
73
|
detail?: string;
|
|
74
74
|
};
|
|
75
75
|
entries: EntryVerificationResult[];
|
|
76
|
-
|
|
76
|
+
recordId: string;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
export interface VerifyExportOptions {
|
|
@@ -86,7 +86,7 @@ const SUPPORTED_HASH = new Set(['SHA-256', 'sha-256', 'sha256']);
|
|
|
86
86
|
const SUPPORTED_SIG = new Set(['Ed25519', 'ed25519']);
|
|
87
87
|
|
|
88
88
|
export function verifyExport(
|
|
89
|
-
exportData:
|
|
89
|
+
exportData: RecordAuditExport,
|
|
90
90
|
options: VerifyExportOptions = {},
|
|
91
91
|
): VerifyExportResult {
|
|
92
92
|
const meta = exportData.exportMetadata;
|
|
@@ -110,7 +110,7 @@ export function verifyExport(
|
|
|
110
110
|
verifiedEntries: 0,
|
|
111
111
|
brokenAt: { position: 0, reason: 'unsupported_algorithm', detail },
|
|
112
112
|
entries: [result],
|
|
113
|
-
|
|
113
|
+
recordId: meta.recordId,
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -133,12 +133,12 @@ export function verifyExport(
|
|
|
133
133
|
verifiedEntries,
|
|
134
134
|
brokenAt,
|
|
135
135
|
entries: entryResults,
|
|
136
|
-
|
|
136
|
+
recordId: meta.recordId,
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
function resolveKeys(
|
|
141
|
-
exportData:
|
|
141
|
+
exportData: RecordAuditExport,
|
|
142
142
|
options: VerifyExportOptions,
|
|
143
143
|
): Record<string, string> {
|
|
144
144
|
const meta = exportData.exportMetadata;
|
package/tests/api-client.test.ts
CHANGED
|
@@ -66,12 +66,12 @@ describe('ApiClient', () => {
|
|
|
66
66
|
vi.stubGlobal('fetch', mockFetch);
|
|
67
67
|
|
|
68
68
|
const client = new ApiClient('https://api.test.com', 'key');
|
|
69
|
-
await client.request('POST', '/
|
|
69
|
+
await client.request('POST', '/records', { body: { type: 'ACH-PROC-v1' } });
|
|
70
70
|
|
|
71
71
|
const [, options] = mockFetch.mock.calls[0] as [string, RequestInit];
|
|
72
72
|
const headers = options.headers as Record<string, string>;
|
|
73
73
|
expect(headers['Content-Type']).toBe('application/json');
|
|
74
|
-
expect(JSON.parse(options.body as string)).toEqual({
|
|
74
|
+
expect(JSON.parse(options.body as string)).toEqual({ type: 'ACH-PROC-v1' });
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
it('handles non-JSON responses', async () => {
|
|
@@ -121,7 +121,7 @@ describe('ApiClient', () => {
|
|
|
121
121
|
);
|
|
122
122
|
|
|
123
123
|
const client = new ApiClient('https://api.test.com', 'key');
|
|
124
|
-
const result = await client.request('POST', '/
|
|
124
|
+
const result = await client.request('POST', '/records', { body: {} });
|
|
125
125
|
|
|
126
126
|
expect(result.ok).toBe(true);
|
|
127
127
|
expect(result.status).toBe(201);
|
|
@@ -139,7 +139,7 @@ describe('ApiClient', () => {
|
|
|
139
139
|
);
|
|
140
140
|
|
|
141
141
|
const client = new ApiClient('https://api.test.com', 'key');
|
|
142
|
-
const result = await client.request('GET', '/
|
|
142
|
+
const result = await client.request('GET', '/records/bad');
|
|
143
143
|
|
|
144
144
|
expect(result.ok).toBe(false);
|
|
145
145
|
expect(result.status).toBe(404);
|
|
@@ -5,7 +5,7 @@ import { AgledgerMcpServer } from '../src/server.js';
|
|
|
5
5
|
|
|
6
6
|
const API_URL = process.env.AGLEDGER_API_URL ?? 'http://localhost:3001';
|
|
7
7
|
const API_KEY =
|
|
8
|
-
process.env.AGLEDGER_API_KEY ?? '
|
|
8
|
+
process.env.AGLEDGER_API_KEY ?? 'agl_agt_test';
|
|
9
9
|
|
|
10
10
|
let client: Client;
|
|
11
11
|
let cleanup: () => Promise<void>;
|
|
@@ -66,41 +66,41 @@ describe('agledger_discover (live)', () => {
|
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
describe('
|
|
70
|
-
let
|
|
71
|
-
let
|
|
69
|
+
describe('admin key (live)', () => {
|
|
70
|
+
let adminClient: Client;
|
|
71
|
+
let adminCleanup: () => Promise<void>;
|
|
72
72
|
|
|
73
73
|
beforeAll(async () => {
|
|
74
74
|
if (!apiReachable) return;
|
|
75
|
-
const
|
|
76
|
-
const server = new AgledgerMcpServer({ apiKey:
|
|
75
|
+
const adminKey = process.env.AGLEDGER_ADMIN_API_KEY ?? 'agl_adm_test';
|
|
76
|
+
const server = new AgledgerMcpServer({ apiKey: adminKey, apiUrl: API_URL });
|
|
77
77
|
const [ct, st] = InMemoryTransport.createLinkedPair();
|
|
78
|
-
|
|
79
|
-
await Promise.all([server.mcp.connect(st),
|
|
80
|
-
|
|
81
|
-
await
|
|
78
|
+
adminClient = new Client({ name: 'admin-test', version: '0.0.0-test' });
|
|
79
|
+
await Promise.all([server.mcp.connect(st), adminClient.connect(ct)]);
|
|
80
|
+
adminCleanup = async () => {
|
|
81
|
+
await adminClient.close();
|
|
82
82
|
await server.mcp.close();
|
|
83
83
|
};
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
afterAll(async () => {
|
|
87
|
-
if (
|
|
87
|
+
if (adminCleanup) await adminCleanup();
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
it('discover works with
|
|
90
|
+
it('discover works with admin key', async () => {
|
|
91
91
|
if (skipIfNoApi()) return;
|
|
92
|
-
const result = await
|
|
92
|
+
const result = await adminClient.callTool({ name: 'agledger_discover', arguments: {} });
|
|
93
93
|
expect(result.isError).toBeFalsy();
|
|
94
94
|
const content = result.structuredContent as Record<string, unknown>;
|
|
95
95
|
const identity = content.identity as Record<string, unknown>;
|
|
96
|
-
expect(identity.role).toBe('
|
|
96
|
+
expect(identity.role).toBe('admin');
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
it('can list
|
|
99
|
+
it('can list records with admin key', async () => {
|
|
100
100
|
if (skipIfNoApi()) return;
|
|
101
|
-
const result = await
|
|
101
|
+
const result = await adminClient.callTool({
|
|
102
102
|
name: 'agledger_api',
|
|
103
|
-
arguments: { method: 'GET', path: '/v1/
|
|
103
|
+
arguments: { method: 'GET', path: '/v1/records', params: { limit: 1 } },
|
|
104
104
|
});
|
|
105
105
|
expect(result.isError).toBeFalsy();
|
|
106
106
|
const content = result.structuredContent as Record<string, unknown>;
|
|
@@ -136,7 +136,7 @@ describe('agledger_api (live)', () => {
|
|
|
136
136
|
expect(content.ownerId).toBeDefined();
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
-
it('GET /v1/schemas lists
|
|
139
|
+
it('GET /v1/schemas lists Record types', async () => {
|
|
140
140
|
if (skipIfNoApi()) return;
|
|
141
141
|
|
|
142
142
|
const result = await client.callTool({
|
|
@@ -150,12 +150,12 @@ describe('agledger_api (live)', () => {
|
|
|
150
150
|
expect(Array.isArray(content.data)).toBe(true);
|
|
151
151
|
});
|
|
152
152
|
|
|
153
|
-
it('GET /v1/
|
|
153
|
+
it('GET /v1/records lists records', async () => {
|
|
154
154
|
if (skipIfNoApi()) return;
|
|
155
155
|
|
|
156
156
|
const result = await client.callTool({
|
|
157
157
|
name: 'agledger_api',
|
|
158
|
-
arguments: { method: 'GET', path: '/v1/
|
|
158
|
+
arguments: { method: 'GET', path: '/v1/records', params: { limit: 5 } },
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
expect(result.isError).toBeFalsy();
|
|
@@ -163,16 +163,16 @@ describe('agledger_api (live)', () => {
|
|
|
163
163
|
expect(content.data).toBeDefined();
|
|
164
164
|
});
|
|
165
165
|
|
|
166
|
-
it('POST /v1/
|
|
166
|
+
it('POST /v1/records creates a record', async () => {
|
|
167
167
|
if (skipIfNoApi()) return;
|
|
168
168
|
|
|
169
169
|
const result = await client.callTool({
|
|
170
170
|
name: 'agledger_api',
|
|
171
171
|
arguments: {
|
|
172
172
|
method: 'POST',
|
|
173
|
-
path: '/v1/
|
|
173
|
+
path: '/v1/records',
|
|
174
174
|
params: {
|
|
175
|
-
|
|
175
|
+
type: 'ACH-PROC-v1',
|
|
176
176
|
platform: 'mcp-integration-test',
|
|
177
177
|
criteria: {
|
|
178
178
|
item_spec: 'integration-test-resource',
|
|
@@ -184,15 +184,15 @@ describe('agledger_api (live)', () => {
|
|
|
184
184
|
expect(result.isError).toBeFalsy();
|
|
185
185
|
const content = result.structuredContent as Record<string, unknown>;
|
|
186
186
|
expect(content.id).toBeDefined();
|
|
187
|
-
expect(content.
|
|
187
|
+
expect(content.type).toBe('ACH-PROC-v1');
|
|
188
188
|
});
|
|
189
189
|
|
|
190
|
-
it('returns structured error for not-found
|
|
190
|
+
it('returns structured error for not-found record', async () => {
|
|
191
191
|
if (skipIfNoApi()) return;
|
|
192
192
|
|
|
193
193
|
const result = await client.callTool({
|
|
194
194
|
name: 'agledger_api',
|
|
195
|
-
arguments: { method: 'GET', path: '/v1/
|
|
195
|
+
arguments: { method: 'GET', path: '/v1/records/nonexistent-id' },
|
|
196
196
|
});
|
|
197
197
|
|
|
198
198
|
expect(result.isError).toBe(true);
|
|
@@ -207,9 +207,9 @@ describe('agledger_api (live)', () => {
|
|
|
207
207
|
name: 'agledger_api',
|
|
208
208
|
arguments: {
|
|
209
209
|
method: 'POST',
|
|
210
|
-
path: '/v1/
|
|
210
|
+
path: '/v1/records',
|
|
211
211
|
params: {
|
|
212
|
-
|
|
212
|
+
type: 'ACH-PROC-v1',
|
|
213
213
|
platform: 'test',
|
|
214
214
|
criteria: { bad_field: 'wrong' },
|
|
215
215
|
},
|
|
@@ -223,19 +223,19 @@ describe('agledger_api (live)', () => {
|
|
|
223
223
|
});
|
|
224
224
|
});
|
|
225
225
|
|
|
226
|
-
describe('full
|
|
227
|
-
let
|
|
226
|
+
describe('full record lifecycle (live)', () => {
|
|
227
|
+
let recordId: string;
|
|
228
228
|
|
|
229
|
-
it('step 1: create
|
|
229
|
+
it('step 1: create record with autoActivate', async () => {
|
|
230
230
|
if (skipIfNoApi()) return;
|
|
231
231
|
|
|
232
232
|
const result = await client.callTool({
|
|
233
233
|
name: 'agledger_api',
|
|
234
234
|
arguments: {
|
|
235
235
|
method: 'POST',
|
|
236
|
-
path: '/v1/
|
|
236
|
+
path: '/v1/records',
|
|
237
237
|
params: {
|
|
238
|
-
|
|
238
|
+
type: 'ACH-PROC-v1',
|
|
239
239
|
platform: 'mcp-lifecycle-test',
|
|
240
240
|
autoActivate: true,
|
|
241
241
|
criteria: {
|
|
@@ -247,33 +247,33 @@ describe('full mandate lifecycle (live)', () => {
|
|
|
247
247
|
|
|
248
248
|
expect(result.isError).toBeFalsy();
|
|
249
249
|
const content = result.structuredContent as Record<string, unknown>;
|
|
250
|
-
|
|
251
|
-
expect(
|
|
250
|
+
recordId = content.id as string;
|
|
251
|
+
expect(recordId).toBeDefined();
|
|
252
252
|
expect(content.status).toBe('ACTIVE');
|
|
253
253
|
});
|
|
254
254
|
|
|
255
|
-
it('step 2: get
|
|
256
|
-
if (skipIfNoApi() || !
|
|
255
|
+
it('step 2: get record to confirm state', async () => {
|
|
256
|
+
if (skipIfNoApi() || !recordId) return;
|
|
257
257
|
|
|
258
258
|
const result = await client.callTool({
|
|
259
259
|
name: 'agledger_api',
|
|
260
|
-
arguments: { method: 'GET', path: `/v1/
|
|
260
|
+
arguments: { method: 'GET', path: `/v1/records/${recordId}` },
|
|
261
261
|
});
|
|
262
262
|
|
|
263
263
|
expect(result.isError).toBeFalsy();
|
|
264
264
|
const content = result.structuredContent as Record<string, unknown>;
|
|
265
|
-
expect(content.id).toBe(
|
|
265
|
+
expect(content.id).toBe(recordId);
|
|
266
266
|
expect(content.status).toBe('ACTIVE');
|
|
267
267
|
});
|
|
268
268
|
|
|
269
269
|
it('step 3: submit receipt', async () => {
|
|
270
|
-
if (skipIfNoApi() || !
|
|
270
|
+
if (skipIfNoApi() || !recordId) return;
|
|
271
271
|
|
|
272
272
|
const result = await client.callTool({
|
|
273
273
|
name: 'agledger_api',
|
|
274
274
|
arguments: {
|
|
275
275
|
method: 'POST',
|
|
276
|
-
path: `/v1/
|
|
276
|
+
path: `/v1/records/${recordId}/receipts`,
|
|
277
277
|
params: {
|
|
278
278
|
evidence: {
|
|
279
279
|
item_secured: 'Lifecycle test widget delivered',
|
|
@@ -289,15 +289,15 @@ describe('full mandate lifecycle (live)', () => {
|
|
|
289
289
|
expect(result.isError).toBeFalsy();
|
|
290
290
|
const content = result.structuredContent as Record<string, unknown>;
|
|
291
291
|
expect(content.id).toBeDefined();
|
|
292
|
-
expect(content.
|
|
292
|
+
expect(content.recordId).toBe(recordId);
|
|
293
293
|
});
|
|
294
294
|
|
|
295
|
-
it('step 4: check
|
|
296
|
-
if (skipIfNoApi() || !
|
|
295
|
+
it('step 4: check record reached terminal state', async () => {
|
|
296
|
+
if (skipIfNoApi() || !recordId) return;
|
|
297
297
|
|
|
298
298
|
const result = await client.callTool({
|
|
299
299
|
name: 'agledger_api',
|
|
300
|
-
arguments: { method: 'GET', path: `/v1/
|
|
300
|
+
arguments: { method: 'GET', path: `/v1/records/${recordId}` },
|
|
301
301
|
});
|
|
302
302
|
|
|
303
303
|
expect(result.isError).toBeFalsy();
|
|
@@ -306,30 +306,30 @@ describe('full mandate lifecycle (live)', () => {
|
|
|
306
306
|
expect(['FULFILLED', 'VERIFIED_FAIL', 'PROCESSING']).toContain(status);
|
|
307
307
|
});
|
|
308
308
|
|
|
309
|
-
it('step 5: list receipts for
|
|
310
|
-
if (skipIfNoApi() || !
|
|
309
|
+
it('step 5: list receipts for record', async () => {
|
|
310
|
+
if (skipIfNoApi() || !recordId) return;
|
|
311
311
|
|
|
312
312
|
const result = await client.callTool({
|
|
313
313
|
name: 'agledger_api',
|
|
314
|
-
arguments: { method: 'GET', path: `/v1/
|
|
314
|
+
arguments: { method: 'GET', path: `/v1/records/${recordId}/receipts` },
|
|
315
315
|
});
|
|
316
316
|
|
|
317
317
|
expect(result.isError).toBeFalsy();
|
|
318
318
|
const content = result.structuredContent as Record<string, unknown>;
|
|
319
319
|
const data = content.data as Array<Record<string, unknown>>;
|
|
320
320
|
expect(data.length).toBeGreaterThanOrEqual(1);
|
|
321
|
-
expect(data[0].
|
|
321
|
+
expect(data[0].recordId).toBe(recordId);
|
|
322
322
|
});
|
|
323
323
|
|
|
324
|
-
it('step 6: check events for
|
|
325
|
-
if (skipIfNoApi() || !
|
|
324
|
+
it('step 6: check events for record', async () => {
|
|
325
|
+
if (skipIfNoApi() || !recordId) return;
|
|
326
326
|
|
|
327
327
|
const result = await client.callTool({
|
|
328
328
|
name: 'agledger_api',
|
|
329
329
|
arguments: {
|
|
330
330
|
method: 'GET',
|
|
331
331
|
path: '/v1/events',
|
|
332
|
-
params: {
|
|
332
|
+
params: { recordId, limit: 10, since: '2020-01-01T00:00:00Z' },
|
|
333
333
|
},
|
|
334
334
|
});
|
|
335
335
|
|
|
@@ -354,14 +354,14 @@ describe('HTTP method coverage (live)', () => {
|
|
|
354
354
|
expect(content.error ?? content.message).toBeDefined();
|
|
355
355
|
});
|
|
356
356
|
|
|
357
|
-
it('PATCH returns structured error for invalid
|
|
357
|
+
it('PATCH returns structured error for invalid record update', async () => {
|
|
358
358
|
if (skipIfNoApi()) return;
|
|
359
359
|
|
|
360
360
|
const result = await client.callTool({
|
|
361
361
|
name: 'agledger_api',
|
|
362
362
|
arguments: {
|
|
363
363
|
method: 'PATCH',
|
|
364
|
-
path: '/v1/
|
|
364
|
+
path: '/v1/records/nonexistent-id',
|
|
365
365
|
params: { platform: 'updated' },
|
|
366
366
|
},
|
|
367
367
|
});
|
package/tests/server.test.ts
CHANGED
|
@@ -44,7 +44,7 @@ describe('tool registration', () => {
|
|
|
44
44
|
expect(tool!.description).toContain('nextSteps');
|
|
45
45
|
expect(tool!.description).toContain('/v1/');
|
|
46
46
|
expect(tool!.description).toContain('/v1/schemas');
|
|
47
|
-
expect(tool!.description).toContain('/v1/
|
|
47
|
+
expect(tool!.description).toContain('/v1/records');
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
it('registers agledger_verify', () => {
|
|
@@ -113,7 +113,7 @@ describe('agledger_discover', () => {
|
|
|
113
113
|
}),
|
|
114
114
|
)
|
|
115
115
|
.mockResolvedValueOnce(
|
|
116
|
-
new Response(JSON.stringify({ agentId: 'agent-1', scopes: ['
|
|
116
|
+
new Response(JSON.stringify({ agentId: 'agent-1', scopes: ['records:read'] }), {
|
|
117
117
|
status: 200,
|
|
118
118
|
headers: { 'content-type': 'application/json' },
|
|
119
119
|
}),
|
|
@@ -125,13 +125,13 @@ describe('agledger_discover', () => {
|
|
|
125
125
|
expect(result.isError).toBeFalsy();
|
|
126
126
|
const content = result.structuredContent as Record<string, unknown>;
|
|
127
127
|
expect(content.health).toEqual({ status: 'ok', version: '1.0.0' });
|
|
128
|
-
expect(content.identity).toEqual({ agentId: 'agent-1', scopes: ['
|
|
128
|
+
expect(content.identity).toEqual({ agentId: 'agent-1', scopes: ['records:read'] });
|
|
129
129
|
|
|
130
130
|
// Quickstart workflow is always present
|
|
131
131
|
const quickstart = content.quickstart as { steps: Array<{ step: number; path: string }> };
|
|
132
132
|
expect(quickstart.steps).toHaveLength(4);
|
|
133
133
|
expect(quickstart.steps[0].path).toBe('/v1/schemas');
|
|
134
|
-
expect(quickstart.steps[2].path).toBe('/v1/
|
|
134
|
+
expect(quickstart.steps[2].path).toBe('/v1/records');
|
|
135
135
|
|
|
136
136
|
// Docs hints always present — point at live API discovery and the openapi resource.
|
|
137
137
|
const docs = content.docs as { openapi: string; openapiResource: string; description: string };
|
|
@@ -164,8 +164,8 @@ describe('agledger_discover', () => {
|
|
|
164
164
|
describe('agledger_api', () => {
|
|
165
165
|
it('passes through successful GET response', async () => {
|
|
166
166
|
const apiResponse = {
|
|
167
|
-
data: [{ id: '
|
|
168
|
-
nextSteps: [{ action: 'Get
|
|
167
|
+
data: [{ id: 'r-1', status: 'ACTIVE' }],
|
|
168
|
+
nextSteps: [{ action: 'Get record', method: 'GET', href: '/records/r-1' }],
|
|
169
169
|
};
|
|
170
170
|
vi.stubGlobal(
|
|
171
171
|
'fetch',
|
|
@@ -179,7 +179,7 @@ describe('agledger_api', () => {
|
|
|
179
179
|
|
|
180
180
|
const result = await harness.client.callTool({
|
|
181
181
|
name: 'agledger_api',
|
|
182
|
-
arguments: { method: 'GET', path: '/
|
|
182
|
+
arguments: { method: 'GET', path: '/records', params: { limit: 10 } },
|
|
183
183
|
});
|
|
184
184
|
|
|
185
185
|
expect(result.isError).toBeFalsy();
|
|
@@ -187,7 +187,7 @@ describe('agledger_api', () => {
|
|
|
187
187
|
});
|
|
188
188
|
|
|
189
189
|
it('passes through POST body', async () => {
|
|
190
|
-
const apiResponse = { id: '
|
|
190
|
+
const apiResponse = { id: 'r-2', status: 'CREATED' };
|
|
191
191
|
const mockFetch = vi.fn().mockResolvedValueOnce(
|
|
192
192
|
new Response(JSON.stringify(apiResponse), {
|
|
193
193
|
status: 201,
|
|
@@ -200,26 +200,26 @@ describe('agledger_api', () => {
|
|
|
200
200
|
name: 'agledger_api',
|
|
201
201
|
arguments: {
|
|
202
202
|
method: 'POST',
|
|
203
|
-
path: '/
|
|
204
|
-
params: {
|
|
203
|
+
path: '/records',
|
|
204
|
+
params: { type: 'ACH-PROC-v1', platform: 'test' },
|
|
205
205
|
},
|
|
206
206
|
});
|
|
207
207
|
|
|
208
208
|
const [url, options] = mockFetch.mock.calls[0] as [string, RequestInit];
|
|
209
|
-
expect(url).toContain('/
|
|
209
|
+
expect(url).toContain('/records');
|
|
210
210
|
expect(options.method).toBe('POST');
|
|
211
211
|
expect(JSON.parse(options.body as string)).toEqual({
|
|
212
|
-
|
|
212
|
+
type: 'ACH-PROC-v1',
|
|
213
213
|
platform: 'test',
|
|
214
214
|
});
|
|
215
215
|
});
|
|
216
216
|
|
|
217
217
|
it('forwards full API error body', async () => {
|
|
218
218
|
const errorBody = {
|
|
219
|
-
message: '
|
|
219
|
+
message: 'Record not found',
|
|
220
220
|
code: 'NOT_FOUND',
|
|
221
221
|
docUrl: 'https://www.agledger.ai/docs/errors/NOT_FOUND',
|
|
222
|
-
suggestion: 'Check the
|
|
222
|
+
suggestion: 'Check the record ID and try again.',
|
|
223
223
|
};
|
|
224
224
|
vi.stubGlobal(
|
|
225
225
|
'fetch',
|
|
@@ -233,21 +233,21 @@ describe('agledger_api', () => {
|
|
|
233
233
|
|
|
234
234
|
const result = await harness.client.callTool({
|
|
235
235
|
name: 'agledger_api',
|
|
236
|
-
arguments: { method: 'GET', path: '/
|
|
236
|
+
arguments: { method: 'GET', path: '/records/bad-id' },
|
|
237
237
|
});
|
|
238
238
|
|
|
239
239
|
expect(result.isError).toBe(true);
|
|
240
240
|
const content = result.structuredContent as Record<string, unknown>;
|
|
241
241
|
expect(content.docUrl).toBe('https://www.agledger.ai/docs/errors/NOT_FOUND');
|
|
242
|
-
expect(content.suggestion).toBe('Check the
|
|
242
|
+
expect(content.suggestion).toBe('Check the record ID and try again.');
|
|
243
243
|
});
|
|
244
244
|
|
|
245
245
|
it('forwards 403 with missingScopes', async () => {
|
|
246
246
|
const errorBody = {
|
|
247
247
|
message: 'Insufficient permissions',
|
|
248
248
|
code: 'FORBIDDEN',
|
|
249
|
-
missingScopes: ['
|
|
250
|
-
suggestion: 'Request
|
|
249
|
+
missingScopes: ['records:write'],
|
|
250
|
+
suggestion: 'Request records:write scope on your API key.',
|
|
251
251
|
};
|
|
252
252
|
vi.stubGlobal(
|
|
253
253
|
'fetch',
|
|
@@ -261,18 +261,18 @@ describe('agledger_api', () => {
|
|
|
261
261
|
|
|
262
262
|
const result = await harness.client.callTool({
|
|
263
263
|
name: 'agledger_api',
|
|
264
|
-
arguments: { method: 'POST', path: '/
|
|
264
|
+
arguments: { method: 'POST', path: '/records', params: {} },
|
|
265
265
|
});
|
|
266
266
|
|
|
267
267
|
expect(result.isError).toBe(true);
|
|
268
268
|
const content = result.structuredContent as Record<string, unknown>;
|
|
269
|
-
expect(content.missingScopes).toEqual(['
|
|
269
|
+
expect(content.missingScopes).toEqual(['records:write']);
|
|
270
270
|
});
|
|
271
271
|
|
|
272
272
|
it('rejects path not starting with / with recovery directive', async () => {
|
|
273
273
|
const result = await harness.client.callTool({
|
|
274
274
|
name: 'agledger_api',
|
|
275
|
-
arguments: { method: 'GET', path: '
|
|
275
|
+
arguments: { method: 'GET', path: 'records' },
|
|
276
276
|
});
|
|
277
277
|
|
|
278
278
|
expect(result.isError).toBe(true);
|
|
@@ -288,7 +288,7 @@ describe('agledger_api', () => {
|
|
|
288
288
|
// Thin-passthrough contract: the API owns error guidance. The MCP must not
|
|
289
289
|
// inject a suggestion or any other field the API didn't return.
|
|
290
290
|
const errorBody = {
|
|
291
|
-
message: 'Invalid
|
|
291
|
+
message: 'Invalid Record type',
|
|
292
292
|
code: 'BAD_REQUEST',
|
|
293
293
|
};
|
|
294
294
|
vi.stubGlobal(
|
|
@@ -303,7 +303,7 @@ describe('agledger_api', () => {
|
|
|
303
303
|
|
|
304
304
|
const result = await harness.client.callTool({
|
|
305
305
|
name: 'agledger_api',
|
|
306
|
-
arguments: { method: 'POST', path: '/v1/
|
|
306
|
+
arguments: { method: 'POST', path: '/v1/records', params: { type: 'INVALID' } },
|
|
307
307
|
});
|
|
308
308
|
|
|
309
309
|
expect(result.isError).toBe(true);
|
|
@@ -314,9 +314,9 @@ describe('agledger_api', () => {
|
|
|
314
314
|
|
|
315
315
|
it('preserves existing API suggestion without overwriting', async () => {
|
|
316
316
|
const errorBody = {
|
|
317
|
-
message: '
|
|
317
|
+
message: 'Record not found',
|
|
318
318
|
code: 'NOT_FOUND',
|
|
319
|
-
suggestion: 'The
|
|
319
|
+
suggestion: 'The record may have been deleted.',
|
|
320
320
|
};
|
|
321
321
|
vi.stubGlobal(
|
|
322
322
|
'fetch',
|
|
@@ -330,12 +330,12 @@ describe('agledger_api', () => {
|
|
|
330
330
|
|
|
331
331
|
const result = await harness.client.callTool({
|
|
332
332
|
name: 'agledger_api',
|
|
333
|
-
arguments: { method: 'GET', path: '/v1/
|
|
333
|
+
arguments: { method: 'GET', path: '/v1/records/bad-id' },
|
|
334
334
|
});
|
|
335
335
|
|
|
336
336
|
expect(result.isError).toBe(true);
|
|
337
337
|
const content = result.structuredContent as Record<string, unknown>;
|
|
338
|
-
expect(content.suggestion).toBe('The
|
|
338
|
+
expect(content.suggestion).toBe('The record may have been deleted.');
|
|
339
339
|
});
|
|
340
340
|
|
|
341
341
|
it('handles network errors with recovery directive', async () => {
|
|
@@ -411,7 +411,7 @@ describe('agledger_api', () => {
|
|
|
411
411
|
name: 'agledger_api',
|
|
412
412
|
arguments: {
|
|
413
413
|
method: 'GET',
|
|
414
|
-
path: '/
|
|
414
|
+
path: '/records/search',
|
|
415
415
|
params: { status: 'ACTIVE', limit: 20 },
|
|
416
416
|
},
|
|
417
417
|
});
|