[v2] `client.callTool` rejects an `input_required` result when the tool declares `outputSchema` (manual mode)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- node.js, typescript
- 領域
- api, backend-api-design, testing
調査の方向性
Read packages/client/src/client/client.ts at the output check linked in the report, then trace how callTool handles input_required results and output schema validation. Reproduce with the supplied stdio scripts and compare manual mode with and without outputSchema; done means manual mode returns the intermediate result for the caller while completed output still receives schema validation. A linked pull request (#3217) is already open.
索引モデルが issue の本文から書いたものです。
説明
What happened?
With inputRequired: { autoFulfill: false } and callTool(..., { allowInputRequired: true }), a tool that declares an outputSchema fails on the first round. The server sends resultType: "input_required" with a form elicitation request. The client throws before the caller can read inputRequests and respond.
Environment: Node.js v26.13.1 and v22.23.2, stdio, protocol pinned to and negotiated as 2026-07-28. Both runs used client, server and core 2.4.0, with Zod 4.6.7.
- Save the two files from Code to reproduce in separate
server/andclient/directories. Install@modelcontextprotocol/[email protected]and[email protected]inserver/, and@modelcontextprotocol/[email protected]inclient/. - From the parent directory, run
cd client && node client.mjs ../server/server.mjs. The script callslistTools()beforecallTool(). - Compare (a) manual mode with
outputSchema, (b) automatic mode with the same tool, and (c) manual mode with an otherwise identical tool that omitsoutputSchema.
First tools/call response in case (a), captured over stdio:
{"jsonrpc":"2.0","id":1,"result":{"_meta":{"io.modelcontextprotocol/serverInfo":{"name":"repro-server","version":"0"}},"resultType":"input_required","inputRequests":{"confirmation":{"method":"elicitation/create","params":{"message":"Delete item 7?","requestedSchema":{"type":"object","properties":{}},"mode":"form"}}}}}
Result lines from the run:
RESULT (a): threw ProtocolError code=-32600: Tool delete_item has an output schema but did not return structured content
RESULT (b): returned {"_meta":{"io.modelcontextprotocol/serverInfo":{"name":"repro-server","version":"0"}},"content":[{"type":"text","text":"{\"id\":7}"}],"structuredContent":{"id":7}}
RESULT (c): returned {"_meta":{"io.modelcontextprotocol/serverInfo":{"name":"repro-server","version":"0"}},"content":[{"type":"text","text":"{\"id\":7}"}],"structuredContent":{"id":7}}
In (c), the first call returns input_required. The follow-up call with inputResponses completes. In (b), the client handles the confirmation internally and returns the completed result with structuredContent.
The output check in Client.callTool checks for missing structuredContent without first checking for input_required. This source was inspected on main. The reproduction above ran on 2.4.0.
Coverage includes stdio and an accepted form elicitation in the working controls. HTTP, manual decline and cancellation, other SDK client versions, and a patched client were outside the reproduction.
AI assistance was used to prepare the reproduction, draft this report, and cross-check the SDK source. The output above was captured from an executed run.
What did you expect?
callTool should return the first input_required response to the manual caller, as it does in case (c). The caller can then answer the elicitation and retry. Output-schema validation should apply to the completed tool output. The 2026-07-28 tools specification describes this intermediate response. Input Required Tool Results
A possible fix would be to return the intermediate result before the output check, while retaining schema validation for the completed result. This is an untested proposal.
Code to reproduce
// server/server.mjs
// Minimal server: two identical tools, one with an outputSchema and one without.
// First tools/call returns input_required (one form elicitation); the retry with
// inputResponses returns the complete result.
import { McpServer, inputRequired, inputResponse } from '@modelcontextprotocol/server';
import { serveStdio } from '@modelcontextprotocol/server/stdio';
import * as z from 'zod';
const handler = async ({ id }, ctx) => {
const answer = inputResponse(ctx.mcpReq.inputResponses, 'confirmation');
if (answer.kind === 'missing') {
return inputRequired({
inputRequests: {
confirmation: inputRequired.elicit({
message: `Delete item ${id}?`,
requestedSchema: { type: 'object', properties: {} },
}),
},
});
}
if (answer.kind !== 'elicit' || answer.action !== 'accept') {
return { content: [{ type: 'text', text: 'not deleted' }], isError: true };
}
return { content: [{ type: 'text', text: JSON.stringify({ id }) }], structuredContent: { id } };
};
const createServer = () => {
const server = new McpServer({ name: 'repro-server', version: '0' });
const inputSchema = z.object({ id: z.number().int() });
server.registerTool(
'delete_item',
{ description: 'Deletes an item (declares outputSchema).', inputSchema, outputSchema: z.object({ id: z.number().int() }) },
handler
);
server.registerTool(
'delete_item_no_schema',
{ description: 'Deletes an item (no outputSchema).', inputSchema },
handler
);
return server;
};
await serveStdio(createServer);
// client/client.mjs
// Usage: node client.mjs <path to server.mjs>
import { readFileSync } from 'node:fs';
import { Client } from '@modelcontextprotocol/client';
import { StdioClientTransport } from '@modelcontextprotocol/client/stdio';
const pkg = JSON.parse(readFileSync(new URL('./node_modules/@modelcontextprotocol/client/package.json', import.meta.url)));
console.log(`@modelcontextprotocol/client ${pkg.version}, node ${process.version}`);
// Prints every JSON-RPC message that crosses the transport.
const tap = (transport, label) => {
const send = transport.send.bind(transport);
transport.send = (message, options) => {
console.log(` [${label}] --> ${JSON.stringify(message)}`);
return send(message, options);
};
let onmessage;
Object.defineProperty(transport, 'onmessage', {
get: () => onmessage,
set: fn => {
onmessage = (message, extra) => {
console.log(` [${label}] <-- ${JSON.stringify(message)}`);
return fn(message, extra);
};
},
});
return transport;
};
const connect = async (label, options = {}) => {
const client = new Client(
{ name: 'repro-client', version: '0' },
{ capabilities: { elicitation: { form: {} } }, versionNegotiation: { mode: { pin: '2026-07-28' } }, ...options }
);
client.setRequestHandler('elicitation/create', async () => ({ action: 'accept', content: {} }));
await client.connect(tap(new StdioClientTransport({ command: process.execPath, args: [process.argv[2]] }), label));
const { tools } = await client.listTools(); // caches the outputSchema validators
console.log(` negotiated protocol: ${client.getNegotiatedProtocolVersion()}`);
console.log(` tools: ${JSON.stringify(tools.map(t => ({ name: t.name, outputSchema: t.outputSchema ?? null })))}`);
return client;
};
const run = async (title, fn) => {
console.log(`\n=== ${title}`);
try {
const result = await fn();
console.log(`RESULT ${title.slice(0, 3)}: returned ${JSON.stringify(result)}`);
} catch (error) {
console.log(`RESULT ${title.slice(0, 3)}: threw ${error.constructor.name} code=${error.code}: ${error.message}`);
}
};
// Manual mode: take the input_required result, answer it, retry.
const manual = async name => {
const client = await connect('manual', { inputRequired: { autoFulfill: false } });
try {
const first = await client.callTool({ name, arguments: { id: 7 } }, { allowInputRequired: true });
console.log(` first round returned: ${JSON.stringify(first)}`);
return await client.callTool(
{ name, arguments: { id: 7 }, inputResponses: { confirmation: { action: 'accept', content: {} } }, requestState: first.requestState },
{ allowInputRequired: true }
);
} finally {
await client.close();
}
};
await run('(a) manual mode, tool WITH outputSchema', () => manual('delete_item'));
await run('(b) automatic mode (default), tool WITH outputSchema', async () => {
const client = await connect('auto');
try {
return await client.callTool({ name: 'delete_item', arguments: { id: 7 } });
} finally {
await client.close();
}
});
await run('(c) manual mode, same tool WITHOUT outputSchema (control)', () => manual('delete_item_no_schema'));
SDK version
@modelcontextprotocol/client 2.4.0, @modelcontextprotocol/server 2.4.0, @modelcontextprotocol/core 2.4.0
Area
Client
- 主要言語
- TypeScript
- スター
- 13.8k
- フォーク
- 2.5k
- 平均マージ
- 6日 23時間
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/typescript-sdk のほかの issue
-
v2
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
modelcontextprotocol/typescript-sdk#3270 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`callTool` with `allowInputRequired: true` throws on an `input_required` result when the tool declares an `outputSchema`対応中かも @mgoldsborough が 6 日前に担当しました。 オープンv2
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
modelcontextprotocol/typescript-sdk#3249 ·
メンテナーはふだん 1 日以内に返信
-
v2
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
modelcontextprotocol/typescript-sdk#3243 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
TypeScript client accepts an unknown `resultType` in the first `server/discover` reply対応中かも @Tidehyc が 7 日前に担当しました。 オープンv2
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelcontextprotocol/typescript-sdk#3235 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
UriTemplate.match() throws a TypeError on an empty expression it accepts対応中かも @yunusemrejs が 12 日前に担当しました。 オープンv1 v2
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
modelcontextprotocol/typescript-sdk#3221 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
modelcontextprotocol/typescript-sdk の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Vessel9817/onion-site-template#512 ·
メンテナーはふだん 1 日以内に返信
-
nightly-tests
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
BlackBeltTechnology/pi-agent-dashboard#1256 ·
メンテナーはふだん 1 日以内に返信
-
approved
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
fritzprix/libr-agent#3266 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
better-auth/better-auth#13101 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信