Skip to content

Feature/133 mcptoolfactory fetch tools without event loop #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: v2.0
Choose a base branch
from

Conversation

jon-fox
Copy link
Contributor

@jon-fox jon-fox commented Jun 22, 2025

Adds fetch_mcp_tools_async, enabling native await-based tool fetching and removing the need to pass an event loop (closes #133). Docs, sample client, and tests were updated.

This was actually pretty difficult and non trivial to make work. I tried a number of different ways to get this working without adding a new async api function to MCPToolFactory, but wasn't able to get it working. Maybe theres something I haven't considered, but opening this pr none the less with what i have.

GITHUB COPILOT SUMMARY
This pull request introduces a new asynchronous method for fetching MCP tools, updates the documentation to reflect the new functionality, and adds extensive test coverage for the feature. Additionally, an example client implementation demonstrates the usage of the new asynchronous method.

New Asynchronous Tool Fetching

  • atomic_agents/lib/factories/mcp_tool_factory.py: Added fetch_mcp_tools_async, an asynchronous method for dynamically generating BaseTool subclasses by connecting to an MCP server. This method supports multiple transport types (STDIO, HTTP_STREAM, SSE) and allows for an optional pre-initialized ClientSession.

Test Coverage for Asynchronous Fetching

  • atomic_agents/tests/lib/factories/test_mcp_tool_factory.py: Added comprehensive tests for fetch_mcp_tools_async, covering scenarios such as fetching with and without a client session, handling different transport types, multiple tool definitions, and error propagation (e.g., connection errors, runtime errors).

Example Usage

Documentation Updates

  • docs/examples/mcp_agent.md: Updated documentation to include examples of both synchronous and asynchronous tool fetching, highlighting the advantages of each approach. Detailed explanations of supported transport types and their use cases were also added. [1] [2] [3]

Minor Updates

jon-fox added 2 commits June 22, 2025 01:43
…nBlend-AI#133)

- Add fetch_mcp_tools_async() for async context usage
- Include tests and STDIO client sample
- Remove event loop requirement for async
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant