java_eval
Execute Python code against a live COMSOL model’s Java API to run custom geometry, solver, or evaluation logic and return computed results.
Instructions
Execute Python code against the live COMSOL Java API (escape hatch).
The code runs inside the COMSOL worker thread. Assign to ``result`` to
return a value. Example:
code='''m = model.java
g = m.geom("geom1") g.run() result = {"domains": g.getNDomains(), "boundaries": g.getNBoundaries()}''' -> {"domains": 1, "boundaries": 6}
Args:
code: Python source. Names available: model, jm, client, mph, jcast,
jset, jget, jprops, tree, jsonify, np.
model: model name/tag for ``model`` (None = current model).
timeout_s: advisory timeout for the tool call.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": {
"code": "<code>"
},
"name": "java_eval"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| model | No | ||
| timeout_s | No |