qwen-code/integration-tests/fixtures/invocation-context-echo.mjs
callmeYe b436855a40
feat(core): propagate trusted daemon invocation context (#7279)
* feat(core): propagate trusted daemon invocation context

* test(cli): update ACP startup expectation

* refactor(core): centralize ACP capability env key

* test(cli): update worktree ACP core mock

* test(integration): run daemon context smoke on PRs

* test(ci): update no-AK smoke expectation

* test(core): cover invocation context isolation

* fix(cli): compare ACP capability safely

* fix(docs): restore GitHub action input names

* fix(core): sanitize private ACP capability from child env

* fix(core): reuse private ACP capability env constant

* test(cli): cover malformed trusted invocation context

* test(acp-bridge): assert exact child environment

---------

Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: 易良 <1204183885@qq.com>
2026-07-23 06:49:11 +00:00

49 lines
1.4 KiB
JavaScript

import { appendFile } from 'node:fs/promises';
import process from 'node:process';
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
const outputFile = process.env['INVOCATION_CONTEXT_ECHO_FILE'];
if (!outputFile) {
throw new Error('INVOCATION_CONTEXT_ECHO_FILE is required');
}
const server = new Server(
{ name: 'invocation-context-echo', version: '1.0.0' },
{ capabilities: { tools: {} } },
);
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [
{
name: 'capture_invocation_context',
description: 'Capture this tool request metadata.',
inputSchema: {
type: 'object',
properties: { probe: { type: 'string' } },
required: ['probe'],
additionalProperties: false,
},
},
],
}));
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const record = {
arguments: request.params.arguments ?? {},
metadata: request.params._meta ?? null,
privateCapabilityInEnv:
process.env['QWEN_CODE_PRIVATE_ACP_CAPABILITY'] !== undefined,
};
await appendFile(outputFile, `${JSON.stringify(record)}\n`);
return {
content: [{ type: 'text', text: JSON.stringify(record) }],
};
});
await server.connect(new StdioServerTransport());