modelcontextprotocol / modelcontextprotocol/python-sdk
Inline $ref in tool inputSchema for LLM consumption (parity with typescript-sdk)
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 24.3k
- Forks
- 4k
- Ø Merge
- 1 T. 1 Std.
- Gemergte PRs (30 T.)
- 31
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie bei src/mcp/server/mcpserver/tools/base.py:76, wo model_json_schema() in die Tool-Schema-Pipeline einfließt. Vergleichen Sie den Ansatz dereferenceLocalRefs des TypeScript SDK mit dem genannten Präzedenzfall im Go SDK. Erledigt ist die Aufgabe, wenn lokale $ref/$defs für Tool-Schemas eingebettet werden und Zyklen einen Fehler erzeugen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- api
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 68/100