Skip to content

Commit 4a49d35

Browse files
author
hzq
committed
Build and smoke-test the MCPB package from source
1 parent 32aca3e commit 4a49d35

10 files changed

Lines changed: 848 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ jobs:
2929
run: npm --prefix integrations/deepseek-harness test
3030
- run: npm run verify
3131

32+
mcpb:
33+
name: build and smoke-test MCPB
34+
runs-on: ubuntu-latest
35+
timeout-minutes: 10
36+
steps:
37+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
38+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
39+
with:
40+
node-version: '24.18.0'
41+
- run: npm ci --include=optional --ignore-scripts
42+
- run: npm run verify:mcpb
43+
3244
# Windows:测试里大量用到 POSIX 专用写法(chmod 出来的带 shebang 的假可执行文件、/bin/sh、
3345
# 权限位、SIGTERM/SIGKILL 等),完整测试在 Windows 上必然失败。这里先跑类型检查、格式检查与
3446
# 和 Windows 打包相关的测试;完整的 Windows 兼容是另一项工作(清单见 docs/releasing.md)。

‎integrations/mcpb/README.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ Both inputs are required. "No environment variables declared" does **not** mean
2020

2121
## Maintainer check
2222

23+
The repository now builds the separate `0.0.65` MCPB candidate from [`entry.ts`](entry.ts) and [`manifest.json`](manifest.json). On macOS or Linux, with Node 24.18 or newer within the repository's supported range and `zip`/`unzip` installed:
24+
25+
```sh
26+
npm ci --include=optional --ignore-scripts
27+
npm run package:mcpb -- /existing/directory/open-agent-api-mcp-0.0.65.mcpb
28+
npm run verify:mcpb
29+
```
30+
31+
The package command will not overwrite an existing file. The verification command builds twice in the same environment and compares the bytes. It then starts the extracted entry point over stdio against a disposable loopback gateway to check discovery and invocation denial with a scoped reader key. It does not test an MCP client installer, upload the package, or modify the Registry.
32+
2333
[`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`.
2434

2535
On a machine with Node and `unzip`, regenerate the record from the exact release asset and compare it with the tracked record:

‎integrations/mcpb/entry.ts‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import path from 'node:path';
2+
import { readCallerKey } from '../../src/client/caller-key.js';
3+
import { GatewayClient } from '../../src/client/client.js';
4+
import { serveMcp } from '../../src/client/mcp.js';
5+
import { validateEndpoint } from '../../src/config/config.js';
6+
7+
async function main(): Promise<void> {
8+
const [gateway, tokenFile] = process.argv.slice(2);
9+
if (process.argv.length !== 4 || !gateway || !tokenFile || !path.isAbsolute(tokenFile)) {
10+
process.stderr.write(
11+
'Open Agent API: Set the gateway origin and select an absolute token-file path.\n',
12+
);
13+
process.exitCode = 1;
14+
return;
15+
}
16+
let origin: string;
17+
try {
18+
const endpoint = new URL(gateway);
19+
validateEndpoint(endpoint.href);
20+
if (endpoint.pathname !== '/' || endpoint.search || endpoint.hash) throw new Error();
21+
origin = endpoint.origin;
22+
} catch {
23+
process.stderr.write(
24+
'Open Agent API: Use an HTTPS gateway origin or loopback HTTP, without a path or credentials.\n',
25+
);
26+
process.exitCode = 1;
27+
return;
28+
}
29+
const key = await readCallerKey(tokenFile).catch(() => undefined);
30+
if (!key) {
31+
process.stderr.write(
32+
'Open Agent API: Select a readable file containing one scoped gateway key.\n',
33+
);
34+
process.exitCode = 1;
35+
return;
36+
}
37+
await serveMcp(new GatewayClient(origin, key.text.trim()));
38+
}
39+
40+
void main().catch(() => {
41+
process.stderr.write('Open Agent API: Could not start the MCP bridge.\n');
42+
process.exitCode = 1;
43+
});

‎integrations/mcpb/manifest.json‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"manifest_version": "0.3",
3+
"name": "open-agent-api-mcp",
4+
"display_name": "Open Agent API",
5+
"version": "0.0.65",
6+
"description": "Connect local MCP clients to agents published on a self-hosted Open Agent API gateway.",
7+
"author": {
8+
"name": "Open Agent API contributors",
9+
"url": "https://github.com/jiangxingfan1-coder/Open-Agent-API"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/jiangxingfan1-coder/Open-Agent-API.git"
14+
},
15+
"documentation": "https://github.com/jiangxingfan1-coder/Open-Agent-API/blob/main/integrations/mcpb/README.md",
16+
"support": "https://github.com/jiangxingfan1-coder/Open-Agent-API/issues",
17+
"license": "Apache-2.0",
18+
"server": {
19+
"type": "node",
20+
"entry_point": "server/index.mjs",
21+
"mcp_config": {
22+
"command": "node",
23+
"args": [
24+
"${__dirname}/server/index.mjs",
25+
"${user_config.gateway_url}",
26+
"${user_config.token_file}"
27+
]
28+
}
29+
},
30+
"tools_generated": true,
31+
"compatibility": {
32+
"runtimes": { "node": ">=24.18.0 <27" }
33+
},
34+
"user_config": {
35+
"gateway_url": {
36+
"type": "string",
37+
"title": "Gateway origin",
38+
"description": "Your Open Agent API gateway origin, without /v1.",
39+
"required": true,
40+
"default": "http://127.0.0.1:8787"
41+
},
42+
"token_file": {
43+
"type": "file",
44+
"title": "Gateway token file",
45+
"description": "Select a local file containing a scoped gateway key. Use read scope for discovery and grant invoke only when needed.",
46+
"required": true
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)