agent-envelope-mcp 1.0.4 → 1.0.6

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 CHANGED
@@ -3,8 +3,8 @@
3
3
  The neutral authority layer for action-performing systems, as an [MCP](https://modelcontextprotocol.io) server.
4
4
 
5
5
  Any MCP client — Claude, an OpenAI agent, LangChain, CrewAI, a custom runtime —
6
- can call these tools to **check and issue delegated action authority** without
7
- building its own policy engine, audit log, or verification stack. AgentEnvelope
6
+ can call these tools to **check delegated action authority** without
7
+ building its own verification stack. AgentEnvelope
8
8
  is owned by no framework, so every framework can embed it.
9
9
 
10
10
  An AgentEnvelope "agent" is a bounded action identity: a named actor, operation,
@@ -18,8 +18,8 @@ instruction.
18
18
  npx agent-envelope-mcp
19
19
  ```
20
20
 
21
- It speaks MCP over stdio. No API key is needed to start, or to use the sovereign
22
- verifier — only the hosted-governance tools require `AE_API_KEY`.
21
+ It speaks MCP over stdio. No API key is needed to start, or to use sovereign
22
+ signature/record verification — only the hosted-governance tools require `AE_API_KEY`.
23
23
 
24
24
  ## Wire it into an MCP client
25
25
 
@@ -42,17 +42,24 @@ environment (only needed for hosted-governance tools):
42
42
 
43
43
  | Tool | Mode | Credential |
44
44
  |---|---|---|
45
- | `ae_verify_sovereign` | Sovereign | none — offline, always free |
45
+ | `ae_verify_sovereign` | Sovereign signature check | none — offline, always free |
46
+ | `ae_verify_sovereign_record` | Sovereign public-record check | none — offline, always free |
46
47
  | `ae_get_agent` | Hosted governance | `AE_API_KEY` |
47
48
  | `ae_verify_action` | Hosted governance | `AE_API_KEY` |
48
49
  | `ae_mint` | Hosted governance | `AE_API_KEY` |
49
50
 
50
- - **`ae_verify_sovereign`** — verify a signed message against a known agent
51
- address. Pure crypto: no vault, no key, no network. Verification is always free.
51
+ - **`ae_verify_sovereign`** — verify a signed message against a known agent
52
+ address. Pure crypto: no vault, no key, no network. This is a signature-only
53
+ check; it does not check action-envelope scope, expiry, usage limits, or hosted
54
+ record status.
55
+ - **`ae_verify_sovereign_record`** — verify a signed action against a public
56
+ action record. Checks record status, action index, signature/address match,
57
+ optional expected envelope hash, and time decay without a network call.
52
58
  - **`ae_get_agent`** — fetch the hosted public record for an agent id.
53
59
  - **`ae_verify_action`** — verify a signed action against the hosted public record.
54
60
  - **`ae_mint`** — verify a `MintDelegate` and signed `MintRequest` through hosted
55
- governance, returning a mint receipt. This is a governed action.
61
+ governance, returning a mint receipt. It does not return private capability
62
+ material. This is a governed action.
56
63
 
57
64
  The sovereign verifier needs no account and no key. The hosted-governance tools
58
65
  are the governed surface a framework offloads rather than rebuilds. API keys
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "agent-envelope-mcp",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "mcpName": "io.github.BlackBoxEngineering/agent-envelope-mcp",
5
- "description": "Neutral MCP server for AgentEnvelope delegated action authority: sovereign verify plus hosted-governance verify, lookup, and mint.",
5
+ "description": "Neutral MCP server for AgentEnvelope delegated action authority: sovereign signature/record verification plus hosted-governance verify, lookup, and mint receipts.",
6
6
  "type": "module",
7
7
  "bin": {
8
8
  "agent-envelope-mcp": "bin/agent-envelope-mcp.js"
@@ -11,10 +11,10 @@
11
11
  ".": "./src/server.js"
12
12
  },
13
13
  "files": [
14
- "bin",
15
- "src",
16
- "server.json",
17
- "README.md",
14
+ "bin",
15
+ "src",
16
+ "server.json",
17
+ "README.md",
18
18
  "LICENSE",
19
19
  "NOTICE"
20
20
  ],
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@modelcontextprotocol/sdk": "^1.30.0",
29
- "agent-envelope-sdk": "^1.3.2",
29
+ "agent-envelope-sdk": "latest",
30
30
  "zod": "^4.4.3"
31
31
  },
32
32
  "keywords": [
package/server.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
3
  "name": "io.github.BlackBoxEngineering/agent-envelope-mcp",
4
- "description": "Neutral MCP server for AgentEnvelope delegated action authority: sovereign verify + hosted-governance verify, lookup, and mint.",
4
+ "description": "Neutral MCP server for AgentEnvelope delegated action authority: sovereign signature/record verification plus hosted-governance verify, lookup, and mint receipts.",
5
5
  "repository": {
6
6
  "url": "https://github.com/BlackBoxEngineering/agent-envelope-mcp",
7
7
  "source": "github"
8
8
  },
9
- "version": "1.0.4",
9
+ "version": "1.0.5",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "agent-envelope-mcp",
14
- "version": "1.0.4",
14
+ "version": "1.0.5",
15
15
  "transport": {
16
16
  "type": "stdio"
17
17
  },
18
18
  "environmentVariables": [
19
19
  {
20
20
  "name": "AE_API_KEY",
21
- "description": "Portal-issued API key. Required only for hosted-governance tools (ae_get_agent, ae_verify_action, ae_mint). Sovereign verification needs no key.",
21
+ "description": "Portal-issued API key. Required only for hosted-governance tools (ae_get_agent, ae_verify_action, ae_mint). Sovereign signature and record verification need no key.",
22
22
  "isRequired": false,
23
23
  "isSecret": true,
24
24
  "format": "string"
package/src/server.js CHANGED
@@ -9,7 +9,8 @@
9
9
  * Two tiers of tools, matching the two modes:
10
10
  *
11
11
  * Sovereign (free, offline, no credential):
12
- * - ae_verify_sovereign verify a signature against a known agent address
12
+ * - ae_verify_sovereign verify a signature against a known agent address
13
+ * - ae_verify_sovereign_record verify a signature against a public action record
13
14
  *
14
15
  * Hosted governance (requires AE_API_KEY):
15
16
  * - ae_get_agent look up a registered agent's public record
@@ -23,57 +24,139 @@
23
24
 
24
25
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
25
26
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
26
- import { z } from 'zod';
27
- import { AgentEnvelopeClient } from 'agent-envelope-sdk/client';
28
- import { verifyAction as verifyActionSovereign } from 'agent-envelope-sdk';
29
-
30
- // ─── Credential handling (fail-closed, never process.exit inside a server) ────
31
-
32
- function getApiKey() {
33
- return process.env.AE_API_KEY?.trim() || null;
34
- }
35
-
27
+ import { z } from 'zod';
28
+ import { AgentEnvelopeClient } from 'agent-envelope-sdk/client';
29
+ import { verifyAction as verifyActionSovereign, verifyRecord as verifyRecordSovereign } from 'agent-envelope-sdk';
30
+
31
+ // ─── Credential handling (fail-closed, never process.exit inside a server) ────
32
+
33
+ function getApiKey() {
34
+ return process.env.AE_API_KEY?.trim() || null;
35
+ }
36
+
36
37
  let cachedClient = null;
38
+ let cachedApiKey = null;
37
39
  function governanceClient() {
38
40
  const apiKey = getApiKey();
39
41
  if (!apiKey) return null;
40
- if (!cachedClient) cachedClient = new AgentEnvelopeClient({ apiKey });
42
+ if (!cachedClient || cachedApiKey !== apiKey) {
43
+ cachedClient = new AgentEnvelopeClient({ apiKey });
44
+ cachedApiKey = apiKey;
45
+ }
41
46
  return cachedClient;
42
47
  }
43
-
44
- const ok = (value) => ({ content: [{ type: 'text', text: JSON.stringify(value, null, 2) }] });
45
- const fail = (message) => ({ content: [{ type: 'text', text: message }], isError: true });
48
+
49
+ const ok = (value) => ({ content: [{ type: 'text', text: JSON.stringify(value, null, 2) }] });
50
+ const fail = (message) => ({ content: [{ type: 'text', text: message }], isError: true });
51
+ const hostedResult = (value, fallback) => {
52
+ if (value && typeof value === 'object' && !Array.isArray(value) && 'error' in value) {
53
+ return fail(`${fallback}: ${String(value.error)}`);
54
+ }
55
+ return ok(value);
56
+ };
46
57
  const NEEDS_KEY =
47
- 'AE_API_KEY is not set. This is a hosted-governance tool; set the portal-issued API key to use it. (Sovereign verification needs no key — use ae_verify_sovereign.)';
58
+ '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.';
59
+
60
+ const encoder = new TextEncoder();
61
+ const MAX_SIGNED_MESSAGE_BYTES = 64 * 1024;
62
+ const MAX_RECORD_BYTES = 256 * 1024;
63
+ const MAX_MINT_OBJECT_BYTES = 256 * 1024;
64
+ const AGENT_ID = /^[a-zA-Z0-9_:-]{1,128}$/;
65
+ const ADDRESS = /^0x[a-fA-F0-9]{40}$/;
66
+ const HASH = /^0x[a-fA-F0-9]{64}$/;
67
+ const SIGNATURE = /^0x[a-fA-F0-9]{130}$/;
68
+
69
+ function jsonByteLength(value) {
70
+ try {
71
+ return encoder.encode(JSON.stringify(value)).length;
72
+ } catch {
73
+ return Infinity;
74
+ }
75
+ }
76
+
77
+ function jsonWithin(maxBytes, label) {
78
+ return z.unknown().refine((value) => jsonByteLength(value) <= maxBytes, {
79
+ message: `${label} exceeds ${maxBytes} JSON bytes`,
80
+ });
81
+ }
82
+
83
+ const signedMessageSchema = jsonWithin(MAX_SIGNED_MESSAGE_BYTES, 'signed message');
84
+ const mintObjectSchema = jsonWithin(MAX_MINT_OBJECT_BYTES, 'mint object');
85
+ const agentIdSchema = z.string().regex(AGENT_ID, 'agentId must be 1-128 characters: letters, numbers, underscore, colon, or hyphen');
86
+ const addressSchema = z.string().regex(ADDRESS, 'address must be a 0x-prefixed 20-byte hex address');
87
+ const hashSchema = z.string().regex(HASH, 'hash must be a 0x-prefixed 32-byte hex value');
88
+ const signatureSchema = z.string().regex(SIGNATURE, 'signature must be a 0x-prefixed 65-byte recoverable signature');
89
+ const publicActionRecordSchema = z.object({
90
+ type: z.literal('agentenvelope.publicActionRecord'),
91
+ version: z.literal(1),
92
+ recordId: z.string().min(1).max(256),
93
+ agentId: agentIdSchema,
94
+ agentAddress: addressSchema,
95
+ status: z.string().min(1).max(32),
96
+ domain: z.object({
97
+ domainId: z.string().min(1).max(128),
98
+ domainHash: hashSchema,
99
+ }).passthrough(),
100
+ actionEnvelope: z.object({
101
+ actionIndex: z.number().int().nonnegative(),
102
+ }).passthrough(),
103
+ actionEnvelopeHash: hashSchema,
104
+ expiry: z.string().nullable().optional(),
105
+ }).passthrough().refine((value) => jsonByteLength(value) <= MAX_RECORD_BYTES, {
106
+ message: `public action record exceeds ${MAX_RECORD_BYTES} JSON bytes`,
107
+ });
48
108
 
49
109
  /**
50
110
  * Build a fully configured AgentEnvelope MCP server (not yet connected to a
51
111
  * transport). Exported so hosts can mount it on their own transport.
52
112
  */
53
113
  export function createServer() {
54
- const server = new McpServer({ name: 'agent-envelope', version: '1.0.4' });
114
+ const server = new McpServer({ name: 'agent-envelope', version: '1.0.6' });
55
115
 
56
116
  // Sovereign — free, offline, no credential.
57
- server.registerTool(
58
- 'ae_verify_sovereign',
59
- {
60
- title: 'Verify (sovereign, offline)',
61
- description:
62
- 'Verify a signed message against a known agent address. Pure crypto, no vault, no API key, no network. Verification is always free.',
63
- inputSchema: {
64
- message: z.record(z.string(), z.unknown()).describe('The exact signed message object'),
65
- signature: z.string().describe('0x-prefixed 65-byte signature'),
66
- expectedAddress: z.string().describe("The agent's 0x address to check against"),
67
- },
68
- },
69
- async ({ message, signature, expectedAddress }) => {
117
+ server.registerTool(
118
+ 'ae_verify_sovereign',
119
+ {
120
+ title: 'Verify signature (sovereign, offline)',
121
+ description:
122
+ 'Signature-only check: verify a signed message against a known agent address. Pure crypto, no vault, no API key, no network. This does not check an action envelope, scope, expiry, or usage limits; use ae_verify_sovereign_record when you have a public action record.',
123
+ inputSchema: {
124
+ message: signedMessageSchema.describe('The exact signed message value'),
125
+ signature: signatureSchema.describe('0x-prefixed 65-byte signature'),
126
+ expectedAddress: addressSchema.describe("The agent's 0x address to check against"),
127
+ },
128
+ },
129
+ async ({ message, signature, expectedAddress }) => {
70
130
  try {
71
131
  return ok(verifyActionSovereign({ message, signature, expectedAddress }));
72
132
  } catch (err) {
73
133
  return fail(err instanceof Error ? err.message : 'verification failed');
74
134
  }
75
- },
76
- );
135
+ },
136
+ );
137
+
138
+ server.registerTool(
139
+ 'ae_verify_sovereign_record',
140
+ {
141
+ title: 'Verify public action record (sovereign, offline)',
142
+ description:
143
+ 'Verify a signed action against a public action record. Checks record status, action index, signature/address match, optional expected envelope hash, and time decay. Pure crypto/local validation with no API key and no network.',
144
+ inputSchema: {
145
+ record: publicActionRecordSchema.describe('The public action record received from AgentEnvelope or another trusted store'),
146
+ actionIndex: z.number().int().nonnegative().describe('The action index being invoked'),
147
+ payload: signedMessageSchema.describe('The exact signed action payload'),
148
+ signature: signatureSchema.describe('0x-prefixed 65-byte signature'),
149
+ expectedActionEnvelopeHash: hashSchema.optional().describe('Optional expected action-envelope hash'),
150
+ },
151
+ },
152
+ async ({ record, actionIndex, payload, signature, expectedActionEnvelopeHash }) => {
153
+ try {
154
+ return ok(verifyRecordSovereign(record, { payload, signature, actionIndex, expectedActionEnvelopeHash }));
155
+ } catch (err) {
156
+ return fail(err instanceof Error ? err.message : 'record verification failed');
157
+ }
158
+ },
159
+ );
77
160
 
78
161
  // Hosted governance — requires AE_API_KEY.
79
162
  server.registerTool(
@@ -81,18 +164,18 @@ export function createServer() {
81
164
  {
82
165
  title: 'Look up registered agent',
83
166
  description: 'Fetch the hosted public record for an agent id. Requires a portal-issued API key.',
84
- inputSchema: {
85
- agentId: z.string().describe('The registered agent id'),
86
- },
87
- },
88
- async ({ agentId }) => {
167
+ inputSchema: {
168
+ agentId: agentIdSchema.describe('The registered agent id'),
169
+ },
170
+ },
171
+ async ({ agentId }) => {
89
172
  const client = governanceClient();
90
- if (!client) return fail(NEEDS_KEY);
91
- try {
92
- return ok(await client.getAgent(agentId));
93
- } catch (err) {
94
- return fail(err instanceof Error ? err.message : 'lookup failed');
95
- }
173
+ if (!client) return fail(NEEDS_KEY);
174
+ try {
175
+ return hostedResult(await client.getAgent(agentId), 'lookup failed');
176
+ } catch (err) {
177
+ return fail(err instanceof Error ? err.message : 'lookup failed');
178
+ }
96
179
  },
97
180
  );
98
181
 
@@ -101,44 +184,44 @@ export function createServer() {
101
184
  {
102
185
  title: 'Verify action (hosted record)',
103
186
  description: 'Verify a signed action against the hosted public record for an agent. Requires a portal-issued API key.',
104
- inputSchema: {
105
- agentId: z.string().describe('The registered agent id'),
106
- actionIndex: z.number().int().nonnegative().describe('The action index'),
107
- payload: z.record(z.string(), z.unknown()).describe('The signed action payload'),
108
- signature: z.string().describe('0x-prefixed 65-byte signature'),
109
- expectedActionEnvelopeHash: z.string().optional().describe('Optional expected action-envelope hash'),
110
- },
111
- },
112
- async ({ agentId, actionIndex, payload, signature, expectedActionEnvelopeHash }) => {
187
+ inputSchema: {
188
+ agentId: agentIdSchema.describe('The registered agent id'),
189
+ actionIndex: z.number().int().nonnegative().describe('The action index'),
190
+ payload: signedMessageSchema.describe('The signed action payload'),
191
+ signature: signatureSchema.describe('0x-prefixed 65-byte signature'),
192
+ expectedActionEnvelopeHash: hashSchema.optional().describe('Optional expected action-envelope hash'),
193
+ },
194
+ },
195
+ async ({ agentId, actionIndex, payload, signature, expectedActionEnvelopeHash }) => {
113
196
  const client = governanceClient();
114
- if (!client) return fail(NEEDS_KEY);
115
- try {
116
- return ok(await client.verifyAction({ agentId, actionIndex, payload, signature, expectedActionEnvelopeHash }));
117
- } catch (err) {
118
- return fail(err instanceof Error ? err.message : 'verification failed');
119
- }
197
+ if (!client) return fail(NEEDS_KEY);
198
+ try {
199
+ return hostedResult(await client.verifyAction({ agentId, actionIndex, payload, signature, expectedActionEnvelopeHash }), 'verification failed');
200
+ } catch (err) {
201
+ return fail(err instanceof Error ? err.message : 'verification failed');
202
+ }
120
203
  },
121
204
  );
122
205
 
123
206
  server.registerTool(
124
207
  'ae_mint',
125
- {
126
- title: 'Mint capability (governance event)',
127
- description:
128
- 'Verify a MintDelegate and signed MintRequest through hosted governance. Returns a mint receipt. Requires a portal-issued API key. This is a governed action.',
129
- inputSchema: {
130
- delegate: z.record(z.string(), z.unknown()).describe('The signed MintDelegate'),
131
- request: z.record(z.string(), z.unknown()).describe('The bot-signed MintRequest'),
132
- },
133
- },
134
- async ({ delegate, request }) => {
208
+ {
209
+ title: 'Verify mint request (hosted receipt)',
210
+ description:
211
+ 'Verify a MintDelegate and signed MintRequest through hosted governance. Returns a mint receipt; it does not return private capability material. Requires a portal-issued API key. This is a governed action.',
212
+ inputSchema: {
213
+ delegate: mintObjectSchema.describe('The signed MintDelegate'),
214
+ request: mintObjectSchema.describe('The bot-signed MintRequest'),
215
+ },
216
+ },
217
+ async ({ delegate, request }) => {
135
218
  const client = governanceClient();
136
- if (!client) return fail(NEEDS_KEY);
137
- try {
138
- return ok(await client.mint({ delegate, request }));
139
- } catch (err) {
140
- return fail(err instanceof Error ? err.message : 'mint failed');
141
- }
219
+ if (!client) return fail(NEEDS_KEY);
220
+ try {
221
+ return hostedResult(await client.mint({ delegate, request }), 'mint failed');
222
+ } catch (err) {
223
+ return fail(err instanceof Error ? err.message : 'mint failed');
224
+ }
142
225
  },
143
226
  );
144
227