Skip to main content
Glama
COMSOL Multiphysics MCP Server

COMSOL Multiphysics MCP Server

by zixuanguo89

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

NameRequiredDescriptionDefault
codeYes
modelNo
timeout_sNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations, the description carries the full burden and does disclose real behavior: code runs in the COMSOL worker thread, values are returned by assigning to ``result``, and timeout_s is advisory. It omits important traits for arbitrary code execution — whether model mutations persist, what happens on exceptions, and whether failures can leave the session in a bad state.

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 one-line purpose is front-loaded, followed by the return convention, a worked example, and per-argument notes. The example is long but earns its place by showing exactly how to return a value; minor redundancy between the intro and the Args block.

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

Completeness4/5

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

For a code-execution tool with no annotations and no output schema, the description covers the essentials: execution context, how to return a value (with a sample input/output pair), and all three arguments. Error handling and side-effect persistence are the notable omissions.

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, and it partly does: it enumerates the names available in scope, documents that model=None means the current model, and clarifies that timeout_s is advisory. Remaining gaps are that 'model name/tag' is ambiguous and the timeout unit/behavior when exceeded is not explained.

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

Purpose4/5

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

States a concrete verb and resource — execute Python source against the live COMSOL Java API — and labels itself an 'escape hatch', which signals a distinct role. It does not explicitly contrast with sibling tools such as export_model_java, but the purpose is unambiguous without opening the schema.

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

Usage Guidelines3/5

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

The parenthetical '(escape hatch)' implies this is a fallback for cases the structured tools don't cover, which is useful implied guidance. However, it never states when to prefer this over the numerous catalog_* / result_eval_* siblings, nor when it should be avoided.

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