modelcontextprotocol / modelcontextprotocol/python-sdk
Prompt validation errors are logged with an unnecessary traceback
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 24.3k
- フォーク
- 4k
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 31
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
mcp/server/mcpserver/server.py の get_prompt から始め、mcp/server/mcpserver/prompts/base.py の render の呼び出しを追ってください。必須の problem 引数なしで diagnose_cluster に対する prompts/get を再現し、その後、検証エラーがどのようにログに記録されるかを調べてください。リクエストが引き続き拒否され、期待される検証エラーが完全な traceback なしでログに記録されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- api, backend
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 72/100