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

Abierto Apto para principiantes
#1,163 5 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@ShaanGS ya está trabajando en esto.

Desde el 21/10/2026.

  • #1165 de @ShaanGS — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Empieza por RestClient._send() y call_spec() en application/mcp/rest_client.py y luego revisa el tratamiento de RestClientError en application/mcp/server.py. Reproduce el error de conexión y el timeout con los comandos del issue, y comprueba cómo se depuran los textos de error de REST. El trabajo estará terminado cuando ambas excepciones de las solicitudes lleguen al cliente como errores útiles, mientras que los errores inesperados sigan devolviendo «Internal MCP tool error.»

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
210
Forks
167
Merge medio
4 d 12 h
PR fusionados (30 d)
28

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de OWASP/OpenCRE

Todos los issues de OWASP/OpenCRE

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.