agent-envelope-mcp 1.1.1 → 1.2.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/README.md +2 -1
- package/package.json +13 -13
- package/server.json +2 -2
- package/src/server.js +61 -6
- package/tests/server.test.js +116 -3
package/README.md
CHANGED
|
@@ -57,6 +57,7 @@ verification and hosted read/query tools.
|
|
|
57
57
|
| `ae_get_delegate` | Hosted governance | `AE_API_KEY` or bearer | Fetches one active hosted delegate |
|
|
58
58
|
| `ae_check_legitimacy` | Hosted governance | `AE_API_KEY` or bearer | Normalizes legitimacy state into a decision |
|
|
59
59
|
| `ae_mint` | Hosted governance | `AE_API_KEY` or bearer | Governed mint request; returns receipt, not private material. Omitted when `AE_TOOLS=readonly` |
|
|
60
|
+
| `ae_register_delegated_action` | Hosted governance | `AE_API_KEY` or bearer | Registers the public action record after an accepted mint. Omitted when `AE_TOOLS=readonly` |
|
|
60
61
|
|
|
61
62
|
Most tools return both readable MCP `content` and machine-readable
|
|
62
63
|
`structuredContent`.
|
|
@@ -252,7 +253,7 @@ await startHttp({ port: 8787, host: "127.0.0.1", path: "/mcp" });
|
|
|
252
253
|
## Security Notes
|
|
253
254
|
|
|
254
255
|
- Verification-only tools are annotated as read-only.
|
|
255
|
-
- `ae_mint`
|
|
256
|
+
- `ae_mint` and `ae_register_delegated_action` are annotated as governed, non-idempotent hosted actions.
|
|
256
257
|
- API keys meter service access; signatures prove authority.
|
|
257
258
|
- The runtime keeps secrets. The model asks for authority; AgentEnvelope returns
|
|
258
259
|
the decision.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-envelope-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"mcpName": "io.github.BlackBoxEngineering/agent-envelope-mcp",
|
|
5
5
|
"description": "MCP adapter for AgentEnvelope: sovereign verification, hosted decisions, delegates, legitimacy, and mint receipts.",
|
|
6
6
|
"type": "module",
|
|
@@ -10,26 +10,26 @@
|
|
|
10
10
|
"exports": {
|
|
11
11
|
".": "./src/server.js"
|
|
12
12
|
},
|
|
13
|
-
"files": [
|
|
14
|
-
"bin",
|
|
15
|
-
"src",
|
|
16
|
-
"tests",
|
|
17
|
-
"server.json",
|
|
18
|
-
"README.md",
|
|
13
|
+
"files": [
|
|
14
|
+
"bin",
|
|
15
|
+
"src",
|
|
16
|
+
"tests",
|
|
17
|
+
"server.json",
|
|
18
|
+
"README.md",
|
|
19
19
|
"LICENSE",
|
|
20
20
|
"NOTICE"
|
|
21
21
|
],
|
|
22
|
-
"scripts": {
|
|
23
|
-
"test": "node --test tests/*.test.js",
|
|
24
|
-
"start": "node bin/agent-envelope-mcp.js",
|
|
25
|
-
"start:http": "node bin/agent-envelope-mcp.js --http --port 8787"
|
|
26
|
-
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "node --test tests/*.test.js",
|
|
24
|
+
"start": "node bin/agent-envelope-mcp.js",
|
|
25
|
+
"start:http": "node bin/agent-envelope-mcp.js --http --port 8787"
|
|
26
|
+
},
|
|
27
27
|
"engines": {
|
|
28
28
|
"node": ">=18"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
32
|
-
"agent-envelope-sdk": "^1.4.
|
|
32
|
+
"agent-envelope-sdk": "^1.4.6",
|
|
33
33
|
"zod": "^4.4.3"
|
|
34
34
|
},
|
|
35
35
|
"keywords": [
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/BlackBoxEngineering/agent-envelope-mcp",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.2.0",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "agent-envelope-mcp",
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.2.0",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|
package/src/server.js
CHANGED
|
@@ -18,7 +18,7 @@ import { AgentEnvelopeClient } from 'agent-envelope-sdk/client';
|
|
|
18
18
|
import { verifyAction as verifyActionSovereign, verifyRecord as verifyRecordSovereign } from 'agent-envelope-sdk';
|
|
19
19
|
|
|
20
20
|
const HOSTED_BASE_URL = process.env.AE_API_BASE_URL?.trim() || 'https://jemdjwteae.execute-api.us-east-1.amazonaws.com/v1';
|
|
21
|
-
const SERVER_VERSION = '1.
|
|
21
|
+
const SERVER_VERSION = '1.2.0';
|
|
22
22
|
const NEEDS_KEY =
|
|
23
23
|
'AE_API_KEY is not set. This is a hosted-governance tool; set the portal-issued API key to use it. Sovereign signature and record verification need no key.';
|
|
24
24
|
const TOOLS_MODE = process.env.AE_TOOLS?.trim().toLowerCase() || 'all';
|
|
@@ -67,6 +67,25 @@ function isPlainObject(value) {
|
|
|
67
67
|
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
function unwrapProxyResponse(value) {
|
|
71
|
+
if (!isPlainObject(value) || !Number.isInteger(value.statusCode) || !('body' in value)) return value;
|
|
72
|
+
let body = value.body;
|
|
73
|
+
if (typeof body === 'string') {
|
|
74
|
+
try {
|
|
75
|
+
body = JSON.parse(body);
|
|
76
|
+
} catch {
|
|
77
|
+
body = { message: body };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (value.statusCode >= 400) {
|
|
81
|
+
const error = new Error(body?.message || body?.error || `AgentEnvelope API error ${value.statusCode}`);
|
|
82
|
+
error.status = value.statusCode;
|
|
83
|
+
error.body = body;
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
return body;
|
|
87
|
+
}
|
|
88
|
+
|
|
70
89
|
function jsonByteLength(value) {
|
|
71
90
|
try {
|
|
72
91
|
return encoder.encode(JSON.stringify(value)).length;
|
|
@@ -107,10 +126,11 @@ function fail(message, details) {
|
|
|
107
126
|
}
|
|
108
127
|
|
|
109
128
|
function hostedResult(value, fallback) {
|
|
110
|
-
|
|
111
|
-
|
|
129
|
+
const normalized = unwrapProxyResponse(value);
|
|
130
|
+
if (normalized && typeof normalized === 'object' && !Array.isArray(normalized) && 'error' in normalized) {
|
|
131
|
+
return fail(`${fallback}: ${String(normalized.error)}`, normalized);
|
|
112
132
|
}
|
|
113
|
-
return ok(
|
|
133
|
+
return ok(normalized);
|
|
114
134
|
}
|
|
115
135
|
|
|
116
136
|
function errorBody(err) {
|
|
@@ -219,8 +239,18 @@ const publicActionRecordSchema = z.object({
|
|
|
219
239
|
agentAddress: addressSchema,
|
|
220
240
|
status: z.string().min(1).max(32),
|
|
221
241
|
domain: z.object({
|
|
222
|
-
|
|
242
|
+
domainInfo: z.object({
|
|
243
|
+
type: z.literal('agentenvelope.domainInfo'),
|
|
244
|
+
version: z.literal(1),
|
|
245
|
+
namespace: z.string().min(1).max(128),
|
|
246
|
+
domainId: z.string().min(1).max(128),
|
|
247
|
+
kind: z.string().min(1).max(128),
|
|
248
|
+
}).passthrough(),
|
|
249
|
+
canonicalDomainInfo: z.string().min(1).max(4096),
|
|
223
250
|
domainHash: hashSchema,
|
|
251
|
+
domainAddress: addressSchema,
|
|
252
|
+
domainFingerprint: z.string().min(1).max(128),
|
|
253
|
+
createdAt: z.string().min(1).max(64),
|
|
224
254
|
}).passthrough(),
|
|
225
255
|
actionEnvelope: z.object({
|
|
226
256
|
actionIndex: z.number().int().nonnegative(),
|
|
@@ -351,7 +381,7 @@ export function createServer() {
|
|
|
351
381
|
const client = governanceClient(extra);
|
|
352
382
|
if (!client) return fail(NEEDS_KEY);
|
|
353
383
|
try {
|
|
354
|
-
const report = await client.verifyAction(input);
|
|
384
|
+
const report = unwrapProxyResponse(await client.verifyAction(input));
|
|
355
385
|
return ok(decisionFromReport(report, input));
|
|
356
386
|
} catch (err) {
|
|
357
387
|
const body = errorBody(err);
|
|
@@ -451,6 +481,31 @@ export function createServer() {
|
|
|
451
481
|
}
|
|
452
482
|
},
|
|
453
483
|
);
|
|
484
|
+
|
|
485
|
+
server.registerTool(
|
|
486
|
+
'ae_register_delegated_action',
|
|
487
|
+
{
|
|
488
|
+
title: 'Register delegated action record',
|
|
489
|
+
description:
|
|
490
|
+
'Publish a verifier-safe public action record after a successful hosted mint. The hosted service confirms the delegate, signed request, mint nonce, record metadata, plan limits, and legitimacy before registration.',
|
|
491
|
+
annotations: governedHosted,
|
|
492
|
+
inputSchema: {
|
|
493
|
+
record: publicActionRecordSchema.describe('The public action record derived from the minted capability'),
|
|
494
|
+
request: mintObjectSchema.describe('The same signed MintRequest accepted by ae_mint'),
|
|
495
|
+
delegateId: delegateIdSchema.describe('The hosted delegate used for the mint'),
|
|
496
|
+
},
|
|
497
|
+
},
|
|
498
|
+
async ({ record, request, delegateId }, extra) => {
|
|
499
|
+
try {
|
|
500
|
+
return hostedResult(await hostedJson('/sovereign/agents/register-delegated', {
|
|
501
|
+
method: 'POST',
|
|
502
|
+
body: JSON.stringify({ record, request, delegateId }),
|
|
503
|
+
}, extra), 'delegated record registration failed');
|
|
504
|
+
} catch (err) {
|
|
505
|
+
return fail(err instanceof Error ? err.message : 'delegated record registration failed', errorBody(err));
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
);
|
|
454
509
|
}
|
|
455
510
|
|
|
456
511
|
return server;
|
package/tests/server.test.js
CHANGED
|
@@ -2,7 +2,9 @@ import assert from 'node:assert/strict';
|
|
|
2
2
|
import { execFileSync } from 'node:child_process';
|
|
3
3
|
import test from 'node:test';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import {
|
|
5
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
6
|
+
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
|
|
7
|
+
import { createServer, decisionFromReport } from '../src/server.js';
|
|
6
8
|
|
|
7
9
|
const projectRoot = fileURLToPath(new URL('..', import.meta.url));
|
|
8
10
|
|
|
@@ -23,11 +25,122 @@ function spawnedToolNames(env) {
|
|
|
23
25
|
|
|
24
26
|
test('registers mint tool by default', () => {
|
|
25
27
|
const { AE_TOOLS: _aeTools, ...env } = process.env;
|
|
26
|
-
|
|
28
|
+
const names = spawnedToolNames(env);
|
|
29
|
+
assert.ok(names.includes('ae_mint'));
|
|
30
|
+
assert.ok(names.includes('ae_register_delegated_action'));
|
|
27
31
|
});
|
|
28
32
|
|
|
29
33
|
test('AE_TOOLS=readonly omits mint tool', () => {
|
|
30
|
-
|
|
34
|
+
const names = spawnedToolNames({ ...process.env, AE_TOOLS: 'readonly' });
|
|
35
|
+
assert.equal(names.includes('ae_mint'), false);
|
|
36
|
+
assert.equal(names.includes('ae_register_delegated_action'), false);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('delegated action registration uses the hosted registration route', async () => {
|
|
40
|
+
const previousKey = process.env.AE_API_KEY;
|
|
41
|
+
const previousFetch = globalThis.fetch;
|
|
42
|
+
let request;
|
|
43
|
+
process.env.AE_API_KEY = 'test-api-key';
|
|
44
|
+
globalThis.fetch = async (url, init) => {
|
|
45
|
+
request = { url, init };
|
|
46
|
+
return new Response(JSON.stringify({
|
|
47
|
+
statusCode: 201,
|
|
48
|
+
headers: { 'content-type': 'application/json' },
|
|
49
|
+
body: JSON.stringify({ recordId: 'ae-action-test' }),
|
|
50
|
+
}), {
|
|
51
|
+
status: 200,
|
|
52
|
+
headers: { 'content-type': 'application/json' },
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
const server = createServer();
|
|
58
|
+
const result = await server._registeredTools.ae_register_delegated_action.handler({
|
|
59
|
+
record: { recordId: 'ae-action-test' },
|
|
60
|
+
request: { requestId: 'request-test' },
|
|
61
|
+
delegateId: 'ae-delegate-test0001',
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
assert.equal(result.isError, undefined);
|
|
65
|
+
assert.equal(result.structuredContent.recordId, 'ae-action-test');
|
|
66
|
+
assert.ok(request.url.endsWith('/sovereign/agents/register-delegated'));
|
|
67
|
+
assert.equal(request.init.headers['X-Api-Key'], 'test-api-key');
|
|
68
|
+
assert.deepEqual(JSON.parse(request.init.body), {
|
|
69
|
+
record: { recordId: 'ae-action-test' },
|
|
70
|
+
request: { requestId: 'request-test' },
|
|
71
|
+
delegateId: 'ae-delegate-test0001',
|
|
72
|
+
});
|
|
73
|
+
} finally {
|
|
74
|
+
globalThis.fetch = previousFetch;
|
|
75
|
+
if (previousKey === undefined) delete process.env.AE_API_KEY;
|
|
76
|
+
else process.env.AE_API_KEY = previousKey;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('delegated action registration accepts the canonical domain projection over MCP', async () => {
|
|
81
|
+
const previousKey = process.env.AE_API_KEY;
|
|
82
|
+
const previousFetch = globalThis.fetch;
|
|
83
|
+
let called = false;
|
|
84
|
+
process.env.AE_API_KEY = 'test-api-key';
|
|
85
|
+
globalThis.fetch = async () => {
|
|
86
|
+
called = true;
|
|
87
|
+
return new Response(JSON.stringify({ recordId: 'ae-action-test' }), {
|
|
88
|
+
status: 200,
|
|
89
|
+
headers: { 'content-type': 'application/json' },
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
const server = createServer();
|
|
93
|
+
const client = new Client({ name: 'domain-projection-test', version: '1.0.0' });
|
|
94
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
await server.connect(serverTransport);
|
|
98
|
+
await client.connect(clientTransport);
|
|
99
|
+
const domainHash = `0x${'1'.repeat(64)}`;
|
|
100
|
+
const domainAddress = `0x${'2'.repeat(40)}`;
|
|
101
|
+
const actionEnvelopeHash = `0x${'3'.repeat(64)}`;
|
|
102
|
+
const result = await client.callTool({
|
|
103
|
+
name: 'ae_register_delegated_action',
|
|
104
|
+
arguments: {
|
|
105
|
+
record: {
|
|
106
|
+
type: 'agentenvelope.publicActionRecord',
|
|
107
|
+
version: 1,
|
|
108
|
+
recordId: 'ae-action-test',
|
|
109
|
+
agentId: 'mobile:device-01:0',
|
|
110
|
+
agentAddress: `0x${'4'.repeat(40)}`,
|
|
111
|
+
status: 'active',
|
|
112
|
+
domain: {
|
|
113
|
+
domainInfo: {
|
|
114
|
+
type: 'agentenvelope.domainInfo',
|
|
115
|
+
version: 1,
|
|
116
|
+
namespace: 'mobile-testing',
|
|
117
|
+
domainId: 'hmgcc-mobile-mimic',
|
|
118
|
+
kind: 'device',
|
|
119
|
+
},
|
|
120
|
+
canonicalDomainInfo: '{}',
|
|
121
|
+
domainHash,
|
|
122
|
+
domainAddress,
|
|
123
|
+
domainFingerprint: 'ae-domain-test',
|
|
124
|
+
createdAt: '2026-09-26T15:51:06.679Z',
|
|
125
|
+
},
|
|
126
|
+
actionEnvelope: { actionIndex: 0 },
|
|
127
|
+
actionEnvelopeHash,
|
|
128
|
+
expiry: null,
|
|
129
|
+
},
|
|
130
|
+
request: { requestId: 'request-test' },
|
|
131
|
+
delegateId: 'ae-delegate-test0001',
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
assert.equal(result.isError, undefined);
|
|
136
|
+
assert.equal(called, true);
|
|
137
|
+
} finally {
|
|
138
|
+
await client.close();
|
|
139
|
+
await server.close();
|
|
140
|
+
globalThis.fetch = previousFetch;
|
|
141
|
+
if (previousKey === undefined) delete process.env.AE_API_KEY;
|
|
142
|
+
else process.env.AE_API_KEY = previousKey;
|
|
143
|
+
}
|
|
31
144
|
});
|
|
32
145
|
|
|
33
146
|
test('decisionFromReport fails closed when operation is requested but absent from report envelope', () => {
|