mcp-agent applications—projects that use workflows, routers, or multi-agent orchestration. It complements the deployment quickstart with agent-specific advice and links to production-ready examples.
When to use this guide
- You rely on patterns from Building Effective Agents (router, evaluator-optimizer, orchestrator, swarm).
- Your workflows call external MCP servers (filesystem, fetch, bespoke services).
- You need durability (pause/resume, human input, retries) or multiple agents collaborating.
- You want to expose each workflow as an MCP tool for clients to orchestrate.
Example projects
| Example | Highlights | Link |
|---|---|---|
| Temporal orchestrator | Executes planner → researcher → writer pipeline using @app.async_tool | examples/temporal/orchestrator.py |
| Deep orchestrator | Hierarchical planner + executor + evaluator; heavy use of AsyncIO & Temporal tasks | examples/workflows/workflow_deep_orchestrator |
| Evaluator-Optimizer | Iterative loop improving an artifact until evaluation passes | examples/workflows/workflow_evaluator_optimizer |
| Cloud research agent | Fetch, summarize, and persist findings; demonstrates secrets + outputs | examples/cloud/hello_world |
Production-ready checklist
- Config –
execution_engine: temporal, uniquetemporal.task_queue, andmcp.serversdefinitions for all external servers. - Secrets – provider keys in
mcp_agent.secrets.yaml, user secrets tagged!user_secret. - Workflows – use
WorkflowResultto attach metadata,app.taskfor reusable steps, andcontext.loggerfor progress. - Human input –
await context.request_human_input(...)for approvals; handle resume payloads. - Observability – enable OTEL exporters (
otel.enabled: true) and setservice_nameto identify your app in dashboards. - Resource cleanup – if workflows create files or tickets, add compensating actions to
finallyblocks or use Temporal activities with retries.
Deployment workflow
Exposing multiple workflows
Every workflow class becomes an MCP tool namedworkflows-<ClassName>-run. You can expose friendly entrypoints via @app.async_tool as well:
draft_blog_post– easy entrypoint returning{workflow_id, run_id}workflows-BlogAuthorWorkflow-run– low-level interfaceworkflows-get_status,workflows-cancel,workflows-list– generated automatically
mcp-agent cloud workflows list to confirm what’s exposed.
Passing data between tasks
- Use Pydantic models for strong typing (
from mcp_agent.executor.workflow import WorkflowResult). - Temporal memo is available via
WorkflowResult(metadata={"session": "abc"}). - For large payloads, store artifacts in external systems (S3, databases) and persist references; avoid payloads that exceed Temporal history limits.
Human-in-the-loop patterns
Observability for complex agents
- Attach structured data to logs:
context.logger.info("Stage complete", data={"stage": 2}). - Enable token counting:
token_counteris automatically populated when tracing is on. - For long chains, consider writing high-level progress to an external store (Notion, Slack) so operators have context outside the CLI.
Cleanup & rollbacks
- Redeploying with the same name updates the existing deployment with zero downtime (new containers come online before old ones are drained).
- Use
--git-tagto relate deployments to commits. mcp-agent cloud servers delete <id>removes the runtime; workflows in progress are cancelled.- Keep old bundles locally (stored in
.mcp-agent/dist/) for debugging.
Next steps
- Long-running tools →
- Observability →
- ChatGPT Apps deployment → if you plan to publish to OpenAI
- MCP Agent SDK advanced patterns →
