Skip to content

Parallelize list_* calls in Provider.get_tasks()#2731

Merged
jlowin merged 1 commit intomainfrom
parallelize-get-tasks
Dec 25, 2025
Merged

Parallelize list_* calls in Provider.get_tasks()#2731
jlowin merged 1 commit intomainfrom
parallelize-get-tasks

Conversation

@jlowin
Copy link
Copy Markdown
Member

@jlowin jlowin commented Dec 25, 2025

Uses gather() to fetch all component types in parallel, matching the pattern in get_component().

Related to #2716 and #1668

@marvin-context-protocol marvin-context-protocol Bot added enhancement Improvement to existing functionality. For issues and smaller PR improvements. provider Related to the FastMCP Provider class server Related to FastMCP server implementation or server-side functionality. labels Dec 25, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 25, 2025

Walkthrough

The get_tasks method in src/fastmcp/server/providers/base.py has been refactored to retrieve tools, resources, templates, and prompts in parallel using gather instead of sequentially. The method previously accumulated components through multiple explicit isinstance type checks and loops. The new implementation replaces this multi-loop approach with parallel retrieval, returning a single consolidated list filtered by task_config.supports_tasks().

Possibly related PRs

  • Parallelize provider operations #2716: Also modifies src/fastmcp/server/providers/base.py to switch component retrieval to parallel gather-based calls, implementing similar refactoring patterns.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete. It lacks most required checklist items and detailed explanation of changes, though it does reference related issues. Complete the Contributors Checklist and Review Checklist sections, specify which issue this closes, and provide more detailed explanation of the changes and testing performed.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: parallelizing list_* calls in Provider.get_tasks(), which matches the code modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch parallelize-get-tasks

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9d8a608 and 72c6e91.

📒 Files selected for processing (1)
  • src/fastmcp/server/providers/base.py
🧰 Additional context used
📓 Path-based instructions (1)
src/fastmcp/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

src/fastmcp/**/*.py: Python ≥ 3.10 with full type annotations required
Prioritize readable, understandable code - clarity over cleverness. Avoid obfuscated or confusing patterns even if shorter
Follow existing patterns and maintain consistency in code implementation
Be intentional about re-exports - don't blindly re-export everything to parent namespaces. Core types defining a module's purpose should be exported. Specialized features can live in submodules. Only re-export to fastmcp.* for most fundamental types
Never use bare except - be specific with exception types

Files:

  • src/fastmcp/server/providers/base.py
🧬 Code graph analysis (1)
src/fastmcp/server/providers/base.py (8)
src/fastmcp/utilities/async_utils.py (3)
  • gather (12-15)
  • gather (19-22)
  • gather (25-56)
src/fastmcp/server/providers/fastmcp_provider.py (4)
  • list_tools (422-430)
  • list_resources (441-449)
  • list_resource_templates (460-469)
  • list_prompts (483-490)
src/fastmcp/server/providers/local_provider.py (4)
  • list_tools (253-260)
  • list_resources (267-273)
  • list_resource_templates (282-288)
  • list_prompts (301-307)
src/fastmcp/server/providers/proxy.py (4)
  • list_tools (458-477)
  • list_resources (483-496)
  • list_resource_templates (502-515)
  • list_prompts (521-534)
src/fastmcp/server/providers/transforming.py (4)
  • list_tools (169-175)
  • list_resources (191-197)
  • list_resource_templates (213-221)
  • list_prompts (241-247)
src/fastmcp/server/providers/openapi/provider.py (4)
  • list_tools (351-353)
  • list_resources (359-361)
  • list_resource_templates (367-369)
  • list_prompts (378-380)
examples/providers/sqlite/server.py (1)
  • list_tools (78-83)
src/fastmcp/server/tasks/config.py (1)
  • supports_tasks (69-75)
⏰ 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)
  • GitHub Check: Run tests: Python 3.10 on windows-latest
  • GitHub Check: Run tests: Python 3.10 on ubuntu-latest
  • GitHub Check: Run tests: Python 3.13 on ubuntu-latest
  • GitHub Check: Run tests with lowest-direct dependencies
🔇 Additional comments (1)
src/fastmcp/server/providers/base.py (1)

253-265: LGTM! Parallelization improves performance and maintains consistency.

The refactoring to use gather() for parallel fetching is a clear improvement. The implementation correctly:

  • Fetches all component types concurrently instead of sequentially
  • Unpacks results in order for type safety
  • Filters the consolidated list by supports_tasks()
  • Matches the pattern used in get_component() (lines 228-233)

The approach is consistent with the existing codebase and maintains the same error propagation behavior (exceptions propagate when return_exceptions=False).


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jlowin jlowin merged commit 9f72096 into main Dec 25, 2025
14 checks passed
@jlowin jlowin deleted the parallelize-get-tasks branch December 25, 2025 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvement to existing functionality. For issues and smaller PR improvements. provider Related to the FastMCP Provider class server Related to FastMCP server implementation or server-side functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant