Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions packages/agent-bundle/tests/mcp-app-sandbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,18 +296,26 @@ it('provides a valid built App resource without imposing the runtime message-siz
});

it('uses an opaque child relay shell with real MCP Apps JSON-RPC notification methods', async () => {
const proxy = await createMcpAppSandboxProxy({
hostOrigin: 'http://127.0.0.1:43123',
maxMessageBytes: 1_024,
port: 0,
});
const frame = createMcpAppSandboxFrame({
consent,
declaration,
hostOrigin: 'http://127.0.0.1:43123',
proxy,
});
const host = createServer();
host.listen({ host: '127.0.0.1', port: 0 });
await once(host, 'listening');
const address = host.address();
if (address === null || typeof address === 'string') throw new Error('The MCP App sandbox test host did not receive a TCP address.');
const hostOrigin = `http://127.0.0.1:${address.port}`;
let proxy: Awaited<ReturnType<typeof createMcpAppSandboxProxy>> | undefined;

try {
proxy = await createMcpAppSandboxProxy({
hostOrigin,
maxMessageBytes: 1_024,
port: 0,
});
const frame = createMcpAppSandboxFrame({
consent,
declaration,
hostOrigin,
proxy,
});
const shell = await fetch(proxy.url).then((response) => response.text());
expect(shell).toContain('sandbox="allow-scripts"');
expect(shell).toContain("event.origin !== 'null'");
Expand All @@ -318,7 +326,8 @@ it('uses an opaque child relay shell with real MCP Apps JSON-RPC notification me
expect(shell).not.toContain('byteLength(message) > maxMessageBytes');
expect(new URL(frame.src).hash).toContain('maxMessageBytes');
} finally {
await proxy.close();
await proxy?.close();
await new Promise<void>((resolve, reject) => host.close((error) => error === undefined ? resolve() : reject(error)));
}
});

Expand Down
4 changes: 2 additions & 2 deletions packages/agent-bundle/tests/path-token-resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ it('resolves Claude path tokens outside command when launching a generated artif
fixture: {
args: [`${pathTokens.workspaceRoot}/tool`],
command: `${pathTokens.pluginRoot}/bin/unchanged`,
cwd: pathTokens.pluginData,
env: {
DATA: pathTokens.pluginData,
ROOT: pathTokens.pluginRoot,
WORKSPACE: pathTokens.workspaceRoot,
},
Expand Down Expand Up @@ -295,8 +295,8 @@ it('resolves Claude path tokens outside command when launching a generated artif
expect(stdio[0]).toMatchObject({
args: [`${fixture.roots.workspaceRoot}/tool`],
command: '${CLAUDE_PLUGIN_ROOT}/bin/unchanged',
cwd: expect.any(String),
env: {
DATA: expect.any(String),
ROOT: expect.any(String),
WORKSPACE: fixture.roots.workspaceRoot,
},
Expand Down
Loading