Consolidate get_* and _list_* methods into single API#2719
Conversation
The server had parallel implementations for listing components - get_tools() returned dict by name, _list_tools() returned list by key. Consolidate into get_tools(apply_middleware=False) -> list[Tool] as the single source of truth. Breaking change: get_tools/resources/prompts/resource_templates now return lists instead of dicts.
WalkthroughThis pull request refactors component listing methods across the FastMCP server to return lists instead of dictionaries. The Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (18)
📒 Files selected for processing (4)
🧰 Additional context used📓 Path-based instructions (2)docs/**/*.mdx📄 CodeRabbit inference engine (docs/.cursor/rules/mintlify.mdc)
Files:
**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (2)📚 Learning: 2025-11-26T21:51:44.174ZApplied to files:
📚 Learning: 2025-12-21T21:37:55.031ZApplied to files:
🧬 Code graph analysis (2)src/fastmcp/utilities/inspect.py (1)
src/fastmcp/server/providers/fastmcp_provider.py (1)
🪛 Ruff (0.14.10)src/fastmcp/server/server.py815-815: Unused lambda argument: (ARG005) 914-914: Unused lambda argument: (ARG005) 988-988: Unused lambda argument: (ARG005) 1064-1064: Unused lambda argument: (ARG005) ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (12)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Test Failure AnalysisSummary: 9 tests failed on Windows due to pytest-xdist worker crashes with Root Cause: Workers crashed during parallel test execution on Windows with error: Suspected Issue: The PR changes error logging from
The log shows: Suggested Solution:
# Instead of:
logger.exception(f"Error listing tools from provider {provider}")
# Use:
logger.warning(f"Error listing tools from provider {provider}: {result}")
logger.warning(f"Error listing tools from provider {provider}", exc_info=result if isinstance(result, BaseException) else False)Detailed AnalysisFailed Tests (all worker crashes, not test logic failures):
Error Excerpt: Key Code Change ( - logger.warning(f"Failed to get tools from {provider}: {result}")
+ logger.exception(f"Error listing tools from provider {provider}")This pattern was repeated in 4 places for tools, resources, resource_templates, and prompts. Related Files
|
Test Failure AnalysisSummary: Windows-only test failure in Root Cause: The failure is a flaky infrastructure issue where a pytest-retry server thread encountered a Evidence this is not related to the PR:
Suggested Solution: Retry the failing workflow. This is a known class of flaky test failures on Windows with pytest-xdist where workers can crash due to connection handling issues. The test itself is sound and the changes in this PR don't touch the code path being tested. If the failure persists on retry, consider:
Detailed AnalysisFailure LogTest Code (lines 213-237)The failing test is straightforward - it just creates an AzureProvider instance and verifies attributes: def test_azure_specific_scopes(self):
provider = AzureProvider(
client_id="test_client",
client_secret="test_secret",
tenant_id="test-tenant",
base_url="https://myserver.com",
required_scopes=["read", "write", "admin"],
jwt_signing_key="test-secret",
)
assert provider is not None
assert provider._token_validator.required_scopes == ["read", "write", "admin"]No async operations, no network calls, no reason this should cause a worker crash. Job Results
The fact that 3103 other tests passed on Windows including many other Azure provider tests confirms this is an infrastructure flake, not a code issue. Related Files
|
Add call_tool(), read_resource(), render_prompt() methods with apply_middleware parameter, following the pattern from #2719.
The server had parallel implementations for listing components:
get_tools()returned a dict indexed by name, while_list_tools()returned a list deduplicated by key. These were nearly identical with subtle differences in dedup logic and error handling.This consolidates them into a single canonical method with an optional middleware parameter:
Breaking change:
get_tools(),get_resources(),get_prompts(), andget_resource_templates()now returnlistinstead ofdict. The dict key was redundant since components already have.nameor.uriattributes.