Skip to content

Prompt validation errors are logged with an unnecessary traceback #3342

Description

@rookie-z

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    v1Affects the v1.x maintenance linev2Affects the v2 line (2.x on main)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions