modelcontextprotocol / modelcontextprotocol/python-sdk
[v1.x] Server-side outputSchema validation blocks tool error reporting (isError: true)
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 24.3k
- フォーク
- 4k
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 31
説明
Initial Checks
- I confirm that I'm using the latest version of MCP Python SDK
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Description
When a tool handler returns unstructured content for an error case, the low-level server's call_tool decorator validates the output against outputSchema before checking if the response is an error.
This prevents tools with outputSchema from reporting errors via isError: true, as the validation fails with "outputSchema defined but no structured output returned", replacing the original error message.
This was already fixed in the TypeScript SDK via modelcontextprotocol/typescript-sdk#654 / PR #655 (2025-06-24), but the equivalent fix has not been applied to the Python SDK v1.x branch.
The issue is in src/mcp/server/lowlevel/server.py, the call_tool decorator handler:
- Line ~560: outputSchema validation runs unconditionally — should skip when the result is an error
- Line ~575: isError=False is hardcoded — there is no path for the handler to signal an error through unstructured content while outputSchema is defined
Example Code
from mcp.server.lowlevel import Server
from mcp import types
server = Server("test")
@server.call_tool()
async def call_tool(name: str, arguments: dict):
# Tool has outputSchema but needs to return an error
# This gets blocked by outputSchema validation
return [types.TextContent(type="text", text="Resource not found")]
Python & MCP Python SDK
- Python: 3.11 / 3.12
- MCP SDK: v1.26.0+ (v1.x branch)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
src/mcp/server/lowlevel/server.py の 560 行目と 575 行目付近にある call_tool デコレーターのハンドラーを読み、modelcontextprotocol/typescript-sdk#654 / PR #655 にある対応する TypeScript SDK の修正と比較してください。エラーパスが outputSchema の検証を回避し、構造化されていないツールエラーに対して isError レスポンスを保持することを、報告された例のリグレッションチェックとともに確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- api, backend-api-design
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 70/100