-
Couldn't load subscription status.
- Fork 857
Description
Is your feature request related to a problem? Please describe.
Currently, the FastAPI MCP server converts JSON responses to formatted text strings. This limits the ability to provide structured data that can be easily consumed by MCP clients.
Describe the solution you'd like
Add support for returning StructuredContent when API responses are valid JSON. This would involve:
- Enhanced Return Type: Modify
_execute_api_toolto returnStructuredContentfor JSON responses - Configuration Option: Add
prefer_structured_content: bool = Falseparameter to control behavior. Defaults to False for backwards compatibility. - Backward Compatibility: Preserve existing text content behavior when disabled
Describe alternatives you've considered
- Always return structured content (might break existing clients)
- Separate method for structured content (adds complexity)
- Content negotiation (overly complex for this use case)
Additional context
Current implementation converts JSON to formatted text strings. This change would allow MCP clients to receive properly typed structured data instead of text, while maintaining backward compatibility through a configuration option.
Key Benefits
The main advantage is that StructuredContent supports outputSchema, which enables LLMs to understand tool output schemas and create tool chains for single-step execution of multiple tools in sequence.