modelcontextprotocol / modelcontextprotocol/python-sdk

Inline $ref in tool inputSchema for LLM consumption (parity with typescript-sdk)

未關閉
#2,384 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

enhancement needs decision P2
主要語言
Python
星號
24.3k
分支
4k
平均合併
1 天 1 小時
30 天內合併 PR
31

描述

tools/base.py:76 uses raw model_json_schema() which emits $ref/$defs for nested Pydantic models. LLM clients consuming tools/list often can't resolve $ref, leading to params being passed as stringified JSON instead of structured objects.

Repro / demand: anthropics/claude-code#18260 (Notion MCP server, $ref params get stringified by the model).

typescript-sdk addresses this in modelcontextprotocol/typescript-sdk#1563 by adding a dereferenceLocalRefs() step that inlines local $ref and throws on cycles (matching go-sdk precedent). Python should do the equivalent in the tool schema pipeline so all SDKs emit LLM-consumable schemas.

Relevant file: src/mcp/server/mcpserver/tools/base.py:76

貢獻指南

開啟貢獻指南

從這裡開始

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

研究方向

從 src/mcp/server/mcpserver/tools/base.py:76 開始,這裡的 model_json_schema() 會將資料送入工具 schema pipeline。比較 TypeScript SDK 的 dereferenceLocalRefs 方法與所述的 Go SDK 先例。完成的標準是:工具 schema 中的本機 $ref/$defs 會被內嵌,而循環會產生錯誤。

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

評估

技術堆疊
python
領域
api
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
冷清
描述清晰度
基本清楚
新手友好度
68/100

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

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