A task-augmented tools/call can't return a CreateTaskResult on a 2025-11-25 session

未關閉
#3,267 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
66/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
node.js, typescript

研究方向

Start by reading the server's tools/call request handler and result validation, then compare it with the 1.32.1 behavior described in the issue. Reproduce the case with params.task and the supplied handler result. Done means the task request accepts and returns a valid CreateTaskResult on the 2025-11-25 path while ordinary tool calls continue to validate as CallToolResult.

由索引模型根據 Issue 內容生成。

描述

v2

Package: @modelcontextprotocol/server 2.4.0
Compared with: @modelcontextprotocol/sdk 1.32.1
Runtime: Node.js 24.22.1

Summary

In the 2025-11-25 revision, a tools/call whose params carry task is answered with a CreateTaskResult ({ task: { taskId, status, … } }). Server wraps every tools/call handler and validates its result as a CallToolResult, whatever the request carried, so a server that implements 2025-11-25 tasks itself gets -32602 Invalid tools/call result instead of its task result. 1.32.1 validated the result against CreateTaskResultSchema when params.task was set.

This is the 2025-11-25 core tasks path (params.task on tools/call), not the 2026-07-28 tasks extension covered by #2637.

Reproduction

const { Server, InMemoryTransport } = require('@modelcontextprotocol/server');
const { Client } = require('@modelcontextprotocol/client');

(async () => {
  const server = new Server({ name: 'repro', version: '1.0.0' }, { capabilities: { tools: {} } });
  const now = new Date().toISOString();
  server.setRequestHandler('tools/call', async () => ({
    task: { taskId: 't-1', status: 'working', ttl: 60000, createdAt: now, lastUpdatedAt: now },
  }));
  const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
  await server.connect(serverTransport);
  const client = new Client({ name: 'c', version: '1' });
  await client.connect(clientTransport);

  const passThrough = { '~standard': { version: 1, vendor: 'repro', validate: (value) => ({ value }) } };
  const result = await client
    .request({ method: 'tools/call', params: { name: 'slow', arguments: {}, task: { ttl: 60000 } } }, passThrough)
    .catch((error) => error.message);
  console.log(result);
})();

Expected

The CreateTaskResult the handler returned.

Actual

Invalid tools/call result: [ { "code": "custom",
  "message": "content is required when the body carries 'task' — another result family cannot default into an empty tools/call success", … } ]

Suggestion

When the request carries params.task on a 2025-era session, validate the result as a CreateTaskResult (as 1.x did), even without a built-in tasks runtime, so servers that keep their own task store can serve 2025-11-25 tasks.

主要語言
TypeScript
星號
13.8k
分支
2.5k
平均合併
6 天 23 小時
30 天內合併 PR
2

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

modelcontextprotocol/typescript-sdk 的其他 Issue

查看 modelcontextprotocol/typescript-sdk 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。