Complex multi-step workflows with dependency management and state coordination.
from mcp_agent.app import MCPApp from mcp_agent.agents.agent import Agent from mcp_agent.workflows.llm.augmented_llm_openai import OpenAIAugmentedLLM from mcp_agent.workflows.orchestrator.orchestrator import Orchestrator app = MCPApp(name="orchestrator_example") async with app.run() as context: # Create specialized worker agents finder_agent = Agent( name="finder", instruction="Find and read files, fetch URLs for analysis.", server_names=["fetch", "filesystem"] ) writer_agent = Agent( name="writer", instruction="Write comprehensive reports to filesystem.", server_names=["filesystem"] ) proofreader = Agent( name="proofreader", instruction="Review for grammar, spelling, and punctuation errors.", server_names=["fetch"] ) # Create orchestrator with worker agents orchestrator = Orchestrator( worker_agents=[finder_agent, writer_agent, proofreader], llm_factory=OpenAIAugmentedLLM, plan_type="iterative" # Dynamic planning ) # Execute complex multi-step task result = await orchestrator.generate_str( message="Grade the student assignment in short_story.md, check it against APA style guidelines, and write a comprehensive graded report" ) print(result) # Coordinated results from multiple agents
orchestrator = Orchestrator( worker_agents=agents, plan_type="full" # Generate complete plan upfront )
orchestrator = Orchestrator( worker_agents=agents, plan_type="iterative" # Plan one step at a time )