modelcontextprotocol / modelcontextprotocol/python-sdk
Prompt validation errors are logged with an unnecessary traceback
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.3k
- Forks
- 4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 31
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at get_prompt in mcp/server/mcpserver/server.py and follow its call to render in mcp/server/mcpserver/prompts/base.py. Reproduce prompts/get for diagnose_cluster without the required problem argument, then inspect how the validation error is logged. Done means the request remains rejected while the expected validation error is logged without a full traceback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100