@agledger/mcp-server 2.3.0 → 2.3.2
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 +25 -0
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +2 -1
- package/dist/api-client.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +17 -11
- package/dist/server.js.map +1 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/package.json +7 -1
- package/src/api-client.ts +0 -72
- package/src/index.ts +0 -69
- package/src/server.ts +0 -326
- package/src/verify/verify-export.ts +0 -296
- package/tests/api-client.test.ts +0 -147
- package/tests/harness.ts +0 -28
- package/tests/integration.test.ts +0 -373
- package/tests/server.test.ts +0 -500
- package/tsconfig.json +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,31 @@ All notable changes to the AGLedger MCP Server will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [2.3.2] - 2026-05-06
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **Tool results are now visible to LLM-driven MCP runtimes.** Previously every tool returned `content: []` with all data in `structuredContent`. Per MCP spec 2025-06-18, structured content SHOULD also be returned as functionally-equivalent unstructured content; LLM clients (Claude Desktop, ChatGPT MCP, Cursor, OpenAI tool-mapped runtimes) only forward `content[]` to the model, so they saw empty results and stopped. All three tools (`agledger_discover`, `agledger_api`, `agledger_verify`) now mirror `structuredContent` into a single TextContent block on every success and error path. (testbed F-531 / agledger-agents#66)
|
|
12
|
+
- **`serverInfo.version`, `User-Agent`, and `--help` banner no longer drift from `package.json`.** All three read the version from `package.json` at runtime via a shared `version.ts` module instead of duplicating the literal. v2.3.1 shipped `serverInfo.version: 2.3.0` and `User-Agent: agledger-mcp-server/2.2.0`; that class of drift is now structurally impossible.
|
|
13
|
+
- **`--help` banner lists all three tools.** `agledger_verify` was missing from the Tools section.
|
|
14
|
+
- **`mirrorContent` no longer pretty-prints.** The text mirror is consumed by an LLM, not a human — dropping the 2-space indent saves ~25% on agent context tokens for large paginated responses.
|
|
15
|
+
|
|
16
|
+
### Build
|
|
17
|
+
|
|
18
|
+
- Added a `files` allowlist to `package.json` so the npm tarball only ships `dist/`, `LICENSE`, `README.md`, `CHANGELOG.md`, and `package.json` (24 files vs. 29 in 2.3.1). No more shipping `tests/` or `tsconfig.json`.
|
|
19
|
+
|
|
20
|
+
### Tests
|
|
21
|
+
|
|
22
|
+
- Added `assertContentMirrorsStructured` helper and a dedicated F-531 regression suite covering success and error paths on all three tools, plus a parity test asserting `SERVER_VERSION` matches `package.json`.
|
|
23
|
+
|
|
24
|
+
## [2.3.1] - 2026-04-30
|
|
25
|
+
|
|
26
|
+
Tracks AGLedger API v0.22.13. The MCP server is a thin pass-through, so all 10 new v0.22.x routes (`/v1/admin/strings/*`, federation gateway status, peer directory, vault checkpoints, dispute withdraw, etc.) are reachable via `agledger_api` with no surface changes.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- Re-published as part of the v0.7.1 SDK/CLI sweep tracking API v0.22.13. No tool-surface changes.
|
|
31
|
+
|
|
7
32
|
## [2.3.0] - 2026-04-27
|
|
8
33
|
|
|
9
34
|
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.
|
package/dist/api-client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,EAAE,OAAO,CAAC;CACb;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,SAAS;IAMxD,OAAO,CACX,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,IAAI,CAAC,EAAE,OAAO,CAAC;KAChB,GACA,OAAO,CAAC,WAAW,CAAC;CA+CxB"}
|
package/dist/api-client.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SERVER_VERSION } from './version.js';
|
|
1
2
|
export class ApiClient {
|
|
2
3
|
apiUrl;
|
|
3
4
|
apiKey;
|
|
@@ -19,7 +20,7 @@ export class ApiClient {
|
|
|
19
20
|
const headers = {
|
|
20
21
|
Authorization: `Bearer ${this.apiKey}`,
|
|
21
22
|
Accept: 'application/json',
|
|
22
|
-
'User-Agent':
|
|
23
|
+
'User-Agent': `agledger-mcp-server/${SERVER_VERSION}`,
|
|
23
24
|
};
|
|
24
25
|
if (options?.body !== undefined) {
|
|
25
26
|
headers['Content-Type'] = 'application/json';
|
package/dist/api-client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api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AO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAErE,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE;gBACtC,MAAM;gBACN,OAAO;gBACP,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;gBAC5E,MAAM,EAAE,UAAU,CAAC,MAAM;aAC1B,CAAC,CAAC;YAEH,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;YAC1D,IAAI,IAAa,CAAC;YAElB,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBACjC,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;gBAC9B,IAAI,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;YACnD,CAAC;YAED,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;QAClD,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAoEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { parseArgs } from 'node:util';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
-
import { AgledgerMcpServer } from './server.js';
|
|
4
|
+
import { AgledgerMcpServer, SERVER_VERSION } from './server.js';
|
|
5
5
|
process.on('uncaughtException', (err) => {
|
|
6
6
|
process.stderr.write(`Uncaught exception: ${err.message}\n`);
|
|
7
7
|
});
|
|
@@ -18,7 +18,7 @@ function main() {
|
|
|
18
18
|
strict: true,
|
|
19
19
|
});
|
|
20
20
|
if (values.help) {
|
|
21
|
-
process.stderr.write(`AGLedger MCP Server
|
|
21
|
+
process.stderr.write(`AGLedger MCP Server v${SERVER_VERSION}
|
|
22
22
|
|
|
23
23
|
Usage: agledger-mcp --api-key <key> [--api-url <url>]
|
|
24
24
|
|
|
@@ -30,6 +30,7 @@ Options:
|
|
|
30
30
|
Tools:
|
|
31
31
|
agledger_discover Returns API health, your identity, and available scopes
|
|
32
32
|
agledger_api Make any AGLedger API call — the API guides you via nextSteps
|
|
33
|
+
agledger_verify Verify an audit export offline (hash chain + Ed25519)
|
|
33
34
|
`);
|
|
34
35
|
process.exit(0);
|
|
35
36
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,O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MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAEjE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,0EAA0E,CAC3E,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACzD,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAE7C,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;QACnD,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,sCAAsC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAC3F,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,IAAI,EAAE,CAAC;AAEP,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { ApiClient } from './api-client.js';
|
|
3
|
+
import { SERVER_VERSION } from './version.js';
|
|
4
|
+
export { SERVER_VERSION };
|
|
3
5
|
export interface AgledgerMcpServerOptions {
|
|
4
6
|
apiKey: string;
|
|
5
7
|
apiUrl?: string;
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA0CD,qBAAa,iBAAiB;IAC5B,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;gBAEf,OAAO,EAAE,wBAAwB;IAc7C,OAAO,CAAC,aAAa;IAiOrB,OAAO,CAAC,iBAAiB;CAkC1B"}
|
package/dist/server.js
CHANGED
|
@@ -2,6 +2,8 @@ import { z } from 'zod';
|
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { verifyExport } from './verify/verify-export.js';
|
|
4
4
|
import { ApiClient } from './api-client.js';
|
|
5
|
+
import { SERVER_VERSION } from './version.js';
|
|
6
|
+
export { SERVER_VERSION };
|
|
5
7
|
const QUICKSTART = {
|
|
6
8
|
description: 'To track accountability for your work, follow these steps in order:',
|
|
7
9
|
steps: [
|
|
@@ -17,6 +19,11 @@ const DOCS = {
|
|
|
17
19
|
openapi: '/openapi.json',
|
|
18
20
|
openapiResource: 'agledger://openapi',
|
|
19
21
|
};
|
|
22
|
+
// MCP spec 2025-06-18: structuredContent SHOULD also surface as content[]
|
|
23
|
+
// because most LLM-driven runtimes ignore structuredContent.
|
|
24
|
+
function mirrorContent(structured) {
|
|
25
|
+
return [{ type: 'text', text: JSON.stringify(structured) }];
|
|
26
|
+
}
|
|
20
27
|
/**
|
|
21
28
|
* Structured error for CLI-origin failures (network, timeout, malformed input).
|
|
22
29
|
* API-origin errors are forwarded verbatim without enrichment — if the API
|
|
@@ -29,7 +36,7 @@ function errorResult(message, code, suggestion) {
|
|
|
29
36
|
if (suggestion)
|
|
30
37
|
structuredContent.suggestion = suggestion;
|
|
31
38
|
return {
|
|
32
|
-
content:
|
|
39
|
+
content: mirrorContent(structuredContent),
|
|
33
40
|
structuredContent,
|
|
34
41
|
isError: true,
|
|
35
42
|
};
|
|
@@ -40,7 +47,7 @@ export class AgledgerMcpServer {
|
|
|
40
47
|
constructor(options) {
|
|
41
48
|
const apiUrl = options.apiUrl ?? 'https://agledger.example.com';
|
|
42
49
|
this.client = new ApiClient(apiUrl, options.apiKey, options.timeoutMs);
|
|
43
|
-
this.mcp = new McpServer({ name: 'agledger-mcp-server', version:
|
|
50
|
+
this.mcp = new McpServer({ name: 'agledger-mcp-server', version: SERVER_VERSION }, { capabilities: { tools: {}, resources: {} } });
|
|
44
51
|
this.registerTools();
|
|
45
52
|
this.registerResources();
|
|
46
53
|
}
|
|
@@ -88,7 +95,7 @@ export class AgledgerMcpServer {
|
|
|
88
95
|
}
|
|
89
96
|
result.quickstart = QUICKSTART;
|
|
90
97
|
result.docs = DOCS;
|
|
91
|
-
return { content:
|
|
98
|
+
return { content: mirrorContent(result), structuredContent: result };
|
|
92
99
|
}
|
|
93
100
|
catch (err) {
|
|
94
101
|
return errorResult(err instanceof Error ? err.message : String(err), 'DISCOVER_FAILED');
|
|
@@ -139,19 +146,17 @@ export class AgledgerMcpServer {
|
|
|
139
146
|
}
|
|
140
147
|
const response = await client.request(method, path, options);
|
|
141
148
|
if (response.ok) {
|
|
149
|
+
const body = response.body;
|
|
142
150
|
return {
|
|
143
|
-
content:
|
|
144
|
-
structuredContent:
|
|
151
|
+
content: mirrorContent(body),
|
|
152
|
+
structuredContent: body,
|
|
145
153
|
};
|
|
146
154
|
}
|
|
147
155
|
// Forward the API error body verbatim. The API owns error guidance;
|
|
148
156
|
// the MCP does not enrich, translate, or inject suggestions.
|
|
149
157
|
const errorBody = (response.body ?? {});
|
|
150
|
-
const message = (errorBody.message ??
|
|
151
|
-
errorBody.error ??
|
|
152
|
-
`API returned ${response.status}`);
|
|
153
158
|
return {
|
|
154
|
-
content:
|
|
159
|
+
content: mirrorContent(errorBody),
|
|
155
160
|
structuredContent: errorBody,
|
|
156
161
|
isError: true,
|
|
157
162
|
};
|
|
@@ -206,9 +211,10 @@ export class AgledgerMcpServer {
|
|
|
206
211
|
publicKeys,
|
|
207
212
|
requireKeyId,
|
|
208
213
|
});
|
|
214
|
+
const structured = result;
|
|
209
215
|
return {
|
|
210
|
-
content:
|
|
211
|
-
structuredContent:
|
|
216
|
+
content: mirrorContent(structured),
|
|
217
|
+
structuredContent: structured,
|
|
212
218
|
isError: !result.valid,
|
|
213
219
|
};
|
|
214
220
|
}
|
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,EAA0B,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
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;AAC5C,OAAO,EAAE,cAAc,EAAE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,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,QAIlB,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,CAAC,MAAM,cAAc,GACzB,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAG7E,CAAC,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agledger/mcp-server",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
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",
|
|
@@ -23,6 +23,12 @@
|
|
|
23
23
|
"type": "module",
|
|
24
24
|
"main": "./dist/index.js",
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"README.md",
|
|
30
|
+
"CHANGELOG.md"
|
|
31
|
+
],
|
|
26
32
|
"bin": {
|
|
27
33
|
"agledger-mcp": "./dist/index.js"
|
|
28
34
|
},
|
package/src/api-client.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export interface ApiResponse {
|
|
2
|
-
status: number;
|
|
3
|
-
body: unknown;
|
|
4
|
-
ok: boolean;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export class ApiClient {
|
|
8
|
-
private readonly apiUrl: string;
|
|
9
|
-
private readonly apiKey: string;
|
|
10
|
-
private readonly timeoutMs: number;
|
|
11
|
-
|
|
12
|
-
constructor(apiUrl: string, apiKey: string, timeoutMs = 30_000) {
|
|
13
|
-
this.apiUrl = apiUrl.replace(/\/+$/, '');
|
|
14
|
-
this.apiKey = apiKey;
|
|
15
|
-
this.timeoutMs = timeoutMs;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async request(
|
|
19
|
-
method: string,
|
|
20
|
-
path: string,
|
|
21
|
-
options?: {
|
|
22
|
-
query?: Record<string, unknown>;
|
|
23
|
-
body?: unknown;
|
|
24
|
-
},
|
|
25
|
-
): Promise<ApiResponse> {
|
|
26
|
-
const url = new URL(path, this.apiUrl);
|
|
27
|
-
|
|
28
|
-
if (options?.query) {
|
|
29
|
-
for (const [k, v] of Object.entries(options.query)) {
|
|
30
|
-
if (v !== undefined && v !== null) {
|
|
31
|
-
url.searchParams.set(k, String(v));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const headers: Record<string, string> = {
|
|
37
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
38
|
-
Accept: 'application/json',
|
|
39
|
-
'User-Agent': 'agledger-mcp-server/2.2.0',
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
if (options?.body !== undefined) {
|
|
43
|
-
headers['Content-Type'] = 'application/json';
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const controller = new AbortController();
|
|
47
|
-
const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
48
|
-
|
|
49
|
-
try {
|
|
50
|
-
const res = await fetch(url.toString(), {
|
|
51
|
-
method,
|
|
52
|
-
headers,
|
|
53
|
-
body: options?.body !== undefined ? JSON.stringify(options.body) : undefined,
|
|
54
|
-
signal: controller.signal,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const contentType = res.headers.get('content-type') ?? '';
|
|
58
|
-
let body: unknown;
|
|
59
|
-
|
|
60
|
-
if (contentType.includes('json')) {
|
|
61
|
-
body = await res.json();
|
|
62
|
-
} else {
|
|
63
|
-
const text = await res.text();
|
|
64
|
-
body = { _raw: text, _contentType: contentType };
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return { status: res.status, body, ok: res.ok };
|
|
68
|
-
} finally {
|
|
69
|
-
clearTimeout(timeout);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { parseArgs } from 'node:util';
|
|
3
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
-
import { AgledgerMcpServer } from './server.js';
|
|
5
|
-
|
|
6
|
-
process.on('uncaughtException', (err) => {
|
|
7
|
-
process.stderr.write(`Uncaught exception: ${err.message}\n`);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
process.on('unhandledRejection', (reason) => {
|
|
11
|
-
process.stderr.write(
|
|
12
|
-
`Unhandled rejection: ${reason instanceof Error ? reason.message : String(reason)}\n`,
|
|
13
|
-
);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
function main(): void {
|
|
17
|
-
const { values } = parseArgs({
|
|
18
|
-
options: {
|
|
19
|
-
'api-key': { type: 'string', short: 'k' },
|
|
20
|
-
'api-url': { type: 'string', short: 'u' },
|
|
21
|
-
help: { type: 'boolean', short: 'h' },
|
|
22
|
-
},
|
|
23
|
-
strict: true,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
if (values.help) {
|
|
27
|
-
process.stderr.write(
|
|
28
|
-
`AGLedger MCP Server v2.3.0
|
|
29
|
-
|
|
30
|
-
Usage: agledger-mcp --api-key <key> [--api-url <url>]
|
|
31
|
-
|
|
32
|
-
Options:
|
|
33
|
-
--api-key, -k AGLedger API key (or AGLEDGER_API_KEY env var)
|
|
34
|
-
--api-url, -u AGLedger API base URL (or AGLEDGER_API_URL env var)
|
|
35
|
-
--help, -h Show this help message
|
|
36
|
-
|
|
37
|
-
Tools:
|
|
38
|
-
agledger_discover Returns API health, your identity, and available scopes
|
|
39
|
-
agledger_api Make any AGLedger API call — the API guides you via nextSteps
|
|
40
|
-
`,
|
|
41
|
-
);
|
|
42
|
-
process.exit(0);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const apiKey = values['api-key'] ?? process.env.AGLEDGER_API_KEY;
|
|
46
|
-
const apiUrl = values['api-url'] ?? process.env.AGLEDGER_API_URL;
|
|
47
|
-
|
|
48
|
-
if (!apiKey) {
|
|
49
|
-
process.stderr.write(
|
|
50
|
-
'Error: --api-key or AGLEDGER_API_KEY environment variable is required.\n',
|
|
51
|
-
);
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const server = new AgledgerMcpServer({ apiKey, apiUrl });
|
|
56
|
-
const transport = new StdioServerTransport();
|
|
57
|
-
|
|
58
|
-
server.mcp.connect(transport).catch((err: unknown) => {
|
|
59
|
-
process.stderr.write(
|
|
60
|
-
`Fatal: failed to start MCP server: ${err instanceof Error ? err.message : String(err)}\n`,
|
|
61
|
-
);
|
|
62
|
-
process.exit(1);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
main();
|
|
67
|
-
|
|
68
|
-
export { AgledgerMcpServer } from './server.js';
|
|
69
|
-
export type { AgledgerMcpServerOptions } from './server.js';
|