Skip to main content
Glama

yade_execute_code

Execute Python code in the YADE process to inspect or modify simulation state in real time, with immediate output and no task tracking.

Instructions

Execute Python code synchronously in the running YADE process.

Returns stdout immediately. Code runs in the YADE Python environment where yade modules are already imported; side effects persist.

This tool remains responsive EVEN WHILE a simulation task is running (submitted via yade_execute_task). Use it as a live REPL to inspect simulation state in real time — no need to pre-script print statements.

Typical uses:

  • Query simulation state: O.bodies count, current iteration

  • Create/modify bodies, engines, interactions

  • Read or set material properties

  • Live inspection during a running simulation (e.g. check stress tensor, coordination number, energy balance, or capture viewport screenshots when GUI is available)

  • Development and REPL-style testing

Unlike yade_execute_task, this tool is fire-and-return: the response contains the full output. It is NOT tracked by yade_list_tasks and cannot be interrupted or polled.

Timeout behaviour: on timeout the bridge attempts to abort the running code via an async exception injection. Two outcomes:

  • status="terminated" — abort succeeded; the pump thread is free, but YADE state may be partially modified by the code that ran before the abort fired. Inspect state before retrying.

  • status="timeout" — abort failed (code stuck in a C extension, or nested inside a running task's PyRunner tick); the bridge may still be blocked. Restart if unresponsive.

WARNING: For anything expected to take more than a few seconds, use yade_execute_task instead — it has proper cancellation via yade_interrupt_task and does not leave state drift on timeout. Also, do NOT write except BaseException: in your code; it defeats bridge-initiated cancellation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesPython code to execute in YADE process
timeoutNoConsole execution timeout in seconds

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It thoroughly explains timeout behavior, including two possible outcomes (status='terminated' and status='timeout'), side-effect persistence, and the fact that the tool remains responsive during a running simulation. This is highly transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with sections, bullet points, and clear warnings. It is moderately long but each part adds value. Minor redundancy but overall efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity and absence of annotations, the description covers purpose, usage, behavior, timeout mechanisms, side effects, and warnings comprehensively. It also provides typical use cases and differentiates from sibling tools. The output schema exists to clarify return values.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with both parameters described. The description adds context that code runs in YADE environment with pre-imported modules, but this does not add significant meaning beyond the schema. Baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states that the tool executes Python code synchronously in the YADE process and returns stdout. It lists typical uses like querying simulation state and modifying bodies. It differentiates from sibling yade_execute_task by emphasizing fire-and-return behavior and real-time inspection.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly recommends using yade_execute_task for operations expected to take more than a few seconds due to proper cancellation and no state drift. It also warns against catching BaseException to avoid defeating cancellation. This provides clear when-to-use and when-not-to-use guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yusong652/yade-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server