MCP tools return "Internal MCP tool error." when OpenCRE is unreachable or times out

オープン 初心者向け
#1,163 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@ShaanGS がすでに取り組んでいます。

2026年10月21日 から。

  • #1165 @ShaanGS による — オープン

評価

難易度
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
  1. With nothing running on port 5999, start the server: OPENCRE_BASE_URL=http://127.0.0.1:5999 python -m application.mcp
  2. Call list_standards with {}. You get Internal MCP tool error. right away.
  3. For the timeout, start it with OPENCRE_BASE_URL=https://opencre.org and call get_documents_by_tag with {"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

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

OWASP/OpenCRE のほかの issue

OWASP/OpenCRE の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。