Separating Intelligence from Execution: A Workflow Engine for the Model Context Protocol
Organizations: A Preprint
Abstract
Large Language Model (LLM) agents increasingly interact with external systems through tool-calling protocols such as the Model Context Protocol (MCP). In prevailing architectures, the agent must reason about every tool invocation in every session, consuming tokens proportional to the number of actions performed--even when the task has been solved before. We present the MCP Workflow Engine, a novel MCP-native orchestration layer that decouples intelligence (deciding what to do) from execution (carrying it out). An agent reasons once to produce a declarative workflow blueprint--a JSON document specifying a directed sequence of MCP tool calls with parameterized templates, loops, parallel branches, and data piping. Subsequent executions are triggered by a single run_workflow tool call, consuming one invocation's worth of tokens regardless of the blueprint's internal complexity. We formalize the MCP Mediator architectural pattern--an MCP server that simultaneously acts as a client to downstream MCP servers--and implement it in TypeScript against the MCP SDK. We evaluate the engine on a production-scale Kubernetes CMDB synchronization task spanning 67 orchestrated steps across 2 MCP servers, 38 namespaces, 13 worker nodes, and 22 distinct resource types. The engine reduces per-execution token cost by over 99%, completes the full cluster graph--comprising 1,200+ nodes and 2,800+ relationships across 20 relationship types--in under 45 seconds, and achieves deterministic, idempotent execution with zero agent involvement at run time.
Figures & tables
| System | LLM in exec. | Reusable artifact | MCP -native | Exec. cost/run |
|---|---|---|---|---|
| ReAct/Toolformer ( Yao et al., 2023 ; Schick et al., 2023 ) | Yes | None | No | |
| LangChain/CrewAI ( Chase, 2022 ; Moura, 2024 ) | Yes | Chains (code) | No | |
| AutoGen/MetaGPT ( Wu et al., 2023 ; Hong et al., 2023 ) | Yes | Conversations | No | |
| Airflow/Temporal ( Apache Software Foundation, 2015 ; Temporal Technologies, 2020 ) | No | DAGs (code) | No | 0 (no LLM) |
| TaskWeaver ( Qiao et al., 2023 ) | Yes | Code | No | |
| MCP Workflow Engine | No | JSON blueprints | Yes |
| Strategy | Behavior | Use Case |
|---|---|---|
| abort | Stop immediately on first failure | Critical pipelines |
| continue | Log error, skip step, proceed | Best-effort sync |
| retry | Retry up to times with backoff | Transient failures |
| Phase | Steps | Input | Output | Total |
|---|---|---|---|---|
| Tool discovery & planning | 3 | 1,500 | 2,500 | 4,000 |
| Cluster-scoped fetches | 5 | 5,000 | 2,500 | 7,500 |
| Namespace enumeration | 1 | 500 | 1,200 | 1,700 |
| Per-ns resource fetches (38 12) | 456 | 228,000 | 45,600 | 273,600 |
| Graph node creation loops | 800 | 400,000 | 80,000 | 480,000 |
| Relationship creation (20 38) | 760 | 380,000 | 76,000 | 456,000 |
| Phase | Cycles | Input | Output | Total |
|---|---|---|---|---|
| Exploration (one-time) | 8 tool-calling | 12,000 | 4,000 | 16,000 |
| Blueprint construction (one-time) | 15 reasoning | 30,000 | 8,000 | 38,000 |
| Total design (one-time) | 23 | 42,000 | 12,000 | 54,000 |
| Execute (per run) | 1 tool call | 100 | 50 | 150 |
| Runs ( ) | Agent Total | Engine Total | Token Savings |
|---|---|---|---|
| 1 | 1,246,800 | 54,150 | 95.7% |
| 2 | 2,493,600 | 54,300 | 97.8% |
| 5 | 6,234,000 | 54,750 | 99.1% |
| 10 | 12,468,000 | 55,500 | 99.6% |
| 50 | 62,340,000 | 61,500 | 99.9% |
| 365 | 455,082,000 | 108,750 | 99.98% |
| Property | Value |
|---|---|
| Cluster name | atlas-prod (anonymized) |
| Worker nodes | 13 ( node-alpha-01 through node-alpha-13 ) |
| Namespaces | 38 (platform-core, data-services, ml-workloads, …) |
| Resource types synced | 22 |
| Downstream MCP servers | 2 (Kubernetes, Graph Database) |
| Graph database | Property graph (Cypher query language) |
| Phase | Description | Steps | Types |
|---|---|---|---|
| 1. Cluster-scoped | Cluster node, 13 nodes, storage, PVs, roles, CRBs | 8 | call |
| 2. Namespace-scoped | 38 ns 15 resource types | 39 | call , loop |
| 3. Relationships | 20 types linking resources | 20 | call |
| Total | 67 |
| Metric | Value |
| Total execution time | 42 seconds |
| Top-level steps executed | 67 |
| Total MCP tool invocations (incl. loop iters) | 2,000+ |
| Graph nodes created | 1,200+ |
| Graph relationships created | 2,800+ |
| Distinct relationship types | 20 |
| Metric | Single-Namespace | Full-Cluster |
|---|---|---|
| Namespaces | 1 | 38 |
| Blueprint steps | 27 | 67 |
| Resource types | 8 | 22 |
| Loop iterations | 138 | 2,000+ |
| Graph nodes | 139 | 1,200+ |
| Relationships | 245 | 2,800+ |
| Configuration | Steps | Time | Errors | Notes |
| Full engine | 67 | 42s | 0 | Baseline |
| No parallel execution | 67 | 68s | 0 | +62% time |
| No template resolution | — | — | 67 | All steps fail |
| No error strategy ( abort ) | 67 | 38s | 1 (halts) | First failure stops |
| No client pool routing | — | — | 67 | Cannot locate tools |
| Domain | Example Workflow | Steps | Savings |
|---|---|---|---|
| Code-to-Graph Pipeline | Sync repo metadata to knowledge graph | 20 | 95% |
| Incident Response | Correlate alerts logs deployments | 15 | 95% |
| Security Auditing | Scan images CVEs running pods | 18 | 95% |
| Customer Support | Triage KB CRM classify route | 10 | 90% |
| Data Lineage | Trace source transforms dashboards | 12 | 95% |
| Compliance Reporting | RBAC over-perm. accounts report | 25 | 95% |
| Component | File | Lines | Purpose |
|---|---|---|---|
| Type definitions | types/workflow.ts | 134 | Blueprint, Step, Result types |
| Template resolver | engine/template-resolver.ts | 82 | JMESPath + dot-path resolution |
| Workflow engine | engine/workflow-engine.ts | 216 | Orchestration, validation |
| Call executor | engine/steps/call.ts | 49 | MCP tool invocation + retry |
| Loop executor | engine/steps/loop.ts | 67 | Collection iteration |
| Parallel executor | engine/steps/parallel.ts | 52 | Concurrent execution |