Skip to content

fix(mcp): graceful error handling nei tool read-only#28

Merged
Gabrymi93 merged 1 commit into
mainfrom
fix-mcp-graceful-errors
Apr 24, 2026
Merged

fix(mcp): graceful error handling nei tool read-only#28
Gabrymi93 merged 1 commit into
mainfrom
fix-mcp-graceful-errors

Conversation

@Gabrymi93

@Gabrymi93 Gabrymi93 commented Apr 24, 2026

Copy link
Copy Markdown
Member

Sintesi

I tre tool MCP read-only (session_bootstrap, workspace_triage, topic_index) ora catturano requests.HTTPError e restituiscono una stringa di errore contestuale invece di crashare.

Problema

_fetch usa raise_for_status() — quando GitHub è down, rate-limited, o il branch/context non esiste, l'MCP tool sollevava un'eccezione non gestita, mandando in crash il server o restituendo un internal error al client.

Soluzione

Wrap in try/except requests.HTTPError in ogni tool, con messaggio che include il nome del tool e il codice HTTP:

session_bootstrap: 403 Client Error
workspace_triage: 404 Not Found
topic_index: 500 Server Error

refresh_context era già protetto (gestisce esplicitamente il codice 204).

Test

3 nuovi test:

  • test_session_bootstrap_http_error — 403
  • test_workspace_triage_http_error — 404
  • test_topic_index_http_error — 500

57 test passano, coverage mcp_server.py 97%.

Verifica

  • pytest -q verde (57 passed)
  • CI verde

…dling

Ogni tool MCP ora cattura requests.HTTPError e restituisce una stringa
di errore contestuale invece di crashare. Aggiunti 3 test per i casi
403, 404, 500 su session_bootstrap, workspace_triage e topic_index.
@Gabrymi93
Gabrymi93 force-pushed the fix-mcp-graceful-errors branch from eb6426f to fcf6d7f Compare April 24, 2026 18:00
@Gabrymi93
Gabrymi93 merged commit 84637b1 into main Apr 24, 2026
2 checks passed
@Gabrymi93
Gabrymi93 deleted the fix-mcp-graceful-errors branch April 24, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant