Skip to content

fix(fastmcp): propagate mimeType in resource template list #1186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

pchoudhury22
Copy link

@pchoudhury22 pchoudhury22 commented Jul 22, 2025

This PR fixes an issue where the mimeType attribute of resource templates was not included in the results of resource template list in FastMCP. The change ensures that clients receive the correct mimeType metadata. Additionally, a dedicated test is added to verify this behaviour and prevent regressions.

Motivation and Context

Previously, when listing resource templates using FastMCP, the returned objects were missing the mimeType field. This omission could lead to clients being unaware of the correct content type associated with a resource, which in turn could cause issues in handling, displaying, or routing resources based on their type. This change ensures that the mimeType is properly propagated and visible in resource template listings, improving correctness and client interoperability.

How Has This Been Tested?

  • Added a unit test: test_resource_template_includes_mime_type, which:
    • Registers a resource template with a custom mimeType ("text/csv").
    • Verifies that the template is listed with the correct mimeType.
    • Confirms that the resource is accessible and returns the expected value.
  • Ran all tests locally to ensure no regressions.

Breaking Changes

No breaking changes. This is a bug fix; the interface for registering or listing resources/templates is unchanged. Only the metadata in the output is more complete.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

This closes a gap where client code consuming list_resource_templates() or similar methods may have been missing MIME type information for templates, which could impact rendering, routing, or file handling logic.

No changes are required for users who register or access resources—the fix is internal and improves the API response consistency.

… test

- Fix resource template list did not include the mimeType attribute.
- Propagate mimeType from template metadata to the list output in FastMCP.
- Add test_resource_template_includes_mime_type to verify that listed resource templates include the correct mimeType and the resource is still accessible via the client.
@pchoudhury22 pchoudhury22 requested review from a team and ihrpr July 22, 2025 14:02
@pchoudhury22 pchoudhury22 requested a review from a team as a code owner July 23, 2025 18:33
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