Skip to content

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

Open
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/fetch-readability-python-fallback
Open

fix(fetch): add python-only readability fallback#4281
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/fetch-readability-python-fallback

Conversation

@he-yufeng
Copy link
Copy Markdown

Description

Make the fetch server use the optional Node.js readability path only when node is available on PATH, and add --no-readability-js for hosts that need to force the Python-only readabilipy simplifier.

This keeps the existing robust simplifier when Node.js is installed, but avoids making a supposedly optional runtime dependency part of the default execution path.

Publishing Your Server

This changes an existing server and does not add a new server to the registry.

Server Details

  • Server: fetch
  • Changes to: HTML simplification path, CLI configuration, README, tests

Motivation and Context

Fixes #4199.

The README describes Node.js as optional for mcp-server-fetch, but the server always called readabilipy with use_readability=True. In environments without a usable Node.js runtime, that can make HTML fetching fail or hang in a path that should have a Python-only fallback.

The new default is:

  • use the Node.js readability simplifier when node is present
  • otherwise use readabilipy's Python-only simplifier
  • allow explicit opt-out with --no-readability-js

How Has This Been Tested?

From src/fetch:

uv run pytest -q
uv run ruff check .
uv run ruff format --check .
uv run pyright
python -m py_compile src\mcp_server_fetch\server.py src\mcp_server_fetch\__init__.py tests\test_server.py
git diff --check

Breaking Changes

No breaking changes expected. Existing users with Node.js on PATH keep the current readability-js path by default.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

Additional context

The flag is intentionally opt-out instead of changing users with Node.js installed to the simpler path. The automatic fallback only applies when Node.js is absent.

Signed-off-by: Yufeng He <40085740+he-yufeng@users.noreply.github.com>
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.

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

1 participant