modelcontextprotocol / modelcontextprotocol/python-sdk

Prompt validation errors are logged with an unnecessary traceback

Open Beginner friendly
#3,342 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

v1 v2
Dominant language
Python
Stars
24.3k
Forks
4k
Avg merge
1d 1h
Merged PRs (30d)
31

Description

Initial Checks
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:

  1. Create a prompt with a required argument:

    @mcp.prompt()
    def diagnose_cluster(problem: str) -> str:
        return f"Diagnose: {problem}"
    
  2. Call prompts/list and confirm that problem is marked as required.

  3. Call prompts/get without providing the required argument:

    {
      "method": "prompts/get",
      "params": {
        "name": "diagnose_cluster"
      }
    }
    
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.