Skip to main content
Glama

pfc_execute_code

Execute Python code in the PFC model to query state, create plots, or inspect variables, returning output immediately without tracking or cancellation.

Instructions

Execute Python code synchronously in the running PFC process.

Returns stdout and an optional result variable immediately. Code runs in the PFC main thread; side effects persist.

Scheduling: This tool remains available whether PFC is cycling or idle — you can query model state while a task is running.

Environment: PFC embedded Python 3.6.

Typical uses:

  • Query model state: ball/wall/contact counts, current cycle

  • Create and export plots: itasca.command('plot ...')

  • Read or set properties, inspect variables

  • Development and REPL-style testing

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

WARNING: Avoid blocking calls (model.solve with many cycles, long loops). They block the PFC main thread until completion or timeout, and cannot be cancelled. Use pfc_execute_task for anything that may run longer than a few seconds.

WARNING: This code shares the Python namespace with any running task. Avoid overwriting variables the task depends on (e.g. the callback function or simulation objects). Use unique names for throwaway variables to prevent conflicts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesPython code to execute in PFC user console
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?

No annotations provided, so description carries full burden. It fully discloses synchronous execution, side effects persistence, shared namespace, blocking risks, inability to cancel or poll, and availability during cycling/idle states. This exceeds typical transparency.

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

Conciseness5/5

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

Well-structured with clear sections (Returns, Scheduling, Environment, Typical uses, Comparison, Warnings). Information is front-loaded and every sentence adds value. Appropriate length given complexity.

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 presence of an output schema and complete schema coverage, the description covers all necessary aspects: purpose, usage, warnings, limitations, and alternative tools. No gaps identified.

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% and descriptions already cover parameters adequately. The description adds no new semantic details beyond what the schema provides (e.g., code string, timeout with defaults). Baseline 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 it executes Python code synchronously in the PFC process. It distinguishes from sibling pfc_execute_task by emphasizing fire-and-return behavior and lack of tracking, and lists typical use cases (query state, create plots, REPL testing).

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?

Provides explicit when-to-use (state queries, plots) and when-not-to-use (blocking calls, long loops). Clearly contrasts with pfc_execute_task for long-running tasks. Also warns about namespace conflicts with running tasks.

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/pfc-mcp'

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