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.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"session_id": "<session_id>",
"code": "<code>"
},
"name": "session_exec_python"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| session_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||