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

Aperta Adatta ai principianti
#1,163 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@ShaanGS ci sta già lavorando.

Dal 21/10/2026.

  • #1165 di @ShaanGS — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Inizia da RestClient._send() e call_spec() in application/mcp/rest_client.py, poi esamina la gestione di RestClientError in application/mcp/server.py. Riproduci l’errore di connessione e il timeout usando i comandi dell’issue, quindi controlla come vengono ripuliti i testi degli errori REST. Il lavoro è completato quando entrambe le eccezioni delle richieste arrivano al client come errori utili, mentre i bug imprevisti continuano a restituire «Internal MCP tool error.»

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
210
Fork
167
Merge medio
4g 12h
PR unite (30g)
28

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OWASP/OpenCRE

Tutte le issue di OWASP/OpenCRE

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.