Skip to content

Fix: fail fast with actionable errors when MCP endpoint returns#50

Open
zyma wants to merge 1 commit into
ringier-data:mainfrom
Authrion:fix/mcp-html-error-handling
Open

Fix: fail fast with actionable errors when MCP endpoint returns#50
zyma wants to merge 1 commit into
ringier-data:mainfrom
Authrion:fix/mcp-html-error-handling

Conversation

@zyma
Copy link
Copy Markdown
Contributor

@zyma zyma commented Jun 5, 2026

when an MCP endpoint returns HTML instead of JSON/SSE, fail fast with an actionable error instead of hanging

Checklist

  • I have performed a self-review of my code
  • If it is a core feature and/or a bugfix, I have added thorough tests.
  • Does this PR introduce a breaking change? 🚨

Comment on lines +598 to +606
# Best-effort: surface the first connection's URL/slug to the
# streamable-HTTP guard so unexpected-content-type failures
# log with caller context. ``get_tools()`` discovers across all
# connections; per-server enrichment happens in the patched
# transport via the contextvar.
first_slug = next(iter(connections), None)
first_url = getattr(connections[first_slug], "url", None) if first_slug else None
async with guarded_streamable_http(url=first_url, server_slug=first_slug):
tools = await client.get_tools()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels this PR is trying to fix a bug in the mcp which has already been addressed in modelcontextprotocol/python-sdk#2005

Unfortunately 2005 hasn't made it yet to a stable release, though I would still tend to wait, given I don't see this issue too critical

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.

3 participants