Skip to content

Building AI agents, atomically

feat: add arun async entry-point to MCPToolFactory; each generated tool now exposes awaitable arun alongside run, unit tests cover both paths, and a minimal FastAPI example shows await tool.arun addressing issue 40; closes #123, likely closes #40

jon fox40e12d5978d6
diff --git a/atomic-agents/atomic_agents/lib/factories/mcp_tool_factory.py b/atomic-agents/atomic_agents/lib/factories/mcp_tool_factory.py
index 87f23a9..8c8d947 100644
--- a/atomic-agents/atomic_agents/lib/factories/mcp_tool_factory.py
+++ b/atomic-agents/atomic_agents/lib/factories/mcp_tool_factory.py
@@ -126,13 +126,12 @@ class MCPToolFactory:
f"{tool_name}OutputSchema", (MCPToolOutputSchema,), {"__doc__": f"Output schema for {tool_name}"}
)
- # Create run method
- def run_tool_sync(self, params: InputSchema) -> OutputSchema: # type: ignore
+ # Async implementation
+ async def run_tool_async(self, params: InputSchema) -> OutputSchema: # type: ignore
bound_tool_name = self.mcp_tool_name
bound_mcp_endpoint = self.mcp_endpoint # May be None when using external session
bound_transport_type = self.transport_type
persistent_session: Optional[ClientSession] = getattr(self, "_client_session", None)
- loop: Optional[asyncio.AbstractEventLoop] = getattr(self, "_event_loop", None)
bound_working_directory = getattr(self, "working_directory", None)
# Get arguments, excluding tool_name
@@ -191,12 +190,10 @@ class MCPToolFactory:
try:
if persistent_session is not None:
# Use the always‑on session/loop supplied at construction time.
- tool_result = cast(asyncio.AbstractEventLoop, loop).run_until_complete(
- _call_with_persistent_session()
- )
+ tool_result = await _call_with_persistent_session()
else:
# Legacy behaviour – open a fresh connection per invocation.
- tool_result = asyncio.run(_connect_and_call())
+ tool_result = await _connect_and_call()
# Process the result
if isinstance(tool_result, BaseModel) and hasattr(tool_result, "content"):
@@ -212,8 +209,21 @@ class MCPToolFactory:
logger.error(f"Error executing MCP tool '{bound_tool_name}': {e}", exc_info=True)
raise RuntimeError(f"Failed to execute MCP tool '{bound_tool_name}': {e}") from e
+ # Create sync wrapper
+ def run_tool_sync(self, params: InputSchema) -> OutputSchema: # type: ignore
+ persistent_session: Optional[ClientSession] = getattr(self, "_client_session", None)
+ loop: Optional[asyncio.AbstractEventLoop] = getattr(self, "_event_loop", None)
+
+ if persistent_session is not None:
+ # Use the always‑on session/loop supplied at construction time.
+ return cast(asyncio.AbstractEventLoop, loop).run_until_complete(self.arun(params))
+ else:
+ # Legacy behaviour – run in new event loop.
+ return asyncio.run(self.arun(params))
+
# Create the tool class using types.new_class() instead of type()
attrs = {
+ "arun": run_tool_async,
"run": run_tool_sync,
"__doc__": tool_description,
"mcp_tool_name": tool_name,
diff --git a/atomic-agents/tests/lib/factories/test_mcp_tool_factory.py b/atomic-agents/tests/lib/factories/test_mcp_tool_factory.py
index a3320be..1dafcb2 100644
--- a/atomic-agents/tests/lib/factories/test_mcp_tool_factory.py
+++ b/atomic-agents/tests/lib/factories/test_mcp_tool_factory.py
@@ -680,3 +680,134 @@ async def test_fetch_mcp_tools_async_multiple_tools(monkeypatch):
assert "Tool1" in tool_names
assert "Tool2" in tool_names
assert "Tool3" in tool_names
+
+
+# Tests for arun functionality
+
+
+def test_arun_attribute_exists_on_generated_tools(monkeypatch):
+ """Test that dynamically generated tools have the arun attribute."""
+ input_schema = {"type": "object", "properties": {}, "required": []}
+ definitions = [MCPToolDefinition(name="TestTool", description="test", input_schema=input_schema)]
+ monkeypatch.setattr(MCPToolFactory, "_fetch_tool_definitions", lambda self: definitions)
+
+ # Create tool
+ tools = fetch_mcp_tools("http://test", MCPTransportType.HTTP_STREAM)
+ tool_cls = tools[0]
+
+ # Verify the class has arun as an attribute
+ assert hasattr(tool_cls, "arun")
+
+ # Verify instance has arun
+ inst = tool_cls()
+ assert hasattr(inst, "arun")
+ assert callable(getattr(inst, "arun"))
+
+
+async def test_arun_tool_async_execution(monkeypatch):
+ """Test that arun method executes tool asynchronously."""
+ import atomic_agents.lib.factories.mcp_tool_factory as mtf
+
+ class DummyTransportCM:
+ def __init__(self, ret):
+ self.ret = ret
+
+ async def __aenter__(self):
+ return self.ret
+
+ async def __aexit__(self, exc_type, exc, tb):
+ pass
+
+ def dummy_http_client(endpoint):
+ return DummyTransportCM((None, None, None))
+
+ class DummySessionCM:
+ def __init__(self, rs=None, ws=None, *args):
+ pass
+
+ async def initialize(self):
+ pass
+
+ async def call_tool(self, name, arguments):
+ return {"content": f"async-{name}-{arguments}-ok"}
+
+ async def __aenter__(self):
+ return self
+
+ async def __aexit__(self, exc_type, exc, tb):
+ pass
+
+ monkeypatch.setattr(mtf, "streamablehttp_client", dummy_http_client)
+ monkeypatch.setattr(mtf, "ClientSession", DummySessionCM)
+
+ # Prepare definitions
+ input_schema = {"type": "object", "properties": {}, "required": []}
+ definitions = [MCPToolDefinition(name="AsyncTool", description="async test", input_schema=input_schema)]
+ monkeypatch.setattr(MCPToolFactory, "_fetch_tool_definitions", lambda self: definitions)
+
+ # Create tool and test arun
+ tools = fetch_mcp_tools("http://test", MCPTransportType.HTTP_STREAM)
+ tool_cls = tools[0]
+ inst = tool_cls()
+
+ # Test arun execution
+ arun_method = getattr(inst, "arun") # type: ignore
+ params = tool_cls.input_schema(tool_name="AsyncTool") # type: ignore
+ result = await arun_method(params)
+ assert result.result == "async-AsyncTool-{}-ok"
+
+
+async def test_arun_error_handling(monkeypatch):
+ """Test that arun properly handles and wraps errors."""
+ import atomic_agents.lib.factories.mcp_tool_factory as mtf
+
+ class DummyTransportCM:
+ def __init__(self, ret):
+ self.ret = ret
+
+ async def __aenter__(self):
+ return self.ret
+
+ async def __aexit__(self, exc_type, exc, tb):
+ pass
+
+ def dummy_http_client(endpoint):
+ return DummyTransportCM((None, None, None))
+
+ class ErrorSessionCM:
+ def __init__(self, rs=None, ws=None, *args):
+ pass
+
+ async def initialize(self):
+ pass
+
+ async def call_tool(self, name, arguments):
+ raise RuntimeError("Tool execution failed")
+
+ async def __aenter__(self):
+ return self
+
+ async def __aexit__(self, exc_type, exc, tb):
+ pass
+
+ monkeypatch.setattr(mtf, "streamablehttp_client", dummy_http_client)
+ monkeypatch.setattr(mtf, "ClientSession", ErrorSessionCM)
+
+ # Prepare definitions
+ input_schema = {"type": "object", "properties": {}, "required": []}
+ definitions = [MCPToolDefinition(name="ErrorTool", description="error test", input_schema=input_schema)]
+ monkeypatch.setattr(MCPToolFactory, "_fetch_tool_definitions", lambda self: definitions)
+
+ # Create tool and test arun error handling
+ tools = fetch_mcp_tools("http://test", MCPTransportType.HTTP_STREAM)
+ tool_cls = tools[0]
+ inst = tool_cls()
+
+ # Test that arun properly wraps errors
+ arun_method = getattr(inst, "arun") # type: ignore
+ params = tool_cls.input_schema(tool_name="ErrorTool") # type: ignore
+ with pytest.raises(RuntimeError) as exc_info:
+ await arun_method(params)
+ assert "Failed to execute MCP tool 'ErrorTool'" in str(exc_info.value)
diff --git a/atomic-examples/mcp-agent/example-client/fastapi_client/main.py b/atomic-examples/mcp-agent/example-client/fastapi_client/main.py
new file mode 100644
index 0000000..071dcab
--- /dev/null
+++ b/atomic-examples/mcp-agent/example-client/fastapi_client/main.py
@@ -0,0 +1,295 @@
+"""FastAPI client example demonstrating async MCP tool usage."""
+
+import os
+from typing import Dict, Any, Union, Type
+from contextlib import asynccontextmanager
+from dataclasses import dataclass
+
+from fastapi import FastAPI, HTTPException
+from pydantic import BaseModel, Field
+
+from atomic_agents.lib.factories.mcp_tool_factory import fetch_mcp_tools_async, MCPTransportType
+from atomic_agents.agents.base_agent import BaseIOSchema, BaseAgent, BaseAgentConfig
+from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator
+from atomic_agents.lib.components.chat_history import ChatHistory
+import openai
+import instructor
+
+
+@dataclass
+class MCPConfig:
+ """Configuration for the MCP Agent system using HTTP Stream transport."""
+
+ mcp_server_url: str = "http://localhost:6969"
+ openai_model: str = "gpt-4o"
+ openai_api_key: str = os.getenv("OPENAI_API_KEY") or ""
+
+ def __post_init__(self):
+ if not self.openai_api_key:
+ raise ValueError("OPENAI_API_KEY environment variable is not set")
+
+
+class NaturalLanguageRequest(BaseModel):
+ query: str = Field(..., description="Natural language query for mathematical operations")
+
+
+class CalculationResponse(BaseModel):
+ result: Any
+ tools_used: list[str]
+ query: str
+
+
+class MCPOrchestratorInputSchema(BaseIOSchema):
+ """Input schema for the MCP orchestrator that processes user queries."""
+
+ query: str = Field(...)
+
+
+class FinalResponseSchema(BaseIOSchema):
+ """Schema for the final response to the user."""
+
+ response_text: str = Field(...)
+
+
+# Global storage for MCP tools, schema mapping
+mcp_tools = {}
+tool_schema_map: Dict[Type[BaseIOSchema], Type] = {}
+config = None
+
+
+@asynccontextmanager
+async def lifespan(app: FastAPI):
+ """Initialize MCP tools and orchestrator agent on startup."""
+ global mcp_tools, tool_schema_map, config
+
+ config = MCPConfig()
+
+ mcp_endpoint = config.mcp_server_url
+
+ try:
+ print(f"Attempting to connect to MCP server at {mcp_endpoint}")
+ print(f"Using transport type: {MCPTransportType.HTTP_STREAM}")
+
+ import requests
+
+ try:
+ response = requests.get(f"{mcp_endpoint}/health", timeout=5)
+ print(f"Health check response: {response.status_code}")
+ except Exception as health_error:
+ print(f"Health check failed: {health_error}")
+
+ tools = await fetch_mcp_tools_async(mcp_endpoint=mcp_endpoint, transport_type=MCPTransportType.HTTP_STREAM)
+
+ print(f"fetch_mcp_tools returned {len(tools)} tools")
+ print(f"Tools type: {type(tools)}")
+
+ for i, tool in enumerate(tools):
+ tool_name = getattr(tool, "mcp_tool_name", tool.__name__)
+ mcp_tools[tool_name] = tool
+ print(f"Tool {i}: name='{tool_name}', type={type(tool).__name__}")
+
+ print(f"Initialized {len(mcp_tools)} MCP tools: {list(mcp_tools.keys())}")
+
+ tool_schema_map.update(
+ {ToolClass.input_schema: ToolClass for ToolClass in tools if hasattr(ToolClass, "input_schema")}
+ )
+
+ available_schemas = tuple(tool_schema_map.keys()) + (FinalResponseSchema,)
+
+ client = instructor.from_openai(openai.OpenAI(api_key=config.openai_api_key))
+ history = ChatHistory()
+
+ globals()["client"] = client
+ globals()["history"] = history
+ globals()["available_schemas"] = available_schemas
+
+ print("MCP tools, schema mapping, and agent components initialized successfully")
+
+ except Exception as e:
+ print(f"Failed to initialize MCP tools: {e}")
+ print(f"Exception type: {type(e).__name__}")
+ import traceback
+
+ traceback.print_exc()
+ print("\n" + "=" * 60)
+ print("ERROR: Could not connect to MCP server!")
+ print("Please start the MCP server first:")
+ print(" cd /path/to/example-mcp-server")
+ print(" poetry run python -m example_mcp_server.server --mode=http_stream")
+ print("=" * 60)
+ raise RuntimeError(f"MCP server connection failed: {e}") from e
+
+ yield
+
+ mcp_tools.clear()
+ tool_schema_map.clear()
+
+
+app = FastAPI(
+ title="MCP FastAPI Client Example",
+ description="Demonstrates async MCP tool usage in FastAPI handlers with agent-based architecture",
+ lifespan=lifespan,
+)
+
+
+async def execute_with_orchestrator_async(query: str) -> tuple[str, list[str]]:
+ """Execute using orchestrator agent pattern with async execution."""
+ if not config or not tool_schema_map:
+ raise HTTPException(status_code=503, detail="Agent components not initialized")
+
+ tools_used = []
+
+ try:
+ available_schemas = tuple(tool_schema_map.keys()) + (FinalResponseSchema,)
+ ActionUnion = Union[available_schemas]
+
+ class OrchestratorOutputSchema(BaseIOSchema):
+ """Output schema for the MCP orchestrator containing reasoning and selected action."""
+
+ reasoning: str
+ action: ActionUnion
+
+ orchestrator_agent = BaseAgent[MCPOrchestratorInputSchema, OrchestratorOutputSchema](
+ BaseAgentConfig(
+ client=globals()["client"],
+ model=config.openai_model,
+ history=ChatHistory(),
+ system_prompt_generator=SystemPromptGenerator(
+ background=[
+ "You are an MCP Orchestrator Agent, designed to chat with users and",
+ "determine the best way to handle their queries using the available tools.",
+ ],
+ steps=[
+ "1. Use the reasoning field to determine if one or more successive tool calls could be used to handle the user's query.",
+ "2. If so, choose the appropriate tool(s) one at a time and extract all necessary parameters from the query.",
+ "3. If a single tool can not be used to handle the user's query, think about how to break down the query into "
+ "smaller tasks and route them to the appropriate tool(s).",
+ "4. If no sequence of tools could be used, or if you are finished processing the user's query, provide a final "
+ "response to the user.",
+ ],
+ output_instructions=[
+ "1. Always provide a detailed explanation of your decision-making process in the 'reasoning' field.",
+ "2. Choose exactly one action schema (either a tool input or FinalResponseSchema).",
+ "3. Ensure all required parameters for the chosen tool are properly extracted and validated.",
+ "4. Maintain a professional and helpful tone in all responses.",
+ "5. Break down complex queries into sequential tool calls before giving the final answer via `FinalResponseSchema`.",
+ ],
+ ),
+ )
+ )
+
+ orchestrator_output = orchestrator_agent.run(MCPOrchestratorInputSchema(query=query))
+
+ print(f"Debug - orchestrator_output type: {type(orchestrator_output)}, fields: {orchestrator_output.model_dump()}")
+
+ if hasattr(orchestrator_output, "chat_message") and not hasattr(orchestrator_output, "action"):
+ action_instance = FinalResponseSchema(response_text=orchestrator_output.chat_message)
+ reasoning = "Response generated directly from chat model"
+ elif hasattr(orchestrator_output, "action"):
+ action_instance = orchestrator_output.action
+ reasoning = orchestrator_output.reasoning if hasattr(orchestrator_output, "reasoning") else "No reasoning provided"
+ else:
+ return "I encountered an unexpected response format. Unable to process.", tools_used
+
+ print(f"Debug - Orchestrator reasoning: {reasoning}")
+ print(f"Debug - Action instance type: {type(action_instance)}")
+ print(f"Debug - Action instance: {action_instance}")
+
+ iteration_count = 0
+ max_iterations = 5
+
+ while not isinstance(action_instance, FinalResponseSchema) and iteration_count < max_iterations:
+ iteration_count += 1
+ print(f"Debug - Iteration {iteration_count}, processing action type: {type(action_instance)}")
+
+ tool_class = tool_schema_map.get(type(action_instance))
+ if not tool_class:
+ print(f"Debug - Error: No tool found for schema {type(action_instance)}")
+ print(f"Debug - Available schemas: {list(tool_schema_map.keys())}")
+ return "I encountered an internal error. Could not find the appropriate tool.", tools_used
+
+ tool_name = tool_class.mcp_tool_name
+ tools_used.append(tool_name)
+
+ print(f"Debug - Executing {tool_class.mcp_tool_name}...")
+ print(f"Debug - Parameters: {action_instance.model_dump()}")
+ tool_instance = tool_class()
+ try:
+ result = await tool_instance.arun(action_instance)
+ print(f"Debug - Result: {result.result}")
+
+ next_query = f"Based on the tool result: {result.result}, please provide the final response to the user's original query: {query}"
+ next_output = orchestrator_agent.run(MCPOrchestratorInputSchema(query=next_query))
+
+ print(f"Debug - subsequent orchestrator_output type: {type(next_output)}, fields: {next_output.model_dump()}")
+
+ if hasattr(next_output, "action"):
+ action_instance = next_output.action
+ if hasattr(next_output, "reasoning"):
+ print(f"Debug - Orchestrator reasoning: {next_output.reasoning}")
+ else:
+ action_instance = FinalResponseSchema(response_text=next_output.chat_message)
+
+ except Exception as e:
+ print(f"Debug - Error executing tool: {e}")
+ return f"I encountered an error while executing the tool: {str(e)}", tools_used
+
+ if iteration_count >= max_iterations:
+ print(f"Debug - Hit max iterations ({max_iterations}), forcing final response")
+ action_instance = FinalResponseSchema(
+ response_text="I reached the maximum number of processing steps. Please try rephrasing your query."
+ )
+
+ if isinstance(action_instance, FinalResponseSchema):
+ return action_instance.response_text, tools_used
+ else:
+ return "Error: Expected final response but got something else", tools_used
+
+ except Exception as e:
+ print(f"Debug - Orchestrator execution error: {e}")
+ import traceback
+
+ traceback.print_exc()
+ raise HTTPException(status_code=500, detail=f"Orchestrator execution failed: {e}")
+
+
+async def root():
+ """Root endpoint showing available tools and following the schema structure."""
+ return {
+ "message": "MCP FastAPI Client Example - Agent-based Architecture",
+ "available_tools": list(mcp_tools.keys()),
+ "tool_schemas": {
+ name: tool.input_schema.__name__ if hasattr(tool, "input_schema") else "N/A" for name, tool in mcp_tools.items()
+ },
+ "endpoints": {
+ "calculate": "/calculate - Natural language queries using agent orchestration (e.g., 'multiply 15 by 3')"
+ },
+ "example_usage": {
+ "natural_language": {
+ "endpoint": "/calculate",
+ "body": {"query": "What is 25 divided by 5?"},
+ "description": "Agent will determine the appropriate tool",
+ }
+ },
+ "config": {
+ "mcp_server_url": config.mcp_server_url if config else "Not initialized",
+ "model": config.openai_model if config else "Not initialized",
+ },
+ }
+
+
[email protected]("/calculate", response_model=CalculationResponse)
+async def calculate_with_agent(request: NaturalLanguageRequest):
+ """Calculate using agent-based orchestration with natural language input."""
+ try:
+ result_text, tools_used = await execute_with_orchestrator_async(request.query)
+ return CalculationResponse(result=result_text, tools_used=tools_used, query=request.query)
+ except Exception as e:
+ raise HTTPException(status_code=500, detail=f"Agent calculation failed: {e}")
+
+
+if __name__ == "__main__":
+ import uvicorn
+
+ uvicorn.run(app, host="0.0.0.0", port=8000)
diff --git a/atomic-examples/mcp-agent/example-client/poetry.lock b/atomic-examples/mcp-agent/example-client/poetry.lock
index 222370f..2020d63 100644
--- a/atomic-examples/mcp-agent/example-client/poetry.lock
+++ b/atomic-examples/mcp-agent/example-client/poetry.lock
@@ -1,4 +1,4 @@
-# This file is automatically @generated by Poetry 2.0.1 and should not be changed by hand.
+# This file is automatically @generated by Poetry 2.1.2 and should not be changed by hand.
[[package]]
name = "aiohappyeyeballs"
@@ -113,7 +113,7 @@ propcache = ">=0.2.0"
yarl = ">=1.17.0,<2.0"
[package.extras]
-speedups = ["Brotli", "aiodns (>=3.2.0)", "brotlicffi"]
+speedups = ["Brotli ; platform_python_implementation == \"CPython\"", "aiodns (>=3.2.0) ; sys_platform == \"linux\" or sys_platform == \"darwin\"", "brotlicffi ; platform_python_implementation != \"CPython\""]
[[package]]
name = "aiosignal"
@@ -161,7 +161,7 @@ typing_extensions = {version = ">=4.5", markers = "python_version < \"3.13\""}
[package.extras]
doc = ["Sphinx (>=8.2,<9.0)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx_rtd_theme"]
-test = ["anyio[trio]", "blockbuster (>=1.5.23)", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "trustme", "truststore (>=0.9.1)", "uvloop (>=0.21)"]
+test = ["anyio[trio]", "blockbuster (>=1.5.23)", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "trustme", "truststore (>=0.9.1) ; python_version >= \"3.10\"", "uvloop (>=0.21) ; platform_python_implementation == \"CPython\" and platform_system != \"Windows\" and python_version < \"3.14\""]
trio = ["trio (>=0.26.1)"]
[[package]]
@@ -202,12 +202,12 @@ files = [
]
[package.extras]
-benchmark = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-codspeed", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
-cov = ["cloudpickle", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
-dev = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pre-commit-uv", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
+benchmark = ["cloudpickle ; platform_python_implementation == \"CPython\"", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pympler", "pytest (>=4.3.0)", "pytest-codspeed", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"]
+cov = ["cloudpickle ; platform_python_implementation == \"CPython\"", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"]
+dev = ["cloudpickle ; platform_python_implementation == \"CPython\"", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pre-commit-uv", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"]
docs = ["cogapp", "furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier"]
-tests = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"]
-tests-mypy = ["mypy (>=1.11.1)", "pytest-mypy-plugins"]
+tests = ["cloudpickle ; platform_python_implementation == \"CPython\"", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"]
+tests-mypy = ["mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\""]
[[package]]
name = "certifi"
@@ -396,6 +396,27 @@ uvicorn = ">=0.15.0"
type = "directory"
url = "../example-mcp-server"
+[[package]]
+name = "fastapi"
+version = "0.115.14"
+description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production"
+optional = false
+python-versions = ">=3.8"
+groups = ["main"]
+files = [
+ {file = "fastapi-0.115.14-py3-none-any.whl", hash = "sha256:6c0c8bf9420bd58f565e585036d971872472b4f7d3f6c73b698e10cffdefb3ca"},
+ {file = "fastapi-0.115.14.tar.gz", hash = "sha256:b1de15cdc1c499a4da47914db35d0e4ef8f1ce62b624e94e0e5824421df99739"},
+]
+
+[package.dependencies]
+pydantic = ">=1.7.4,<1.8 || >1.8,<1.8.1 || >1.8.1,<2.0.0 || >2.0.0,<2.0.1 || >2.0.1,<2.1.0 || >2.1.0,<3.0.0"
+starlette = ">=0.40.0,<0.47.0"
+typing-extensions = ">=4.8.0"
+
+[package.extras]
+all = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.5)", "httpx (>=0.23.0)", "itsdangerous (>=1.1.0)", "jinja2 (>=3.1.5)", "orjson (>=3.2.1)", "pydantic-extra-types (>=2.0.0)", "pydantic-settings (>=2.0.0)", "python-multipart (>=0.0.18)", "pyyaml (>=5.3.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0)", "uvicorn[standard] (>=0.12.0)"]
+standard = ["email-validator (>=2.0.0)", "fastapi-cli[standard] (>=0.0.5)", "httpx (>=0.23.0)", "jinja2 (>=3.1.5)", "python-multipart (>=0.0.18)", "uvicorn[standard] (>=0.12.0)"]
+
[[package]]
name = "frozenlist"
version = "1.6.0"
@@ -542,7 +563,7 @@ gitdb = ">=4.0.1,<5"
[package.extras]
doc = ["sphinx (>=7.1.2,<7.2)", "sphinx-autodoc-typehints", "sphinx_rtd_theme"]
-test = ["coverage[toml]", "ddt (>=1.1.1,!=1.4.3)", "mock", "mypy", "pre-commit", "pytest (>=7.3.1)", "pytest-cov", "pytest-instafail", "pytest-mock", "pytest-sugar", "typing-extensions"]
+test = ["coverage[toml]", "ddt (>=1.1.1,!=1.4.3)", "mock ; python_version < \"3.8\"", "mypy", "pre-commit", "pytest (>=7.3.1)", "pytest-cov", "pytest-instafail", "pytest-mock", "pytest-sugar", "typing-extensions ; python_version < \"3.11\""]
[[package]]
name = "h11"
@@ -597,7 +618,7 @@ httpcore = "==1.*"
idna = "*"
[package.extras]
-brotli = ["brotli", "brotlicffi"]
+brotli = ["brotli ; platform_python_implementation == \"CPython\"", "brotlicffi ; platform_python_implementation != \"CPython\""]
cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"]
http2 = ["h2 (>=3,<5)"]
socks = ["socksio (==1.*)"]
@@ -1241,7 +1262,7 @@ typing-inspection = ">=0.4.0"
[package.extras]
email = ["email-validator (>=2.0.0)"]
-timezone = ["tzdata"]
+timezone = ["tzdata ; python_version >= \"3.9\" and platform_system == \"Windows\""]
[[package]]
name = "pydantic-core"
@@ -1646,7 +1667,7 @@ rich = ">=13.3.3"
typing-extensions = ">=4.4.0,<5.0.0"
[package.extras]
-syntax = ["tree-sitter (>=0.23.0)", "tree-sitter-bash (>=0.23.0)", "tree-sitter-css (>=0.23.0)", "tree-sitter-go (>=0.23.0)", "tree-sitter-html (>=0.23.0)", "tree-sitter-java (>=0.23.0)", "tree-sitter-javascript (>=0.23.0)", "tree-sitter-json (>=0.24.0)", "tree-sitter-markdown (>=0.3.0)", "tree-sitter-python (>=0.23.0)", "tree-sitter-regex (>=0.24.0)", "tree-sitter-rust (>=0.23.0)", "tree-sitter-sql (>=0.3.0)", "tree-sitter-toml (>=0.6.0)", "tree-sitter-xml (>=0.7.0)", "tree-sitter-yaml (>=0.6.0)"]
+syntax = ["tree-sitter (>=0.23.0) ; python_version >= \"3.9\"", "tree-sitter-bash (>=0.23.0) ; python_version >= \"3.9\"", "tree-sitter-css (>=0.23.0) ; python_version >= \"3.9\"", "tree-sitter-go (>=0.23.0) ; python_version >= \"3.9\"", "tree-sitter-html (>=0.23.0) ; python_version >= \"3.9\"", "tree-sitter-java (>=0.23.0) ; python_version >= \"3.9\"", "tree-sitter-javascript (>=0.23.0) ; python_version >= \"3.9\"", "tree-sitter-json (>=0.24.0) ; python_version >= \"3.9\"", "tree-sitter-markdown (>=0.3.0) ; python_version >= \"3.9\"", "tree-sitter-python (>=0.23.0) ; python_version >= \"3.9\"", "tree-sitter-regex (>=0.24.0) ; python_version >= \"3.9\"", "tree-sitter-rust (>=0.23.0) ; python_version >= \"3.9\"", "tree-sitter-sql (>=0.3.0) ; python_version >= \"3.9\"", "tree-sitter-toml (>=0.6.0) ; python_version >= \"3.9\"", "tree-sitter-xml (>=0.7.0) ; python_version >= \"3.9\"", "tree-sitter-yaml (>=0.6.0) ; python_version >= \"3.9\""]
[[package]]
name = "tqdm"
@@ -1743,7 +1764,7 @@ files = [
]
[package.extras]
-brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"]
+brotli = ["brotli (>=1.0.9) ; platform_python_implementation == \"CPython\"", "brotlicffi (>=0.8.0) ; platform_python_implementation != \"CPython\""]
h2 = ["h2 (>=4,<5)"]
socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"]
zstd = ["zstandard (>=0.18.0)"]
@@ -1765,7 +1786,7 @@ click = ">=7.0"
h11 = ">=0.8"
[package.extras]
-standard = ["colorama (>=0.4)", "httptools (>=0.6.3)", "python-dotenv (>=0.13)", "pyyaml (>=5.1)", "uvloop (>=0.14.0,!=0.15.0,!=0.15.1)", "watchfiles (>=0.13)", "websockets (>=10.4)"]
+standard = ["colorama (>=0.4) ; sys_platform == \"win32\"", "httptools (>=0.6.3)", "python-dotenv (>=0.13)", "pyyaml (>=5.1)", "uvloop (>=0.14.0,!=0.15.0,!=0.15.1) ; sys_platform != \"win32\" and sys_platform != \"cygwin\" and platform_python_implementation != \"PyPy\"", "watchfiles (>=0.13)", "websockets (>=10.4)"]
[[package]]
name = "yarl"
@@ -1889,4 +1910,4 @@ propcache = ">=0.2.1"
[metadata]
lock-version = "2.1"
python-versions = ">=3.12,<4.0"
-content-hash = "93a54c0a2c5c002db1a1036420d9670c2244f351ef3bb17b668e02463d0150a4"
+content-hash = "046353729e3397922a30daf001f7eaf7bafbeacb4bd3b4cdcb31501f51d3a455"
diff --git a/atomic-examples/mcp-agent/example-client/pyproject.toml b/atomic-examples/mcp-agent/example-client/pyproject.toml
index b6a7327..6694fc0 100644
--- a/atomic-examples/mcp-agent/example-client/pyproject.toml
+++ b/atomic-examples/mcp-agent/example-client/pyproject.toml
@@ -12,6 +12,7 @@ pydantic = ">=2.10.3,<3.0.0"
rich = ">=13.0.0"
openai = ">=1.0.0"
mcp = {extras = ["cli"], version = "^1.9.4"}
+fastapi = "^0.115.14"
[build-system]
requires = ["poetry-core>=1.0.0"]