modelcontextprotocol / modelcontextprotocol/python-sdk
Prompt validation errors are logged with an unnecessary traceback
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
Initial Checks
- I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1)
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Release line
2.x (current stable)
Description
Description
When a prompt is called without a required argument, the request is correctly rejected, but the Python SDK logs the validation error with a full traceback.
To Reproduce
Steps to reproduce the behavior:
-
Create a prompt with a required argument:
@mcp.prompt() def diagnose_cluster(problem: str) -> str: return f"Diagnose: {problem}" -
Call
prompts/listand confirm thatproblemis marked as required. -
Call
prompts/getwithout providing the required argument:{ "method": "prompts/get", "params": { "name": "diagnose_cluster" } } -
The request is rejected, but the server logs a full traceback:
Error getting prompt diagnose_cluster Traceback (most recent call last): ... File ".../mcp/server/mcpserver/server.py", line 1285, in get_prompt rendered = await prompt.render(arguments, context) File ".../mcp/server/mcpserver/prompts/base.py", line 160, in render raise ValueError(f"Missing required arguments: {missing}") ValueError: Missing required arguments: {'problem'} handler for 'prompts/get' raised
Example Code
Python & MCP Python SDK
## Environment
- MCP Python SDK: v2
- Python: 3.x
- Server: `MCPServer`
- Prompt transport: Streamable HTTP
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
Beginne bei get_prompt in mcp/server/mcpserver/server.py und folge seinem Aufruf von render in mcp/server/mcpserver/prompts/base.py. Reproduziere prompts/get für diagnose_cluster ohne das erforderliche problem-Argument und untersuche anschließend, wie der Validierungsfehler protokolliert wird. Fertig ist die Aufgabe, wenn die Anfrage weiterhin abgelehnt wird und der erwartete Validierungsfehler ohne einen vollständigen Traceback protokolliert wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- api, backend
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 72/100