Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Image/Audio `format=` emits image/jpg, audio/mp3, audio/m4a — unregistered MIME types that disagree with the `path=` suffix table

オープン 初心者向け
#3,585 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
api

調査の方向性

src/mcp/server/fastmcp/utilities/types.py から始め、既存のパスサフィックステーブルと、Image および Audio の format= の処理を比較します。docs/servers/media.md では data= の使用方法を説明しています。関連する Image と Audio の MIME タイプテストを実行し、issue のパラメータ化されたケースを検討します。完了の条件は、登録されたエイリアスがパスベースの結果と一致し、未知のフォーマットがフォールバックを維持することです。

索引モデルが issue の本文から書いたものです。

説明

v1 v2
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 be image/jpeg)
  • Audio(data=..., format="mp3") -> audio/mp3 (should be audio/mpeg)
  • Audio(data=..., format="m4a") -> audio/m4a (should be audio/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.

主要言語
Python
スター
24.4k
フォーク
4k
平均マージ
1日 7時間
マージ済み PR(30日)
18

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/python-sdk のほかの issue

modelcontextprotocol/python-sdk の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。