Skip to content

fix(server): classify structured file MIME types as text#2572

Open
manaskarra wants to merge 1 commit intomodelcontextprotocol:mainfrom
manaskarra:fix/file-resource-text-mime-types
Open

fix(server): classify structured file MIME types as text#2572
manaskarra wants to merge 1 commit intomodelcontextprotocol:mainfrom
manaskarra:fix/file-resource-text-mime-types

Conversation

@manaskarra
Copy link
Copy Markdown

Summary

  • Treat structured text MIME types such as application/json, application/*+json, XML, YAML, JavaScript, and SVG as text for FileResource.
  • Preserve binary behavior for application/octet-stream and explicit is_binary=True overrides.
  • Add regression coverage for common text-like non-text/* MIME types.

Motivation and Context

FileResource currently marks every non-text/* MIME type as binary. That makes common textual resources like JSON files return bytes, which are then exposed as blob resource contents instead of text resource contents.

How Has This Been Tested?

  • uv run --frozen pytest tests/server/mcpserver/resources/test_file_resources.py
  • uv run --frozen ruff check src/mcp/server/mcpserver/resources/types.py tests/server/mcpserver/resources/test_file_resources.py
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant