@agledger/mcp-server 2.10.1 → 2.11.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.
package/dist/server.d.ts CHANGED
@@ -1,9 +1,25 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import { ApiClient } from './api-client.js';
3
+ import { type OidcCertCredentialOptions } from './credentials.js';
4
+ import { type DelegationSourceOptions } from './delegation.js';
3
5
  import { SERVER_VERSION } from './version.js';
4
6
  export { SERVER_VERSION };
5
7
  export interface AgledgerMcpServerOptions {
6
- apiKey: string;
8
+ /** An AGLedger API key. Exactly one of `apiKey` and `oidc` is required. */
9
+ apiKey?: string;
10
+ /**
11
+ * Authenticate with a short-lived cert exchanged for a customer IdP token
12
+ * (`POST /v1/auth/oidc/cert`). `getOidcToken` is called for every exchange
13
+ * and must return a fresh token each time. Exactly one of `apiKey` and
14
+ * `oidc` is required.
15
+ */
16
+ oidc?: OidcCertCredentialOptions;
17
+ /**
18
+ * The source of an RFC 8693 delegation token, sent as `AGLedger-On-Behalf-Of`
19
+ * on every POST when the agent acts for a person or another party. Never a
20
+ * tool argument: the model can neither read nor choose it.
21
+ */
22
+ onBehalfOf?: DelegationSourceOptions;
7
23
  apiUrl?: string;
8
24
  /** Request timeout in milliseconds. Default 30000. */
9
25
  timeoutMs?: number;
package/dist/server.js CHANGED
@@ -15,6 +15,8 @@ import { z } from 'zod/v4';
15
15
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
16
16
  import { verifyAuditExport, } from '@agledger/verify-core';
17
17
  import { ApiClient } from './api-client.js';
18
+ import { OidcCertCredential, OidcExchangeError, OidcTokenSourceError, } from './credentials.js';
19
+ import { DelegationSource, DelegationSourceError } from './delegation.js';
18
20
  import { SERVER_VERSION } from './version.js';
19
21
  export { SERVER_VERSION };
20
22
  const QUICKSTART = {
@@ -51,18 +53,64 @@ function mirrorContent(structured) {
51
53
  * API-origin errors are forwarded verbatim without enrichment; if the API
52
54
  * returns a suggestion, agents see it; if not, that's an API concern to fix upstream.
53
55
  */
54
- function errorResult(message, code, suggestion) {
56
+ function errorResult(message, code, suggestion, extra) {
55
57
  const structuredContent = { error: true, message };
56
58
  if (code)
57
59
  structuredContent.code = code;
58
60
  if (suggestion)
59
61
  structuredContent.suggestion = suggestion;
62
+ if (extra)
63
+ Object.assign(structuredContent, extra);
60
64
  return {
61
65
  content: mirrorContent(structuredContent),
62
66
  structuredContent,
63
67
  isError: true,
64
68
  };
65
69
  }
70
+ /**
71
+ * The credential could not produce a bearer. This is a client-side failure (the
72
+ * request never went out), so it is reported in the server's own error shape.
73
+ * The exchange's refusal is carried as the Server sent it, scrubbed of any
74
+ * token, and its recoveryHint is passed through rather than rewritten.
75
+ */
76
+ function credentialErrorResult(err) {
77
+ if (err instanceof OidcExchangeError) {
78
+ return errorResult(err.message, err.code, err.recoveryHint ??
79
+ 'The OIDC cert exchange was refused. Check that the token source yields a current token from an issuer registered for agents on this Server.', err.status ? { status: err.status, response: err.body } : undefined);
80
+ }
81
+ if (err instanceof DelegationSourceError) {
82
+ return errorResult(err.message, err.code, 'Fix the delegation source the server was started with (AGLEDGER_ON_BEHALF_OF_CMD or AGLEDGER_ON_BEHALF_OF_FILE); it must yield a current RFC 8693 token-exchange result token.');
83
+ }
84
+ if (err instanceof OidcTokenSourceError) {
85
+ return errorResult(err.message, err.code, 'Fix the token source the server was started with (AGLEDGER_OIDC_TOKEN_CMD or AGLEDGER_OIDC_TOKEN_FILE); it must yield a current OIDC JWT on every call.');
86
+ }
87
+ return undefined;
88
+ }
89
+ /**
90
+ * A tool's input schema, refusing arguments it does not declare.
91
+ *
92
+ * zod's default object strips unknown keys, so `agledger_api` called with
93
+ * `body` instead of `params` sent no payload at all and the agent read the
94
+ * Server's "body must be object" as a payload problem. The object is loose so
95
+ * the handler sees the stray key and can name it; `additionalProperties` is
96
+ * then dropped from the published schema, which is what it said before. JSON
97
+ * Schema reads an absent `additionalProperties` as "allowed", same as the `{}`
98
+ * a loose object would publish, and Gemini's function-call grammar rejects
99
+ * the keyword outright. `tests/tool-schema.test.ts` asserts the published
100
+ * document.
101
+ */
102
+ function toolInput(shape) {
103
+ return z.looseObject(shape).meta({ additionalProperties: undefined });
104
+ }
105
+ function unknownArgumentResult(tool, shape, args, hint) {
106
+ const declared = Object.keys(shape);
107
+ const unknown = Object.keys(args).filter((k) => !declared.includes(k));
108
+ if (unknown.length === 0)
109
+ return undefined;
110
+ const names = unknown.map((k) => `\`${k}\``).join(', ');
111
+ const accepted = declared.length ? declared.map((k) => `\`${k}\``).join(', ') : 'no arguments';
112
+ return errorResult(`${tool} does not take ${unknown.length === 1 ? 'the argument' : 'the arguments'} ${names}. It accepts ${accepted}.`, 'UNKNOWN_ARGUMENT', `${hint ? `${hint} ` : ''}Call ${tool} again with only the arguments it declares.`, { unknownArguments: unknown, acceptedArguments: declared });
113
+ }
66
114
  // Free-form object fields are declared as `string` on the wire so Gemini's
67
115
  // function-call grammar (a strict OpenAPI 3.0 subset that rejects
68
116
  // `additionalProperties` and properties-less OBJECT) can emit them. The
@@ -144,6 +192,101 @@ function unwrapVerificationKeys(raw) {
144
192
  }
145
193
  return raw;
146
194
  }
195
+ /**
196
+ * Every code `agledger_verify` can report, named in its description so a model
197
+ * can branch on them. The list used to be typed out by hand and fell three
198
+ * codes behind verify-core (CHAIN_OIDC_ACTOR_MISMATCH, CHAIN_KEY_EXPIRED,
199
+ * CHAIN_KEY_NOT_YET_ACTIVE). `ExportCodesMissing` below makes the compiler
200
+ * fail when verify-core adds an export-level code this list does not carry.
201
+ * CHECKPOINT_* and TENANT_* are dump-verifier codes and never come back from
202
+ * an audit export.
203
+ */
204
+ const EXPORT_FAILURE_CODES = [
205
+ 'CHAIN_HASH_MISMATCH',
206
+ 'CHAIN_LINK_BROKEN',
207
+ 'CHAIN_GENESIS_INVALID',
208
+ 'CHAIN_POSITION_GAP',
209
+ 'CHAIN_MALFORMED_ENTRY',
210
+ 'CHAIN_COSE_DECODE_FAILED',
211
+ 'CHAIN_COSE_HEADER_MISMATCH',
212
+ 'CHAIN_PAYLOAD_BINDING_MISMATCH',
213
+ 'CHAIN_OIDC_ACTOR_MISMATCH',
214
+ 'CHAIN_SIGNATURE_INVALID',
215
+ 'CHAIN_SIGNATURE_MISSING_KEY',
216
+ 'CHAIN_KEY_POLICY_VIOLATION',
217
+ 'CHAIN_KEY_EXPIRED',
218
+ 'CHAIN_KEY_NOT_YET_ACTIVE',
219
+ 'CHAIN_ALG_MISMATCH',
220
+ 'CHAIN_SIGNING_KEY_DRIFT',
221
+ 'CHAIN_ACTOR_ATTRIBUTION_MISMATCH',
222
+ 'CHAIN_AGENT_SIGNATURE_INVALID',
223
+ 'CHAIN_UNSUPPORTED_ALGORITHM',
224
+ 'UNSUPPORTED_FORMAT',
225
+ 'CHAIN_EMPTY',
226
+ ];
227
+ // Resolves to `true` only when nothing is missing; otherwise the assignment
228
+ // fails and the error names the missing code.
229
+ const exportCodesComplete = true;
230
+ void exportCodesComplete;
231
+ const DISCOVER_ARGS = {};
232
+ const API_ARGS = {
233
+ method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']).describe('HTTP method'),
234
+ path: z
235
+ .string()
236
+ .describe('API path starting with / (e.g. /v1/records, /v1/schemas, /v1/records/{id}/completions)'),
237
+ params: jsonStringField
238
+ .optional()
239
+ .describe('Request parameters as a JSON-encoded string, e.g. \'{"type":"notarize-generic-v1","criteria":{"task_description":"..."}}\'. ' +
240
+ 'For GET/DELETE: becomes query parameters. For POST/PUT/PATCH: becomes the JSON body. ' +
241
+ 'The body is not type-coerced, so write each value as the type the schema declares. ' +
242
+ 'Identifier fields (externalTaskId, correlationId, platformRef, projectRef, publisher) are ' +
243
+ 'strings even when the identifier is all digits: send "4821", not 4821. ' +
244
+ 'Native JSON objects are also accepted for compatibility.'),
245
+ idempotencyKey: z
246
+ .string()
247
+ .max(256)
248
+ .optional()
249
+ .describe('Optional dedup key for POST calls, max 256 characters. Ignored on other methods. ' +
250
+ 'One is generated per call when you omit it, so a single call is already replay-safe. ' +
251
+ 'Pass your own only when you are retrying a call that may have already reached the ' +
252
+ 'Server (a timeout, a dropped connection): reuse the exact key from the first attempt ' +
253
+ 'and the Server returns the original result instead of notarizing the work twice. ' +
254
+ 'A key is bound to method, route, and body, so a retry that changes the body is ' +
255
+ 'rejected with 400 rather than silently replaying the old response.'),
256
+ };
257
+ const VERIFY_ARGS = {
258
+ export: jsonStringField.describe('The audit export as a JSON-encoded string (the response body from ' +
259
+ 'GET /v1/records/{id}/audit-export, JSON.stringify\'d). Native JSON ' +
260
+ 'objects are also accepted for compatibility.'),
261
+ publicKeys: jsonStringField
262
+ .optional()
263
+ .describe('Optional out-of-band signing keys. Accepts any of these as a JSON-encoded ' +
264
+ 'string (or a native object/array): a compact map ' +
265
+ '\'{"key-1":"MCowBQYDK2VwAyEA..."}\' (values are base64 SPKI DER; Ed25519 keys ' +
266
+ 'start "MCowBQYDK2Vw", P-256 keys "MFkwEwYHKoZIzj0"), the list shape ' +
267
+ '\'[{"keyId":"key-1","publicKey":"MCowBQYDK2VwAyEA..."}]\', or the raw ' +
268
+ 'GET /v1/verification-keys response envelope (\'{"data":[...], ...}\'); the ' +
269
+ '.data array is unwrapped automatically, so the agledger_api response can be ' +
270
+ 'passed straight through). Merged over any keys embedded in the export.'),
271
+ agentKeys: jsonStringField
272
+ .optional()
273
+ .describe('Optional Ed25519 public keys of agent certs, as a JSON-encoded array of JWKs ' +
274
+ '\'[{"kty":"OKP","crv":"Ed25519","x":"..."}]\' (the publicKeyJwk each agent sent at cert exchange, also the cnf.jwk claim in its certJws). ' +
275
+ 'An entry whose sealed agent signature names one of these keys by thumbprint has that ' +
276
+ 'signature re-verified offline, and fails CHAIN_AGENT_SIGNATURE_INVALID if it does not verify. ' +
277
+ 'Without it, agent signatures are counted in result.agentSignatures but not checked.'),
278
+ requireKeyId: z
279
+ .string()
280
+ .optional()
281
+ .describe('If set, every entry must reference this keyId. Rejects exports signed by a ' +
282
+ 'retired or unexpected key even if cryptographically valid.'),
283
+ requireOutOfBandKeys: z
284
+ .boolean()
285
+ .optional()
286
+ .describe('High-assurance: refuse keys embedded in the export. An entry whose only key is ' +
287
+ 'export-embedded fails CHAIN_KEY_POLICY_VIOLATION, forcing verification against ' +
288
+ 'keys supplied out of band via publicKeys.'),
289
+ };
147
290
  export class AgledgerMcpServer {
148
291
  mcp;
149
292
  client;
@@ -158,7 +301,12 @@ export class AgledgerMcpServer {
158
301
  throw new Error('No API URL configured. AGLedger is self-hosted, so the MCP server cannot guess your Server: ' +
159
302
  'pass --api-url <url> or set AGLEDGER_API_URL.');
160
303
  }
161
- this.client = new ApiClient(apiUrl, options.apiKey, options.timeoutMs);
304
+ if (Boolean(options.apiKey) === Boolean(options.oidc)) {
305
+ throw new Error('Configure exactly one credential: an API key (--api-key or AGLEDGER_API_KEY) or an OIDC token source ' +
306
+ '(AGLEDGER_OIDC_TOKEN_CMD or AGLEDGER_OIDC_TOKEN_FILE).');
307
+ }
308
+ const credential = options.apiKey ? options.apiKey : new OidcCertCredential(options.oidc);
309
+ this.client = new ApiClient(apiUrl, credential, options.timeoutMs, options.onBehalfOf ? new DelegationSource(options.onBehalfOf) : undefined);
162
310
  this.mcp = new McpServer({ name: 'agledger-mcp-server', version: SERVER_VERSION }, { capabilities: { tools: {}, resources: {} } });
163
311
  this.registerTools();
164
312
  this.registerResources();
@@ -169,7 +317,7 @@ export class AgledgerMcpServer {
169
317
  title: 'Discover AGLedger API',
170
318
  description: 'Returns API health, your identity, available scopes, and a quickstart workflow. ' +
171
319
  'Call this first. The response tells you who you are and what to do next.',
172
- inputSchema: {},
320
+ inputSchema: toolInput(DISCOVER_ARGS),
173
321
  annotations: {
174
322
  readOnlyHint: true,
175
323
  destructiveHint: false,
@@ -182,10 +330,15 @@ export class AgledgerMcpServer {
182
330
  // introspect its own context). No NAMED scope is required, so the list
183
331
  // is empty: a valid API key suffices, but no specific scope gates it.
184
332
  _meta: { requiredScopes: [] },
185
- }, async () => {
333
+ }, async (args) => {
334
+ const refused = unknownArgumentResult('agledger_discover', DISCOVER_ARGS, args);
335
+ if (refused)
336
+ return refused;
186
337
  try {
187
338
  const [health, identity, scopeProfiles] = await Promise.allSettled([
188
- client.request('GET', '/health'),
339
+ // Anonymous, so "is the Server up" stays answerable when the
340
+ // credential is what is broken.
341
+ client.request('GET', '/health', { anonymous: true }),
189
342
  client.request('GET', '/v1/auth/me'),
190
343
  client.request('GET', '/v1/scope-profiles'),
191
344
  ]);
@@ -202,15 +355,28 @@ export class AgledgerMcpServer {
202
355
  result.identity = identity.value.body;
203
356
  }
204
357
  else {
205
- result.identity = {
206
- error: identity.reason instanceof Error
207
- ? identity.reason.message
208
- : String(identity.reason),
209
- };
358
+ const credentialError = credentialErrorResult(identity.reason);
359
+ result.identity = credentialError
360
+ ? credentialError.structuredContent
361
+ : {
362
+ error: identity.reason instanceof Error
363
+ ? identity.reason.message
364
+ : String(identity.reason),
365
+ };
210
366
  }
211
367
  if (scopeProfiles.status === 'fulfilled') {
212
368
  result.scopeProfiles = scopeProfiles.value.body;
213
369
  }
370
+ // Whether POSTs carry an AGLedger-On-Behalf-Of delegation, and from
371
+ // where. The token itself is never shown.
372
+ const delegationOrigin = client.delegationOrigin;
373
+ result.delegation = delegationOrigin
374
+ ? {
375
+ configured: true,
376
+ source: delegationOrigin,
377
+ note: 'Every POST carries an AGLedger-On-Behalf-Of delegation token; the Server seals it as predicate.on_behalf_of on the chain entry.',
378
+ }
379
+ : { configured: false };
214
380
  result.quickstart = QUICKSTART;
215
381
  result.docs = DOCS;
216
382
  return { content: mirrorContent(result), structuredContent: result };
@@ -235,35 +401,14 @@ export class AgledgerMcpServer {
235
401
  'independently, so there are that many current heads and no single answer. ' +
236
402
  'Filter on signed fields with criteria[key]=value, which selects on the same bytes an ' +
237
403
  'auditor verifies offline; metadata[key]=value filters an unsigned annotation instead. ' +
238
- 'If a call fails, read the suggestion field in the error response. ' +
404
+ 'If a call fails, the error says how to recover: recoveryHint on an error from the Server, ' +
405
+ 'suggestion on an error this tool raises itself (a bad argument, a timeout, a credential failure). ' +
239
406
  'For the full API catalog, GET /openapi.json (or read the agledger://openapi resource); ' +
240
407
  'for prose orientation, GET /llms.txt (or read the agledger://llms.txt resource). ' +
241
- 'For GET/DELETE, params become query parameters. For POST/PUT/PATCH, params become the JSON body.',
242
- inputSchema: {
243
- method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']).describe('HTTP method'),
244
- path: z
245
- .string()
246
- .describe('API path starting with / (e.g. /v1/records, /v1/schemas, /v1/records/{id}/completions)'),
247
- params: jsonStringField
248
- .optional()
249
- .describe('Request parameters as a JSON-encoded string, e.g. \'{"type":"notarize-generic-v1","criteria":{"task_description":"..."}}\'. ' +
250
- 'For GET/DELETE: becomes query parameters. For POST/PUT/PATCH: becomes the JSON body. ' +
251
- 'The body is not type-coerced, so write each value as the type the schema declares. ' +
252
- 'Identifier fields (externalTaskId, correlationId, platformRef, projectRef, publisher) are ' +
253
- 'strings even when the identifier is all digits: send "4821", not 4821. ' +
254
- 'Native JSON objects are also accepted for compatibility.'),
255
- idempotencyKey: z
256
- .string()
257
- .max(256)
258
- .optional()
259
- .describe('Optional dedup key for POST calls, max 256 characters. Ignored on other methods. ' +
260
- 'One is generated per call when you omit it, so a single call is already replay-safe. ' +
261
- 'Pass your own only when you are retrying a call that may have already reached the ' +
262
- 'Server (a timeout, a dropped connection): reuse the exact key from the first attempt ' +
263
- 'and the Server returns the original result instead of notarizing the work twice. ' +
264
- 'A key is bound to method, route, and body, so a retry that changes the body is ' +
265
- 'rejected with 400 rather than silently replaying the old response.'),
266
- },
408
+ 'For GET/DELETE, params become query parameters. For POST/PUT/PATCH, params become the JSON body. ' +
409
+ 'When agledger_discover reports a delegation, every POST carries the AGLedger-On-Behalf-Of header ' +
410
+ 'the operator configured; it is not something you pass.',
411
+ inputSchema: toolInput(API_ARGS),
267
412
  annotations: {
268
413
  readOnlyHint: false,
269
414
  // This tool dispatches to any route, including DELETE/PATCH, so it can
@@ -281,6 +426,9 @@ export class AgledgerMcpServer {
281
426
  // single scope here would be dishonest. Callers see the real missing
282
427
  // scopes in the API's 403 response (missingScopes), forwarded verbatim.
283
428
  }, async (args) => {
429
+ const refused = unknownArgumentResult('agledger_api', API_ARGS, args, 'The request body (POST/PUT/PATCH) and the query string (GET/DELETE) both go in `params`.');
430
+ if (refused)
431
+ return refused;
284
432
  try {
285
433
  const { method, path, params, idempotencyKey } = args;
286
434
  if (!path.startsWith('/')) {
@@ -333,6 +481,9 @@ export class AgledgerMcpServer {
333
481
  };
334
482
  }
335
483
  catch (err) {
484
+ const credentialError = credentialErrorResult(err);
485
+ if (credentialError)
486
+ return credentialError;
336
487
  if (err instanceof DOMException && err.name === 'AbortError') {
337
488
  return errorResult('The API did not respond in time. Retry the same request.', 'TIMEOUT', 'Retry the same request. Increase --timeout if your instance is slow to respond.');
338
489
  }
@@ -352,39 +503,10 @@ export class AgledgerMcpServer {
352
503
  '(GET /v1/verification-keys or /.well-known/scitt-keys) rather than trusting the ' +
353
504
  'export\'s embedded keys; result.keyProvenance reports out-of-band vs embedded key use. ' +
354
505
  'On failure, brokenAt pinpoints the first entry that failed and its canonical code ' +
355
- '(CHAIN_HASH_MISMATCH, CHAIN_LINK_BROKEN, CHAIN_GENESIS_INVALID, CHAIN_COSE_DECODE_FAILED, ' +
356
- 'CHAIN_COSE_HEADER_MISMATCH, CHAIN_PAYLOAD_BINDING_MISMATCH, CHAIN_SIGNATURE_INVALID, ' +
357
- 'CHAIN_SIGNATURE_MISSING_KEY, CHAIN_KEY_POLICY_VIOLATION, CHAIN_ALG_MISMATCH, ' +
358
- 'CHAIN_SIGNING_KEY_DRIFT, CHAIN_UNSUPPORTED_ALGORITHM (this build cannot compute the ' +
359
- 'key\'s algorithm; upgrade, never a pass), CHAIN_POSITION_GAP, CHAIN_MALFORMED_ENTRY, ' +
360
- 'UNSUPPORTED_FORMAT, CHAIN_EMPTY). Obtain the export via agledger_api with method=GET, path=/v1/records/{id}/audit-export. ' +
506
+ `(${EXPORT_FAILURE_CODES.join(', ')}); CHAIN_UNSUPPORTED_ALGORITHM means this build ` +
507
+ 'could not compute the key\'s algorithm: upgrade, and never read it as a pass. Obtain the export via agledger_api with method=GET, path=/v1/records/{id}/audit-export. ' +
361
508
  'For the raw COSE_Sign1 stream, use path=/v1/records/{id}/attestation.',
362
- inputSchema: {
363
- export: jsonStringField.describe('The audit export as a JSON-encoded string (the response body from ' +
364
- 'GET /v1/records/{id}/audit-export, JSON.stringify\'d). Native JSON ' +
365
- 'objects are also accepted for compatibility.'),
366
- publicKeys: jsonStringField
367
- .optional()
368
- .describe('Optional out-of-band signing keys. Accepts any of these as a JSON-encoded ' +
369
- 'string (or a native object/array): a compact map ' +
370
- '\'{"key-1":"MCowBQYDK2VwAyEA..."}\' (values are base64 SPKI DER; Ed25519 keys ' +
371
- 'start "MCowBQYDK2Vw", P-256 keys "MFkwEwYHKoZIzj0"), the list shape ' +
372
- '\'[{"keyId":"key-1","publicKey":"MCowBQYDK2VwAyEA..."}]\', or the raw ' +
373
- 'GET /v1/verification-keys response envelope (\'{"data":[...], ...}\'); the ' +
374
- '.data array is unwrapped automatically, so the agledger_api response can be ' +
375
- 'passed straight through). Merged over any keys embedded in the export.'),
376
- requireKeyId: z
377
- .string()
378
- .optional()
379
- .describe('If set, every entry must reference this keyId. Rejects exports signed by a ' +
380
- 'retired or unexpected key even if cryptographically valid.'),
381
- requireOutOfBandKeys: z
382
- .boolean()
383
- .optional()
384
- .describe('High-assurance: refuse keys embedded in the export. An entry whose only key is ' +
385
- 'export-embedded fails CHAIN_KEY_POLICY_VIOLATION, forcing verification against ' +
386
- 'keys supplied out of band via publicKeys.'),
387
- },
509
+ inputSchema: toolInput(VERIFY_ARGS),
388
510
  annotations: {
389
511
  readOnlyHint: true,
390
512
  destructiveHint: false,
@@ -396,8 +518,11 @@ export class AgledgerMcpServer {
396
518
  // required to invoke it.
397
519
  _meta: { requiredScopes: [] },
398
520
  }, async (args) => {
521
+ const refused = unknownArgumentResult('agledger_verify', VERIFY_ARGS, args);
522
+ if (refused)
523
+ return refused;
399
524
  try {
400
- const { export: exportRaw, publicKeys: publicKeysRaw, requireKeyId, requireOutOfBandKeys } = args;
525
+ const { export: exportRaw, publicKeys: publicKeysRaw, agentKeys: agentKeysRaw, requireKeyId, requireOutOfBandKeys, } = args;
401
526
  const decodedExport = parseJsonObject(exportRaw, 'export');
402
527
  if (!decodedExport.ok)
403
528
  return decodedExport.error;
@@ -412,8 +537,19 @@ export class AgledgerMcpServer {
412
537
  return decodedKeys.error;
413
538
  publicKeys = unwrapVerificationKeys(decodedKeys.value);
414
539
  }
540
+ let agentKeys;
541
+ if (agentKeysRaw !== undefined && agentKeysRaw !== '') {
542
+ const decodedAgentKeys = parseJsonObjectOrArray(agentKeysRaw, 'agentKeys');
543
+ if (!decodedAgentKeys.ok)
544
+ return decodedAgentKeys.error;
545
+ if (!Array.isArray(decodedAgentKeys.value)) {
546
+ return errorResult('Argument `agentKeys` must decode to a JSON array of Ed25519 JWKs.', 'INVALID_JSON', 'Pass `agentKeys` as \'[{"kty":"OKP","crv":"Ed25519","x":"..."}]\'.');
547
+ }
548
+ agentKeys = decodedAgentKeys.value;
549
+ }
415
550
  const result = verifyAuditExport(exportData, {
416
551
  publicKeys,
552
+ agentKeys,
417
553
  requireKeyId,
418
554
  requireOutOfBandKeys,
419
555
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agledger/mcp-server",
3
- "version": "2.10.1",
3
+ "version": "2.11.0",
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",
@@ -55,7 +55,7 @@
55
55
  "prepublishOnly": "npm run build && npm run lint:pkg"
56
56
  },
57
57
  "dependencies": {
58
- "@agledger/verify-core": "^1.4.0",
58
+ "@agledger/verify-core": "^1.5.0",
59
59
  "@modelcontextprotocol/sdk": "^1.30.0",
60
60
  "zod": "^3.25.0 || ^4.0.0"
61
61
  },