fastmcp/tests/server
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
..
http Update all tests 2025-06-27 21:41:37 -04:00
middleware Fix middleware tests 2025-06-26 18:13:32 -04:00
openapi Add output schema support for OpenAPI tools (#1073) 2025-07-07 12:51:01 -04:00
proxy Proxy support advanced MCP features (#1022) 2025-07-04 12:21:57 -04:00
__init__.py restore 1.x code 2025-04-09 11:54:42 -04:00
test_app_state.py Update docs and test 2025-06-20 13:06:48 -04:00
test_auth_integration.py Add audio support 2025-06-14 08:59:48 -04:00
test_context.py Fix formatting per pre-commit hooks 2025-06-19 18:22:02 -04:00
test_file_server.py Remove empty parens 2025-06-04 15:37:55 -04:00
test_import_server.py Ensure multi-client configurations use new ProxyClient (#1045) 2025-07-05 11:57:03 -04:00
test_logging.py Use anyio.event 2025-05-31 18:12:17 -04:00
test_mount.py Ensure multi-client configurations use new ProxyClient (#1045) 2025-07-05 11:57:03 -04:00
test_proxy.py Proxy support advanced MCP features (#1022) 2025-07-04 12:21:57 -04:00
test_resource_prefix_formats.py Update tests 2025-06-19 14:05:19 -04:00
test_run_server.py Update tests for prompts 2025-06-04 16:37:41 -04:00
test_server.py Update all tests 2025-06-27 21:41:37 -04:00
test_server_interactions.py Fix single-element list unwrapping in tool content 2025-07-07 12:07:16 -04:00
test_tool_annotations.py Add structured content & update almost all tests 2025-06-27 15:40:52 -04:00
test_tool_exclude_args.py Add structured content & update almost all tests 2025-06-27 15:40:52 -04:00