Connecting AI Agents to Live Discrete Element Simulations via the Model Context Protocol
Authors: Yusong Han, Ryosuke Uzuoka, Kyohei Ueda
Organizations: Graduate School of Engineering, Kyoto University, Gokasho, Uji, Kyoto, 611-0011, Japan · Disaster Prevention Research Institute, Kyoto University, Gokasho, Uji, Kyoto, 611-0011, Japan
This paper describes a Model Context Protocol (MCP) server through which a general-purpose AI agent operates a discrete element engine, commercial or open-source, while the simulation runs. The agent submits a long simulation to the engine and, while it computes, reads the running model, changes it, or stops it. The human modeler stays at the engine's console and graphical interface throughout, and the agent sees what the modeler does there. The tools are derived from what the agent needs to do at the engine and are held to four principles: correctness, coverage, orthogonality and simplicity. Two documentation tools let the agent search the engine's manual and browse it level by level. Five execution tools let the agent run code in the engine, submit long simulations in the background, check on them, read the running model, and stop them. A bridge inside the engine serves these tools in a commercial DEM engine, PFC, and an open-source one, YADE. In a case study, a general-purpose agent calibrated a drained triaxial model of dense Toyoura sand against laboratory data in both engines, while the modeler worked at the same engine; the agent noticed the modeler's actions at the console and acted on them. The same calibration on YADE was then given to seven language models, three sessions each and without human intervention. Twenty of the twenty-one sessions reached the targets, and nineteen of the parameter sets lie in one small region of the admissible ranges. The server and the bridge are released as two open-source packages, itasca-mcp, which also serves FLAC, 3DEC, MPoint and MassFlow, and yade-mcp.
Figures & tables
Approach
Examples
Workflow
Data-driven models
Trained on laboratory or field data
Phoon et al.,2022 ; Zhang et al.,2021
A model trained on measured data predicts soil properties or soil response.
Trained on DEM simulations
Benvenuti et al.,2016 ; Rackl and Hanley,2017 ; Cheng et al.,2019
A model trained on DEM simulations maps microscopic parameters to the macroscopic response and returns calibrated parameters; the modeler checks them in further simulations.
Language models
Chatbots for numerical code
Kim et al.,2024
The chatbot writes numerical code on request, such as MATLAB scripts for seepage and slope stability; the engineer runs it by hand and carries the errors back to the conversation.
Agents for design and data
Xu et al.,2025a ; Xu et al.,2025b ; Pan et al.,2026
The agent extracts design information from documents or queries site databases, and carries out the calculations.
Table 1: Artificial intelligence and the simulation engine in geotechnical engineering: the approaches and their workflows.
Figure 1: Architecture of the agentic loop. The modeler operates and reads the engine through its console and GUI; the AI agent operates and reads the same engine process through the MCP server. The modeler and the agent communicate in natural language. The modeler sees what the agent does to the engine in the console and the GUI, and the agent sees what the modeler does to the engine in the console history. The dashed frames mark the pre-agentic loop (top right) and the chatbot loop (top left). The MCP server and the bridge, drawn in green, are the contribution of this paper; the agent, its language model and the DEM engine are existing and are used as they are.
Step
Pre-agentic loop
Chatbot loop
Agentic loop
Set the task
Modeler
Modeler
Modeler
Look up the command
Modeler, in the manual
Chatbot, from the training data of its language model
Agent, through the documentation tools
Try the command, adjust it, and run the full simulation
Modeler, at the console
Modeler, who carries text between the chatbot and the console by hand
Agent, through the execution tools; the modeler can also, at the console
Read the result
Modeler
Modeler
Agent and modeler
Accept the result
Modeler
Modeler
Modeler
Table 2: Who carries out each step of the work at the engine in the three loops of Figure 1 .
Figure 2: Two ways to check the commands an agent writes. (a) Every engine command declared as a tool schema: each call is checked against its schema before it reaches the engine, and every schema occupies part of the language model’s context window. (b) The route taken in this study: the agent looks the command up with two documentation tools before writing it. A skipped lookup is caught by the engine’s own error message, which drives the agent to look the command up.
Tool
Description
query documentation
Searches the documentation by keyword and returns the paths of the matching commands.
browse documentation
Returns the full documentation of a command, or the list of commands below a path.
execute_code
Runs a code snippet in the engine and returns the engine’s response. Remains available while a task runs.
execute_task
Submits a script as a background task and returns the task identifier.
check_task_status
Reports the state of a task and returns its output so far.
interrupt_task
Stops a running task and keeps the state of the engine.
Table 3: The tools the MCP server offers the agent, as drawn in the MCP server box of Figure 1 .
Figure 3: Two routes to one entry of the documentation, on the PFC 7.0 command corpus. Each response is counted in tokens. (a) The query tool searches by keyword and returns ranked matches, each with the path of the command. (b) The browse tool reads level by level, and a wrong path returns the list at the parent level. (c) Both routes end in the same browse call, which returns the full documentation. The bar shows the shares of the command corpus read by the documentation tools in examples (a) and (b) and in the case study of Section 3.2 .
Figure 4: The threading model of the bridge in PFC. The HTTP server receives each request on a background thread. A script, and a snippet while no task is running, go into the main queue, and a Qt timer or a console loop runs the items of the main queue on the main thread. A snippet that arrives while a task is running goes into the cycle queue, and the snippet callback runs the snippet. The interrupt callback stops the task when an interrupt is requested. Status queries are answered from the task registry without a queue. Green: added by the bridge; amber: the engine.
Figure 5: The threading model of the bridge in YADE. The HTTP server and the task registry are as in Figure 4 . A YADE simulation can run on a background thread, and the bridge uses separate queues and separate threads for snippets and for tasks. A snippet goes into the snippet queue, and a Qt timer on the main thread runs the snippet, or a polling thread when Qt is not available. A script goes into the task queue, and the task thread runs the tasks in the order submitted. The dashed hold edge lets a snippet hold the cycling simulation for a read ( Figure 6 ). Green: added by the bridge; amber: the engine.
Figure 6: The bridge’s wrapper around O.run() , a zoom into the O.run() box of Figure 5 . The wrapper wraps every O.run() call, typically the one a task script starts on the task thread. Before the simulation, the wrapper restores the bridge-PyRunner to the head of the engine list. During the simulation, the bridge-PyRunner runs once in every step. The bridge-PyRunner calls O.pause() when an interrupt is requested, and holds the simulation while a snippet reads the DEM model. After the simulation, outside the cycle, the wrapper raises CycleInterrupt if an interrupt was requested. Green: added by the bridge; amber: the engine’s existing cycle.
Calibrated
n0
porosity of the frictionless specimen, before consolidation, 0.380–0.445
E∗
contact modulus, 107 – 109 Pa
μ
sliding friction, 0–1
μr
rolling friction, 0–1
Constant in every session
contact model
rolling-resistance linear, kn/ks = 2.0
Table 4: Model specification. The four parameters to calibrate, with their ranges, and the constants.
i
Scalar
Definition
Target
ei
τi
1
E50
secant modulus at half the peak deviator stress
52.5 MPa
relative
25 %
2
qpeak
peak deviator stress
403 kPa
relative
10 %
3
D
dεv/dεa at the peak deviator stress
0.67
absolute
0.10
Table 5: Calibration targets and tolerances. The error ei is the simulated value minus the target, relative to the target or absolute as marked; an iteration is scored by J=maxi∣ei∣/τi , and every target is within tolerance when J≤1 .
Figure 7: The session as a conversation, read from top to bottom: the modeler’s opening message, abridged (the full text is published, see Data availability ); the agent’s messages on the left, grouped by iteration and summarized by their tool calls and outcomes; and the modeler’s two console actions on the right, which reached the agent as console history.
The agent ran
Cause
Solution
w.velocity()
A wall has no such attribute.
Listed the methods of the wall through execute_code ; used w.vel() .
ball.list()[0]
The list of balls cannot be indexed.
Removed the index.
itasca.cycle(20000)
The function returns the cycle number and does not cycle.
Used the command model cycle 20000 .
program list threads
threads is not a keyword of program list .
Used program list information , from the keywords listed in the error.
model cycle 1
model large-strain on was left out.
Added the command, named in the error.
Table 6: The five trials that came back with an error from the engine.
it.
n0
E∗ (Pa)
μ
μr
εa,peak
e1/τ1
e2/τ2
e3/τ3
J
1
0.385
1.0×108
0.50
0.25
invalid, lateral stress off target
2
0.385
1.8×108
0.50
0.25
2.9 %
+0.44
−0.97
+2.69
2.69
3
0.395
1.8×108
0.50
0.50
3.0 %
−0.29
+0.63
+1.25
1.25
4
0.400
2.0×108
0.50
0.50
3.4 %
−0.23
+0.18
+1.31
1.31
5
0.410
2.2×108
0.50
0.70
5.5 %
−0.79
+0.21
+0.61
0.79
Table 7: Parameters and scores of each iteration. εa,peak is the axial strain at the peak deviator stress; e1 , e2 and e3 are the errors of E50 , qpeak and D , each divided by its tolerance τi ( Table 5 ). Iteration 1 is the simulation whose lateral walls reached their velocity cap; its row is kept because the submission was spent.
Figure 8: Convergence of the session. (a) The four parameters declared for each iteration. (b) Signed errors of the three targets, each divided by its tolerance, against iteration; the shaded band is the tolerance, and iteration 1 has no score because its lateral walls reached their velocity cap.
Figure 9: (a) Deviator stress and (b) volumetric strain against axial strain: the test (points), iterations 2 to 4 (thin lines), and iteration 5, the calibrated set (thick line). Iterations 2 to 4 end past their peaks, as the message specified; the calibrated set is shown from a repetition of iteration 5 to 15 % axial strain, which reproduced the session’s curve exactly up to the point where the session had stopped it.
Figure 10: (a) Deviator stress and (b) volumetric strain against axial strain on YADE: the test (points), iterations 1 to 5 (thin lines), and iteration 6, the calibrated set (thick line), shown from a repetition to 15 % axial strain that reproduced the session’s curve exactly over its range.
Figure 11: The third session as a conversation, abridged, read from top to bottom: the modeler’s opening message, the agent’s submission of the task, the modeler’s request while the task was running, and the agent’s tool calls during the task, followed by the agent’s report. The force chains were rendered by the engine’s own viewer at 3.7 % axial strain, near the peak of the deviator stress. The task script contained neither the fabric monitor nor the render.
model
completed
J
submissions
context ( 103 tokens)
USD
Claude Opus 5.5
3/3
0.59–0.95
3–4
85–85
1.69–1.99
GPT-6.1-sol
3/3
0.53–0.99
3–8
45–65
0.36–0.64
Gemini 4 Argon
3/3
0.65–0.83
2–5
138–180
1.93–3.04
Kimi K3
2/3
0.83–1.31
6–12
133–172
2.63–4.93
Qwen3.8-max-0902
3/3
0.53–0.82
3–5
195–256
3.74–6.23
DeepSeek-V4-Pro
3/3
0.58–0.87
6–10
203–403
0.73–1.81
Table 8: Seven language models on the same task as in Section 3.3 , three sessions each; each entry gives the lowest and highest of the three sessions. Completed: sessions that reached J≤1 ; submissions: tasks submitted to the engine; context: tokens in the agent’s context window at the end of the session; USD: cost.
Figure 12: Tool calls of each session, by tool: in green the MCP tools, the documentation tools, execute_code and the task tools, execute_task with check_task_status , interrupt_task and list_tasks ; in blue the agent’s own tools, the shell and the rest. Sessions 1 to 3 of each language model; the session that did not complete is marked.
Figure 13: The parameter set each session ended on, one strip per parameter; sessions 1 to 3 of each language model carry three markers, and the filled marker is the session that did not complete. The axis of each strip spans the range the message allows.
Mistake
Sessions
Solution
The agent wrote q in Pa into the kPa column of the curve file.
The agent read the engine’s error from check_task_status . The agent found the right name in the documentation tools or by trial in execute_code .
The loading walls did not move at the start of shear.
GPT-6.1-sol (1, 2, 3)
In sessions 2 and 3 the agent found zero wall velocity in a read of the running task through execute_code and interrupted the task; in session 1 the agent found a curve without axial strain. The agent corrected the controller.
The lateral servo did not hold the confining stress at its target.
The agent saw it in a read of the running shear through execute_code , or in the recorded lateral stress after the task. The agent corrected the servo.
The agent never called the documentation tools.
Kimi K3 (2)
None. The session did not complete.
Table 9: The mistakes recorded in the twenty-one sessions, by kind, and their solutions. Sessions are numbered as in Figure 12 .
The Model Context Protocol (MCP) standardizes how AI agents discover and invoke external tools, with over 10,000 active servers and 97 million monthly SDK downloads as of early 2026. Yet MCP does not yet standardize how agents safely operate those tools at production scale. Three protocol-level primitives remain missing: identity propagation, adaptive tool budgeting, and structured error semantics. This paper identifies these gaps through field lessons from an enterprise deployment of an AI agent platform integrated with a major cloud provider's MCP servers (client name redacted). We propose three mechanisms to fill them: (1) the Context-Aware Broker Protocol (CABP), which extends JSON-RPC with identity-scoped request routing via a six-stage broker pipeline; (2) Adaptive Timeout Budget Allocation (ATBA), which frames sequential tool invocation as a budget allocation problem over heterogeneous latency distributions; and (3) the Structured Error Recovery Framework (SERF), which provides machine-readable failure semantics that enable deterministic agent self-correction. We organize production failure modes into five design dimensions (server contracts, user context, timeouts, errors, and observability), document concrete failure vignettes, and present a production readiness checklist. All three algorithms are formalized as testable hypotheses with reproducible experimental methodology. Field observations demonstrate that while MCP provides a solid protocol foundation, reliable agent tool integration requires infrastructure-level mechanisms that the specification does not yet address.
Crystal plasticity (CP) simulations predict the mechanical behavior of polycrystalline metals, yet their routine use is hindered by the manual effort of configuring heterogeneous tools, orchestrating multi-step data pipelines, and calibrating constitutive parameters against experiments. These bottlenecks impede productivity in systematic parameter studies, motivating interest in automated workflows. This study presents CP-Agent, a harness-engineered LLM-based agent that autonomously executes complete CP modeling workflows from natural-language tasks. Operating under the ReAct paradigm, the agent reasons about tool selection and sequencing while delegating numerical search to established optimizers. The harness comprises a minimal system prompt, typed tool definitions, a dispatcher, and a safety-bounded iteration loop, encoding domain knowledge through tool schemas rather than hard-coded logic. CP-Agent is demonstrated on four case studies: calibrating four slip parameters of additively manufactured stainless steel 316L against tensile data; validating the workflow against published copper benchmarks, reproducing stress-strain and texture evolution; recovering the initial crystallographic texture of copper, where the agent correctly identifies a diffuse initial texture; and reproducing the multi-pass rolling texture evolution of a Mg-Zn-Ca alloy, where the agent chains five deformation passes and recovers the experimentally observed weakened, split basal texture. In all cases, the agent inferred the correct execution sequence from the task statement, robustly across repeated runs, and delivered physically interpretable results. This work establishes harness engineering as a systematic approach to automating CP modeling workflows while maintaining physical interpretability and auditability through visible reasoning traces.
Samuel Onimpa Alfred, Abhishek Kumar, Veera Sundararaghavan
Department of Aerospace Engineering, University of Michigan, Ann Arbor, 48109, MI, USA
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.