Skip to content

fix(fetch): add python-only readability fallback - #4281

Closed
he-yufeng wants to merge 2 commits into
modelcontextprotocol:mainfrom
he-yufeng:fix/fetch-readability-python-fallback
Closed

he-yufeng wants to merge 2 commits into
modelcontextprotocol:mainfrom
he-yufeng:fix/fetch-readability-python-fallback

Conversation

@he-yufeng

@he-yufeng he-yufeng commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4199.

Summary

mcp-server-fetch always called readabilipy with use_readability=True. That path shells out through Node.js, but the server is installed and documented as a Python package. If Node is missing or the Node readability path is slow/misconfigured, HTML fetches can hang until the MCP client times out.

This patch keeps the stronger Node.js readability path when node is available, but avoids making it an undeclared hard runtime requirement:

  • auto-detect node before choosing the readability backend
  • fall back to readabilipy's Python-only path when Node is unavailable
  • add --no-readability-js for hosts that have Node installed but want the Python-only backend
  • document the behavior in the fetch README

Validation

  • python -m py_compile src/fetch/src/mcp_server_fetch/server.py src/fetch/tests/test_server.py
  • src/fetch/.venv/Scripts/python.exe -m pip install -e src/fetch
  • src/fetch/.venv/Scripts/python.exe -m pytest tests -q from src/fetch
  • src/fetch/.venv/Scripts/python.exe -m py_compile src/mcp_server_fetch/server.py tests/test_server.py from src/fetch
  • src/fetch/.venv/Scripts/python.exe -m ruff check src/mcp_server_fetch/server.py tests/test_server.py from src/fetch
  • git diff --check origin/main..HEAD

@he-yufeng
he-yufeng force-pushed the fix/fetch-readability-python-fallback branch from 3c736c0 to 77e23fe Compare June 7, 2026 11:14

@LuuOW LuuOW left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Technical audit: Verified MCP server implementation for consistency with current SDK patterns.

Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
@he-yufeng

Copy link
Copy Markdown
Contributor Author

extract_content_from_html still lacks a python-only fallback on main, so the failure path this fixes is still live. Any chance of getting eyes on this?

…-python-fallback

Re-express the readability fallback over main's SSRF-guard rework:
allow_private_ips and use_readability_js now thread side by side through
serve/fetch_url, the CLI gains --no-readability-js next to
--allow-private-ips, and the characterization tests moved onto the
in-process harness (MockTransport + FakeWeb) with the forwarding pinned
through serve(use_readability_js=False).
@changeset-bot

changeset-bot Bot commented Oct 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4ff932c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cliffhall

Copy link
Copy Markdown
Member

Thank you for this pull request, and apologies for the long wait for a response.

Since it was opened, the reference servers have been rebuilt for the 2026-07-28 MCP specification (#4857) and released as v2, so this diff no longer applies to the code as it stands. This repository also now accepts issues, not pull requests, from anyone but its maintainers: design and implementation are done by the maintainers through a prompt-driven workflow, so outside PRs are closed rather than reviewed. The policy is in CONTRIBUTING.md.

This is not a judgment on the change or on you. The problem it addresses still applies to v2 and is tracked in #4199, which links back to this PR as a prototype and credits you. Please add anything further there.

This is part of the backlog triage in #4875.

@cliffhall cliffhall closed this Oct 20, 2026
@cliffhall cliffhall mentioned this pull request Oct 20, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

closed-superseded-v2 Closed: fixed or made obsolete by the v2 / 2026-07-28 refactor (#4875)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp-server-fetch hard-codes use_readability=True which requires Node.js (undeclared); fails silently when Node is unavailable or misconfigured

3 participants