Skip to content

Commit 32aca3e

Browse files
author
hzq
committed
Document and verify MCPB Registry setup metadata
1 parent 74fff44 commit 32aca3e

6 files changed

Lines changed: 262 additions & 4 deletions

File tree

‎docs/cli.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,14 @@ evidence in [evidence.md](evidence.md)), which keeps its own command line.
213213

214214
## MCP and integrations
215215

216+
Using the [desktop MCP Bundle preview](https://github.com/jiangxingfan1-coder/Open-Agent-API/blob/main/integrations/mcpb/README.md)? Supply a gateway origin and select a local scoped token file in the installer. Both are required even when a catalog lists no environment variables.
217+
216218
| Command | What it does | Example |
217219
| --- | --- | --- |
218-
| `oaa mcp --url URL --token-file FILE` | Serves the gateway to an MCP client over stdio. | `oaa mcp --token-file .oaa/admin.token` |
220+
| `oaa mcp --url URL --token-file FILE` | Serves the gateway to an MCP client over stdio. | `oaa mcp --token-file .oaa/keys/mcp-reader.key` |
219221
| `oaa mcp inspect --config worker.json --server NAME [--tool NAME] [--cursor CURSOR]` | Lists the tools of an MCP server configured on a worker. | `oaa mcp inspect --config worker.json --server files` |
220222
| `oaa mcp prepare --config worker.json --server NAME --tool NAME --capability private/name --out NEW_DIRECTORY [--name N] [--version V] [--effect E] [--approval A] [--export-result] [--optional]` | Prepares a reviewable capability binding for one MCP tool. | `oaa mcp prepare --config worker.json --server files --tool read --capability private/read --out ./prepared` |
221-
| `oaa integration --out FILE --token-file FILE [--url URL]` | Writes an MCP client configuration (`mcpServers`) that starts `oaa mcp`; nothing is installed. | `oaa integration --out mcp.json --token-file .oaa/admin.token` |
223+
| `oaa integration --out FILE --token-file FILE [--url URL]` | Writes an MCP client configuration (`mcpServers`) that starts `oaa mcp`; nothing is installed. | `oaa integration --out mcp.json --token-file .oaa/keys/mcp-reader.key` |
222224

223225
`oaa mcp-relay` is started by ACP agents from their session configuration; it is not for people.
224226

‎docs/zh-CN/cli.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,14 @@
167167

168168
## MCP 与集成
169169

170+
使用[桌面 MCPB 预览包](https://github.com/jiangxingfan1-coder/Open-Agent-API/blob/main/integrations/mcpb/README.md)时,在安装器中填写网关地址并选择本地的受限密钥文件。即使目录没有列出环境变量,这两项也必填。
171+
170172
| 命令 | 作用 | 示例 |
171173
| --- | --- | --- |
172-
| `oaa mcp --url URL --token-file FILE` | 经 stdio 把网关提供给一个 MCP 客户端。 | `oaa mcp --token-file .oaa/admin.token` |
174+
| `oaa mcp --url URL --token-file FILE` | 经 stdio 把网关提供给一个 MCP 客户端。 | `oaa mcp --token-file .oaa/keys/mcp-reader.key` |
173175
| `oaa mcp inspect --config worker.json --server NAME [--tool NAME] [--cursor CURSOR]` | 列出配置在 worker 上的一个 MCP 服务器的工具。 | `oaa mcp inspect --config worker.json --server files` |
174176
| `oaa mcp prepare --config worker.json --server NAME --tool NAME --capability private/name --out NEW_DIRECTORY [--name N] [--version V] [--effect E] [--approval A] [--export-result] [--optional]` | 为一个 MCP 工具准备一份可审阅的能力绑定。 | `oaa mcp prepare --config worker.json --server files --tool read --capability private/read --out ./prepared` |
175-
| `oaa integration --out FILE --token-file FILE [--url URL]` | 写出一份启动 `oaa mcp` 的 MCP 客户端配置(`mcpServers`);不安装任何东西。 | `oaa integration --out mcp.json --token-file .oaa/admin.token` |
177+
| `oaa integration --out FILE --token-file FILE [--url URL]` | 写出一份启动 `oaa mcp` 的 MCP 客户端配置(`mcpServers`);不安装任何东西。 | `oaa integration --out mcp.json --token-file .oaa/keys/mcp-reader.key` |
176178

177179
`oaa mcp-relay` 由 ACP 智能体根据它们的会话配置启动,不是给人用的。
178180

‎integrations/mcpb/README.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Open Agent API MCP Bundle
2+
3+
The [MCPB preview](https://github.com/jiangxingfan1-coder/Open-Agent-API/releases/tag/mcp-open-agent-api-v0.0.64) connects an MCPB-capable client to an existing Open Agent API gateway over stdio. It does not install a gateway or issue a key. The bundle version is independent of the gateway and desktop version.
4+
5+
| Installer input | What to supply |
6+
| --- | --- |
7+
| `gateway_url` | Gateway origin only, without `/v1`, a query, or credentials. Use HTTPS for a remote gateway or HTTP on loopback, for example `http://127.0.0.1:8787`. |
8+
| `token_file` | Select an absolute local path to a private file containing one scoped OAA gateway key. Use `read` to discover agents; grant `invoke` only when the client should start work. Do not paste a key as an argument or use an admin key for routine access. |
9+
10+
Both inputs are required. "No environment variables declared" does **not** mean anonymous access: the bundle reads its two launch arguments from MCPB installer inputs. For clients that do not support MCPB, use [`oaa integration` or `oaa mcp`](../../docs/cli.md#mcp-and-integrations) instead.
11+
12+
## 中文接入说明
13+
14+
[MCPB 预览包](https://github.com/jiangxingfan1-coder/Open-Agent-API/releases/tag/mcp-open-agent-api-v0.0.64)供支持 MCPB 的客户端经 stdio 连接已有网关,不会安装网关或创建密钥。它的版本与网关、桌面端分别维护。
15+
16+
- `gateway_url`:填写网关地址,不带 `/v1`、查询参数或凭据。远程网关使用 HTTPS,本机回环可使用 `http://127.0.0.1:8787`。
17+
- `token_file`:选择存放受限网关密钥的本地私有文件,使用绝对路径。仅发现智能体时用 `read` 权限,需要发起运行时才授予 `invoke`。不要把密钥文本粘贴到启动参数里,也不要用管理员密钥做日常调用。
18+
19+
两项都必填。目录显示「未声明环境变量」不代表无需鉴权:安装器会把上述配置作为启动参数传给 MCPB。客户端不支持 MCPB 时,可改用 [`oaa integration` 或 `oaa mcp`](../../docs/zh-CN/cli.md#mcp-与集成)。
20+
21+
## Maintainer check
22+
23+
[`server.json`](server.json) is the reviewed Registry metadata for the published bundle bytes, not a Registry update receipt. The short description and setup link are discoverable in ordinary catalogs. The publisher metadata describes the required inputs; it does not add launch arguments on top of `manifest.json`.
24+
25+
On a machine with Node and `unzip`, regenerate the record from the exact release asset and compare it with the tracked record:
26+
27+
```sh
28+
node scripts/mcpb-registry.mjs /path/to/open-agent-api-mcp-0.0.64.mcpb | diff -u integrations/mcpb/server.json -
29+
```
30+
31+
The command reads the manifest and SHA-256 without running the bundle or contacting the Registry. If the bundled setup contract changes, review the metadata and instructions before publication. Registry publication is a separate action.

‎integrations/mcpb/server.json‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3+
"name": "io.github.jiangxingfan1-coder/open-agent-api-mcp",
4+
"description": "Connect MCP clients to Open Agent API. Requires a self-hosted gateway URL and scoped token file.",
5+
"title": "Open Agent API",
6+
"repository": {
7+
"url": "https://github.com/jiangxingfan1-coder/Open-Agent-API",
8+
"source": "github"
9+
},
10+
"websiteUrl": "https://github.com/jiangxingfan1-coder/Open-Agent-API/blob/main/integrations/mcpb/README.md",
11+
"version": "0.0.64",
12+
"packages": [
13+
{
14+
"registryType": "mcpb",
15+
"identifier": "https://github.com/jiangxingfan1-coder/Open-Agent-API/releases/download/mcp-open-agent-api-v0.0.64/open-agent-api-mcp-0.0.64.mcpb",
16+
"fileSha256": "0d0e0eb44304dc14ae21d7624e90ea0b7585fd9158254b05b230a2770b2436d1",
17+
"transport": {
18+
"type": "stdio"
19+
}
20+
}
21+
],
22+
"_meta": {
23+
"io.modelcontextprotocol.registry/publisher-provided": {
24+
"setup": {
25+
"kind": "mcpb-user-config",
26+
"requiredInputs": [
27+
{
28+
"name": "gateway_url",
29+
"type": "string"
30+
},
31+
{
32+
"name": "token_file",
33+
"type": "file"
34+
}
35+
]
36+
}
37+
}
38+
}
39+
}

‎scripts/mcpb-registry.mjs‎

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import assert from 'node:assert/strict';
2+
import { execFileSync } from 'node:child_process';
3+
import { createHash } from 'node:crypto';
4+
import { mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
5+
import { tmpdir } from 'node:os';
6+
import path from 'node:path';
7+
import { pathToFileURL } from 'node:url';
8+
9+
const project = 'https://github.com/jiangxingfan1-coder/Open-Agent-API';
10+
const bundleName = 'open-agent-api-mcp';
11+
const publisher = 'io.modelcontextprotocol.registry/publisher-provided';
12+
const maxBundleBytes = 32 * 1024 * 1024;
13+
14+
export function registryRecord(manifest, sha256) {
15+
const { version, name, server, user_config: config } = manifest;
16+
assert.ok(name === bundleName, 'Unexpected MCPB name.');
17+
assert.ok(
18+
typeof version === 'string' && /^\d+\.\d+\.\d+(?:-[a-z0-9.-]+)?$/.test(version),
19+
'Invalid MCPB version.',
20+
);
21+
assert.ok(typeof sha256 === 'string' && /^[a-f0-9]{64}$/.test(sha256), 'Invalid MCPB digest.');
22+
assert.ok(
23+
server?.type === 'node' &&
24+
server.entry_point === 'server/index.mjs' &&
25+
server.mcp_config?.command === 'node',
26+
'Unexpected MCPB launcher.',
27+
);
28+
assert.ok(
29+
Object.keys(server.mcp_config.env ?? {}).length === 0,
30+
'The MCPB contract no longer uses only arguments.',
31+
);
32+
33+
const inputs = [
34+
{ name: 'gateway_url', type: 'string' },
35+
{ name: 'token_file', type: 'file' },
36+
];
37+
assert.ok(Object.keys(config ?? {}).length === inputs.length, 'Unexpected MCPB inputs.');
38+
for (const input of inputs) {
39+
assert.ok(config[input.name]?.type === input.type, `Unexpected MCPB input type: ${input.name}`);
40+
assert.ok(config[input.name]?.required === true, `Missing required MCPB input: ${input.name}`);
41+
}
42+
assert.ok(
43+
config.token_file.default === undefined,
44+
'The token path must be supplied by the user.',
45+
);
46+
const expected = [
47+
'${__dirname}/server/index.mjs',
48+
...inputs.map((input) => `\${user_config.${input.name}}`),
49+
];
50+
const args = server.mcp_config.args;
51+
assert.ok(
52+
Array.isArray(args) &&
53+
args.length === expected.length &&
54+
expected.every((arg, i) => arg === args[i]),
55+
'Unexpected MCPB launch argument order or source.',
56+
);
57+
58+
return {
59+
$schema: 'https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json',
60+
name: `io.github.jiangxingfan1-coder/${bundleName}`,
61+
description:
62+
'Connect MCP clients to Open Agent API. Requires a self-hosted gateway URL and scoped token file.',
63+
title: 'Open Agent API',
64+
repository: { url: project, source: 'github' },
65+
websiteUrl: `${project}/blob/main/integrations/mcpb/README.md`,
66+
version,
67+
packages: [
68+
{
69+
registryType: 'mcpb',
70+
identifier: `${project}/releases/download/mcp-open-agent-api-v${version}/${bundleName}-${version}.mcpb`,
71+
fileSha256: sha256,
72+
transport: { type: 'stdio' },
73+
},
74+
],
75+
_meta: { [publisher]: { setup: { kind: 'mcpb-user-config', requiredInputs: inputs } } },
76+
};
77+
}
78+
79+
function fromBundle(file) {
80+
const stat = statSync(file);
81+
if (!stat.isFile() || stat.size < 1 || stat.size > maxBundleBytes)
82+
throw new Error('Expected a regular MCPB file no larger than 32 MiB.');
83+
const bytes = readFileSync(file);
84+
// Read the manifest and hash the same snapshot; never extract or execute the entry point.
85+
const dir = mkdtempSync(path.join(tmpdir(), 'oaa-mcpb-registry-'));
86+
try {
87+
const snapshot = path.join(dir, 'bundle.mcpb');
88+
writeFileSync(snapshot, bytes, { mode: 0o600 });
89+
let manifest;
90+
try {
91+
manifest = JSON.parse(
92+
execFileSync('unzip', ['-p', snapshot, 'manifest.json'], {
93+
encoding: 'utf8',
94+
timeout: 10_000,
95+
maxBuffer: 128 * 1024,
96+
}),
97+
);
98+
} catch {
99+
throw new Error(
100+
'Cannot read MCPB manifest.json. Check the bundle and local unzip installation.',
101+
);
102+
}
103+
return registryRecord(manifest, createHash('sha256').update(bytes).digest('hex'));
104+
} finally {
105+
rmSync(dir, { recursive: true, force: true });
106+
}
107+
}
108+
109+
if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) {
110+
if (process.argv.length !== 3)
111+
throw new Error('Usage: node scripts/mcpb-registry.mjs RELEASE.mcpb');
112+
process.stdout.write(JSON.stringify(fromBundle(process.argv[2]), null, 2) + '\n');
113+
}

‎test/mcpb-registry.test.ts‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import assert from 'node:assert/strict';
2+
import { readFileSync } from 'node:fs';
3+
import path from 'node:path';
4+
import test from 'node:test';
5+
import { pathToFileURL } from 'node:url';
6+
7+
const { registryRecord }: { registryRecord(manifest: unknown, digest: string): unknown } =
8+
await import(pathToFileURL(path.resolve('scripts/mcpb-registry.mjs')).href);
9+
const manifest = {
10+
name: 'open-agent-api-mcp',
11+
version: '0.0.64',
12+
server: {
13+
type: 'node',
14+
entry_point: 'server/index.mjs',
15+
mcp_config: {
16+
command: 'node',
17+
args: [
18+
'${__dirname}/server/index.mjs',
19+
'${user_config.gateway_url}',
20+
'${user_config.token_file}',
21+
],
22+
},
23+
},
24+
user_config: {
25+
gateway_url: { type: 'string', required: true },
26+
token_file: { type: 'file', required: true },
27+
},
28+
};
29+
const digest = '0d0e0eb44304dc14ae21d7624e90ea0b7585fd9158254b05b230a2770b2436d1';
30+
31+
test('the MCPB Registry record describes installer inputs without duplicating launch settings', () => {
32+
const record = JSON.parse(readFileSync('integrations/mcpb/server.json', 'utf8'));
33+
assert.deepEqual(registryRecord(manifest, digest), record);
34+
assert.match(record.description, /gateway URL and scoped token file/);
35+
assert.ok(record.description.length <= 100);
36+
assert.equal('packageArguments' in record.packages[0], false);
37+
assert.equal('environmentVariables' in record.packages[0], false);
38+
});
39+
40+
test('MCPB metadata generation refuses credential defaults, optional inputs and launch drift', () => {
41+
const forEachChange = [
42+
(value: typeof manifest) => {
43+
Object.assign(value.user_config.token_file, { default: 'sensitive-fixture' });
44+
},
45+
(value: typeof manifest) => {
46+
value.user_config.token_file.required = false;
47+
},
48+
(value: typeof manifest) => {
49+
value.user_config.token_file.type = 'string';
50+
},
51+
(value: typeof manifest) => {
52+
value.server.mcp_config.args.reverse();
53+
},
54+
(value: typeof manifest) => {
55+
Object.assign(value.server.mcp_config, { env: { CREDENTIAL: 'sensitive-fixture' } });
56+
},
57+
];
58+
for (const change of forEachChange) {
59+
const changed = structuredClone(manifest);
60+
change(changed);
61+
assert.throws(
62+
() => registryRecord(changed, digest),
63+
(error: unknown) => {
64+
assert.ok(error instanceof Error);
65+
assert.doesNotMatch(error.message, /sensitive-fixture/);
66+
return true;
67+
},
68+
);
69+
}
70+
assert.throws(() => registryRecord(manifest, 'unverified'), /Invalid MCPB digest/);
71+
});

0 commit comments

Comments
 (0)