Skip to main content
Glama
loumalouomega

Kratos MCP Server

session_exec_python

Execute custom Python inside a Kratos session to access models, stages, and parameters, returning result or stdout when built-in tools are insufficient.

Instructions

Run Python inside the session's Kratos process for anything the typed tools do not cover. The namespace holds KM (KratosMultiphysics), model, stage (the AnalysisStage), session, parameters; assign a JSON-serialisable value to result to get it back, and print() output is returned as stdout. Example: result = model['Structure'].GetNode(75).X.

DISABLED unless the MCP server was started with KRATOS_MCP_ALLOW_EXEC=1, because it executes arbitrary code as the server's user.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
session_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.9.0

TDQS

A4.6/5.0
Behavior5/5

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

No annotations are provided, so the description carries the full burden — and it does: it discloses the disabled-by-default gate, the security implication (arbitrary code as the server's user), the namespace bindings, the return contract (assign to `result`), and stdout capture. This is exactly the operational context annotations would otherwise supply.

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?

Front-loaded with purpose, then a dense but useful clause on namespace/return semantics, then the critical gating warning. Every sentence earns its place; the middle sentence is packed but justified for an exec tool.

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?

For a two-parameter code-execution tool with an output schema, the description covers the escape-hatch role, the runtime contract, the return mechanism, and the activation requirement. Nothing an agent needs to invoke it safely is missing beyond the minor session_id gap.

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 0%, so the description must compensate. It explains the `code` parameter's contract well (namespace, `result` assignment, print/stdout) and gives a concrete example, but `session_id` is never mentioned despite being required — an agent must infer it selects the target process.

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?

States a specific verb (run) and resource (Python in the session's Kratos process) and explicitly positions itself as the escape hatch for cases the typed tools do not cover, which distinguishes it from the many session_* and mdpa_* siblings.

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?

Names the exact condition for use ('anything the typed tools do not cover') and the hard precondition (DISABLED unless KRATOS_MCP_ALLOW_EXEC=1), including the reason. An agent knows both when to reach for it and when it will fail.

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

Deploy Server

Other Tools