Prompt validation errors are logged with an unnecessary traceback
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
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.
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
- Dominant language
- Python
- Stars
- 24.3k
- Forks
- 4k
- Avg merge
- 1d 19m
- Merged PRs (30d)
- 29
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.
More from modelcontextprotocol/python-sdk
-
v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
modelcontextprotocol/python-sdk#3546 · 5 comments ·
-
v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
modelcontextprotocol/python-sdk#3545 · 1 comment ·
-
v1 v2
Difficulty 1/5 Under an hour Newbie friendliness 91/100
modelcontextprotocol/python-sdk#3508 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
modelcontextprotocol/python-sdk#3504 ·
-
v1 v2
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
modelcontextprotocol/python-sdk#3492 · 1 comment ·
All issues in modelcontextprotocol/python-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100