fastmcp/tests/utilities
Jeremiah Lowin 6c9263001b
Add output schema support for OpenAPI tools (#1073)
* Add output schema support for OpenAPI tools

Implement automatic output schema extraction from OpenAPI responses for
FastMCP tools, addressing issue #1070. Tools generated from OpenAPI specs
now have meaningful output schemas instead of null, improving agent
efficiency when working with structured API responses.

- Add extract_output_schema_from_responses() function to parse response schemas
- Enhance OpenAPITool to accept and use output schemas with proper wrapping
- Automatically wrap non-object responses to comply with MCP requirements
- Include schema definitions and compress unused ones
- Add comprehensive test suite covering object, array, and primitive responses
- Update existing tests to handle structured output with proper typing
- Maintain backward compatibility for specs without response schemas

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Move output schema tests to dedicated test file

Reorganize output schema tests into test_openapi_output_schemas.py to keep
the main test_openapi.py file focused and smaller, as requested. Added two
additional tests for schema definitions handling.

- Move all extract_output_schema_from_responses() tests to new file
- Add tests for schema definitions inclusion
- Remove output schema imports from main test file

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-07 12:51:01 -04:00
..
openapi Add output schema support for OpenAPI tools (#1073) 2025-07-07 12:51:01 -04:00
__init__.py restore 1.x code 2025-04-09 11:54:42 -04:00
test_cache.py Fix typing and static issues 2025-05-09 18:06:51 -04:00
test_inspect.py Fix event loop conflict in inspect CLI command 2025-06-21 20:04:39 -04:00
test_json_schema.py openapi: Improve pruning of unused defs 2025-06-20 14:34:41 -04:00
test_json_schema_type.py Provide a response type to client 2025-06-28 09:47:14 -04:00
test_logging.py Only apply log config to FastMCP loggers 2025-04-14 15:45:05 -04:00
test_mcp_config.py Add Cursor support via CLI integration (#1052) 2025-07-05 20:30:47 -04:00
test_tests.py Remove open-ended and server-specific settings 2025-06-07 20:20:04 -04:00
test_typeadapter.py Make the type checker less sad 2025-06-05 23:02:40 -05:00
test_types.py Add path expansion to image/audio/file (#1038) 2025-07-04 09:51:30 -04:00