Skip to content

Audio(format=...) generates non-canonical MIME types for mp3 and m4a #4627

Closed

Description

@Aman071106

What happened?

What happened?

When an Audio object is created from in-memory data using the format parameter, the generated MIME type is constructed as audio/<format>. This produces non-canonical MIME types for some formats such as mp3 and m4a.

For example, Audio(format="mp3") generates audio/mp3, while Audio(path="sample.mp3") resolves to audio/mpeg. Similarly, Audio(format="m4a") generates audio/m4a, while Audio(path="sample.m4a") resolves to audio/mp4.

I expected both construction paths to produce the same canonical MIME type.

Current output on main

audio/mp3
audio/mpeg

audio/m4a
audio/mp4

Expected output

audio/mpeg
audio/mpeg

audio/mp4
audio/mp4

Additional context

Python's mimetypes module also resolves these extensions to the canonical MIME types:

>>> import mimetypes

>>> mimetypes.guess_type("sample.mp3")
('audio/mpeg', None)

>>> mimetypes.guess_type("sample.m4a")
('audio/mp4', None)

The Audio(path=...) constructor also uses these canonical MIME types, whereas the Audio(format=...) constructor appears to generate MIME types by simply concatenating audio/ with the supplied format.

Example Code

from fastmcp.utilities.types import Audio

print(Audio(data=b"x", format="mp3").to_audio_content().mime_type)
print(Audio(path="sample.mp3")._mime_type)

print(Audio(data=b"x", format="m4a").to_audio_content().mime_type)
print(Audio(path="sample.m4a")._mime_type)

Version Information

- FastMCP version: ` 0.0.1.dev3748+37fb0ad8`
- MCP version: ` 2.0.0b2`
- Python version: `3.12.0`
- Platform: `Windows 11`

Activity

  1. added
    bug
    on Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions