Skip to content

Commit ced3998

Browse files
test(mcp): negotiate the non-task revision for real in the required-tool unit test (#553)
The test pinning the Codex P1 fix (required tools stay callable on a session without the core Tasks utility) narrowed the server's negotiated version with Object.defineProperty. The SDK client can offer an older revision through supportedProtocolVersions, so the session is now negotiated for real at 2025-06-18 through the initialize handshake and the server's own getNegotiatedProtocolVersion() is asserted. A 2026-07-28 session is opened only by the SDK's serving entries (stdio/HTTP), never by a hand-connected in-memory pair, and takes the same branch: anything but 2025-11-25 serves every tool on the ordinary contract.
1 parent c2ffe5e commit ced3998

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎packages/agent-bundle/tests/mcp-tasks.test.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,18 +326,22 @@ describe('task-augmented tools/call (#369)', () => {
326326
});
327327

328328
it('serves every tool as an ordinary request on a revision without the core Tasks utility, required ones included', async () => {
329-
// The SDK client negotiates 2025-11-25 by default; the server's own view
330-
// of the session is what gates the lifecycle, so it is narrowed here to
331-
// what a 2026-07-28 session reports (where the wire has no task vocabulary).
329+
// Negotiated for real: the client offers only 2025-06-18, a revision whose
330+
// core has no Tasks utility, and the server counter-offers it through the
331+
// ordinary initialize handshake. The gate is the negotiated revision, so
332+
// this is the same branch a 2026-07-28 session takes (where the SDK strips
333+
// `execution.taskSupport` and `capabilities.tasks`); that era is opened
334+
// only by the SDK's serving entries, never by a hand-connected in-memory
335+
// pair, which is why it is not the revision driven here.
332336
const { declareTool, install, server, tasks } = createTaskAugmentedMcpServer({ name: 'tasks-unit', version: '0.0.0' });
333337
const required = server.registerTool('background-only', { inputSchema: z.object({}) }, async () => ({ content: [{ text: 'ran', type: 'text' }] }));
334338
declareTool(required, 'background-only', 'required');
335339
install();
336-
Object.defineProperty(tasks, 'getNegotiatedProtocolVersion', { configurable: true, value: () => '2026-07-28' });
337-
const client = new Client({ name: 'tasks-unit-client', version: '0.0.0' });
340+
const client = new Client({ name: 'tasks-unit-client', version: '0.0.0' }, { supportedProtocolVersions: ['2025-06-18'] });
338341
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
339342
await Promise.all([server.connect(serverTransport), client.connect(clientTransport)]);
340343
try {
344+
expect(tasks.getNegotiatedProtocolVersion()).toBe('2025-06-18');
341345
// An ordinary call to the required tool is served, not refused.
342346
expect(await client.callTool({ arguments: {}, name: 'background-only' })).toEqual({ content: [{ text: 'ran', type: 'text' }] });
343347
// Task metadata is ignored: the ordinary result comes back, no task handle.

0 commit comments

Comments
 (0)