Image/Audio `format=` emits image/jpg, audio/mp3, audio/m4a — unregistered MIME types that disagree with the `path=` suffix table
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
- 84/100
Línea de trabajo
Empieza en src/mcp/server/fastmcp/utilities/types.py y compara la tabla existente de sufijos de rutas con el manejo de format= para Image y Audio; docs/servers/media.md explica el uso de data=. Ejecuta las pruebas relevantes de tipos MIME de Image y Audio y considera los casos parametrizados del issue; terminado significa que los alias registrados coinciden con los resultados basados en rutas, mientras que los formatos desconocidos conservan su fallback.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Initial Checks
- I confirm that I'm using the newest release of my release line (2.2.0)
- I have searched GitHub issues and found no similar issue
Release Line
2.x (current stable). The same code exists on v1.x (src/mcp/server/fastmcp/utilities/types.py).
Description
Image and Audio compute the MIME type two different ways. With path= they use a suffix table (.jpg -> image/jpeg, .mp3 -> audio/mpeg, .m4a -> audio/mp4). With format=, which docs/servers/media.md says to pass whenever you use data=, they just do f"image/{format}" / f"audio/{format}". So the same name gives different results depending on which keyword it arrives through, and format= puts non-registered types on the wire:
Image(data=..., format="jpg")->mimeType: "image/jpg"(should beimage/jpeg)Audio(data=..., format="mp3")->audio/mp3(should beaudio/mpeg)Audio(data=..., format="m4a")->audio/m4a(should beaudio/mp4)
This is easy to hit: switching a tool from Image(path="chart.jpg") to Image(data=buf.getvalue(), format="jpg") silently changes the wire output from image/jpeg to image/jpg, and a consumer that validates image MIME types rejects it.
Expected: format="jpg" and path="x.jpg" give the same registered type.
Proposed fix: route format= through the same table the path= branch already has, keeping image/<format> / audio/<format> as the fallback for names outside it (so format="bmp" etc. are unchanged). I have this fix with parametrized tests ready locally (100% branch coverage on types.py, ruff/pyright clean) and would like to open the PR if this is accepted.
Example Code
from pathlib import Path
from mcp.server.mcpserver import Audio, Image
print(Image(data=b"\x00", format="jpg").to_image_content().mime_type) # image/jpg (expected image/jpeg)
print(Audio(data=b"\x00", format="mp3").to_audio_content().mime_type) # audio/mp3 (expected audio/mpeg)
print(Audio(data=b"\x00", format="m4a").to_audio_content().mime_type) # audio/m4a (expected audio/mp4)
# The same helpers get it right when the name arrives as a file suffix:
print(Image(path=Path("x.jpg"))._mime_type) # image/jpeg
Python & MCP Python SDK
Python 3.12.13
mcp 2.2.0 (also reproduced on main @ f1b6589)
Disclosure: found, reproduced and the draft fix tested locally with the help of an AI coding agent (Claude Code); I reviewed the report before filing it.
- Lenguaje dominante
- Python
- Estrellas
- 24.4k
- Forks
- 4k
- Merge medio
- 1 d 7 h
- PR fusionados (30 d)
- 18
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/python-sdk
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
modelcontextprotocol/python-sdk#3590 ·
Los mantenedores suelen responder en 1 día
-
v1 v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
modelcontextprotocol/python-sdk#3589 ·
Los mantenedores suelen responder en 1 día
-
v1 v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
modelcontextprotocol/python-sdk#3578 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
v1 v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
modelcontextprotocol/python-sdk#3573 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
modelcontextprotocol/python-sdk#3566 ·
Los mantenedores suelen responder en 1 día
Todos los issues de modelcontextprotocol/python-sdk
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
spec-kitty/spec-kitty#5319 ·
Los mantenedores suelen responder en 1 día
-
backend::vllm diffusion multimodal
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
openai/openai-agents-python#5229 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día