fastmcp/tests
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
..
auth Support 'scp' claim for OAuth scopes in BearerAuthProvider 2025-07-03 20:18:54 -04:00
cli Update test_cli.py 2025-07-07 10:46:59 -04:00
client Fix single-element list unwrapping in tool content 2025-07-07 12:07:16 -04:00
contrib Remove asyncio mark 2025-07-06 21:14:30 -04:00
deprecated Avoid propagating logs (#1042) 2025-07-04 12:22:11 -04:00
prompts Avoid propagating logs (#1042) 2025-07-04 12:22:11 -04:00
resources Fix single-element list unwrapping in tool content 2025-07-07 12:07:16 -04:00
server Add output schema support for OpenAPI tools (#1073) 2025-07-07 12:51:01 -04:00
test_servers Update tests for prompts 2025-06-04 16:37:41 -04:00
tools Fix single-element list unwrapping in tool content 2025-07-07 12:07:16 -04:00
utilities Add output schema support for OpenAPI tools (#1073) 2025-07-07 12:51:01 -04:00
__init__.py Update type handling for resources 2024-11-29 19:42:46 -05:00
conftest.py Only apply log config to FastMCP loggers 2025-04-14 15:45:05 -04:00
test_examples.py Fix single-element list unwrapping in tool content 2025-07-07 12:07:16 -04:00