mcp-server-fetch: missing Content-Type header forces non-HTML payloads into readability extraction, failing with error
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
Empieza por la comprobación del tipo de contenido en src/fetch/src/mcp_server_fetch/server.py, alrededor de las líneas 335–341, y compárala con la ruta de devolución del contenido sin procesar. Comprueba cómo se reconocen actualmente las respuestas HTML sin tipo de contenido y, después, ejecuta o añade pruebas específicas para respuestas HTML y no HTML con encabezados ausentes. El objetivo se cumple cuando las cargas útiles que no son HTML se devuelven sin procesar y el HTML sigue simplificándose.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Which server?
fetch (mcp-server-fetch)
Server version
2026.10.10 (PyPI / commit bbb701e)
How did you run the server?
uvx (Python package)
Transport
stdio
Protocol era
Current (2024-11-05 spec or newer)
MCP client and version
Direct reproduction script / Claude Desktop 0.8.0
Operating system and runtime
Linux 5.15 / Python 3.11
Server configuration
Standard mcp-server-fetch execution.
Steps to reproduce
In src/fetch/src/mcp_server_fetch/server.py lines 335–341:
content_type = response.headers.get("content-type", "")
is_page_html = (
"<html" in page_raw[:100] or "text/html" in content_type or not content_type
)
if is_page_html and not force_raw:
return extract_content_from_html(page_raw), ""
Notice the clause or not content_type.
When fetching an HTTP endpoint that does not include an explicit Content-Type header (common with static files, raw S3/CDN buckets, embedded/IoT servers, or internal microservices returning plain text or raw JSON):
response.headers.get("content-type", "")returns"".not content_typeevaluates toTrue.is_page_htmlbecomesTrueregardless of what the payload actually contains.extract_content_from_html(page_raw)is invoked on non-HTML content (e.g. JSON{"status": 200}, plain text, CSV, or Markdown).readabilipy.simple_json.simple_json_from_html_string()cannot extract readability content from non-HTML text.- The tool returns
<error>Page failed to be simplified from HTML</error>instead of returning the raw payload.
Contrast this with the exact same payload returned with Content-Type: text/plain:
- With
Content-Type: text/plain:is_page_htmlisFalse-> returnspage_rawsuccessfully. - Without
Content-Typeheader:is_page_htmlisTrue-> fails with<error>Page failed to be simplified from HTML</error>.
Minimal reproduction:
def classify_page(page_raw: str, content_type: str):
is_page_html = (
"<html" in page_raw[:100] or "text/html" in content_type or not content_type
)
return is_page_html
# text/plain with header: False -> raw content returned
assert classify_page("hello world", "text/plain") is False
# plain text without header: True -> wrongly forced into HTML extractor!
assert classify_page("hello world", "") is True
# JSON without header: True -> wrongly forced into HTML extractor!
assert classify_page('{"status": "ok"}', "") is True
Expected behavior
Responses lacking a Content-Type header should NOT automatically be assumed to be HTML. Unless the payload contains unambiguous HTML markup (e.g. starting with <!DOCTYPE html or <html), it should be treated as non-HTML and fall back to returning page_raw.
Actual behavior
Any non-HTML endpoint without a Content-Type header is coerced into HTML simplification and fails with:
<error>Page failed to be simplified from HTML</error>
Logs or error output
<error>Page failed to be simplified from HTML</error>
From src/fetch/src/mcp_server_fetch/server.py:158-160:
ret = readabilipy.simple_json.simple_json_from_html_string(html, use_readability=True)
if not ret["content"]:
return "<error>Page failed to be simplified from HTML</error>"
Already prototyped a fix?
In src/fetch/src/mcp_server_fetch/server.py, remove or not content_type and check for HTML markers properly:
content_type_lower = content_type.lower()
page_start = page_raw.lstrip()[:100].lower()
is_page_html = (
"text/html" in content_type_lower
or "application/xhtml+xml" in content_type_lower
or page_start.startswith(("<html", "<!doctype html"))
)
This ensures:
- Valid HTML documents (with or without headers) are still simplified.
- Payloads without a
Content-Typeheader that are NOT HTML fall through to the raw content return block instead of returning an error string.
Before you submit
- I searched existing issues and this is not a duplicate.
- This is not a security vulnerability report (those go through the private advisory form).
- Lenguaje dominante
- JavaScript
- Estrellas
- 91.2k
- Forks
- 11.8k
- Merge medio
- 6 h 20 min
- PR fusionados (30 d)
- 117
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de modelcontextprotocol/servers
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
modelcontextprotocol/servers#5071 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
git: git_create_branch is marked non-destructive but silently resets an existing packed branchAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
modelcontextprotocol/servers#5059 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
mcp-server-fetch: `fetch` prompt returns JSON-RPC error code 0 with the raw exception text for an invalid URLQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
modelcontextprotocol/servers#4914 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
CLAUDE.md: tool-naming rule (kebab-case) disagrees with filesystem and memory serversPosiblemente ocupada @liang0417 la tomó hace 15 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
modelcontextprotocol/servers#4892 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Filesystem README recommends deprecated MCP Roots protocol for restricting directory accessPosiblemente ocupada @its-amann la tomó hace 20 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
modelcontextprotocol/servers#4844 ·
Los mantenedores suelen responder en 1 día
Todos los issues de modelcontextprotocol/servers
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
woocommerce/woocommerce-google-analytics-integration#699 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
t0ggles
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
nolimits4web/swiper#8240 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Inter-Actief/amelink#131 ·