MCP tools return "Internal MCP tool error." when OpenCRE is unreachable or times out
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
application/mcp/rest_client.py の RestClient._send() と call_spec() から始め、次に application/mcp/server.py の RestClientError の処理を確認してください。issue にあるコマンドを使って接続失敗とタイムアウトを再現し、REST エラーテキストがどのようにサニタイズされるかを確認してください。両方のリクエスト例外が有用なエラーとしてクライアントに届き、予期しないバグは引き続き “Internal MCP tool error.” を返せば完了です。
索引モデルが issue の本文から書いたものです。
説明
Issue
What is the issue?
I hit this while trying the MCP server against opencre.org. When the server can't connect to OpenCRE, or a REST call takes longer than the 30 s timeout, the tool result is just Internal MCP tool error.. The actual error is only in the server's stderr, which MCP clients usually don't show. So from the client side you can't tell a server that isn't running, a wrong OPENCRE_BASE_URL or a slow endpoint apart from a real bug in the MCP server.
It looks like RestClient._send() in application/mcp/rest_client.py doesn't catch requests exceptions, so a ConnectionError or ReadTimeout skips the RestClientError handlers in on_call_tool (application/mcp/server.py) and ends up in the last except Exception, which is meant for unexpected errors.
Expected Behaviour
A tool error that says what went wrong, something like:
Could not reach OpenCRE at http://127.0.0.1:5999 (ConnectionError)OpenCRE at https://opencre.org timed out after 30s
and Internal MCP tool error. only for actual bugs.
Actual Behaviour
is_error: true with Internal MCP tool error. in both cases. The real exceptions are in the server log:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=5999): Max retries exceeded with url: /rest/v1/standards (Caused by NewConnectionError(... Failed to establish a new connection: [Errno 61] Connection refused"))
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='opencre.org', port=443): Read timed out. (read timeout=30.0)
Steps to reproduce
- With nothing running on port 5999, start the server:
OPENCRE_BASE_URL=http://127.0.0.1:5999 python -m application.mcp - Call
list_standardswith{}. You getInternal MCP tool error.right away. - For the timeout, start it with
OPENCRE_BASE_URL=https://opencre.organd callget_documents_by_tagwith{"tag": ["family:standard"]}. Same message after about 30 s. (That query is slow on opencre.org right now because of #1087, so it's an easy way to trigger the timeout.)
Tested on main (06f2c56) with Python 3.11. I called the tools from a small script using the MCP SDK's stdio_client.
Possible fix: catch requests.Timeout / requests.RequestException around the _send() call in call_spec() and raise a RestClientError with a message like the ones above, passed through _scrub() like the REST error text. server.py already returns RestClientError messages to the client and logs the traceback, so nothing needs to change there. I have this working locally with tests and can open a PR if that sounds good.
- 主要言語
- Python
- スター
- 210
- フォーク
- 167
- 平均マージ
- 4日 12時間
- マージ済み PR(30日)
- 28
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OWASP/OpenCRE のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OWASP/OpenCRE#1215 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Map Analysis continues polling after a background job fails対応中かも @amantebriwal4321 が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
OWASP/OpenCRE#1211 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
find_node_by_name endpoint does not enforce MAX_ITEMS_PER_PAGE, allowing unbounded pagination queries`対応中かも @Jeffy123-zhu が 26 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
OWASP/OpenCRE#1149 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Information disclosure via filesystem existence oracle in web_main.py catch-all route対応中かも @0x5t4l1n が 39 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OWASP/OpenCRE#1112 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
Unknown stop ID in slow zone data crashes post formatting and skips the rest of that day's postsオープンbackend bug tm-new-volunteer
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
transitmatters/mbta-slow-zone-bot#81 · コメント 1 件 ·
-
area:schema documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
risk:high type:ci
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
spacetelescope/rdmt-spire#49 ·
メンテナーはふだん 1 日以内に返信