Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

mcp-server-fetch: missing Content-Type header forces non-HTML payloads into readability extraction, failing with error

Abierto Apto para principiantes
#5,134 0 comentarios 0 reacciones 0 asignados Ver en GitHub

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
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
backend

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):

  1. response.headers.get("content-type", "") returns "".
  2. not content_type evaluates to True.
  3. is_page_html becomes True regardless of what the payload actually contains.
  4. extract_content_from_html(page_raw) is invoked on non-HTML content (e.g. JSON {"status": 200}, plain text, CSV, or Markdown).
  5. readabilipy.simple_json.simple_json_from_html_string() cannot extract readability content from non-HTML text.
  6. 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_html is False -> returns page_raw successfully.
  • Without Content-Type header: is_page_html is True -> 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:

  1. Valid HTML documents (with or without headers) are still simplified.
  2. Payloads without a Content-Type header 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

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de modelcontextprotocol/servers

Todos los issues de modelcontextprotocol/servers

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.