Skip to main content
Glama
Ching-Chiang

comsol-mcp

by Ching-Chiang

set_parameters

Set multiple global parameters on a shared server-side model in COMSOL Multiphysics for collaborative modeling.

Instructions

Set multiple global parameters on the selected server-side model.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
parameters_jsonYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Definition of the 'set_parameters' MCP tool. Decorated with @mcp.tool(), it takes a JSON string of parameters, parses them, and sets each on the COMSOL model via model.java.param().set(name, expression). Returns updated parameters and count.
    @mcp.tool()
    def set_parameters(parameters_json: str) -> str:
        """Set multiple global parameters on the selected server-side model."""
    
        def _impl() -> dict[str, Any]:
            model = _require_model()
            parsed = json.loads(parameters_json)
            if not isinstance(parsed, list):
                raise ValueError("parameters_json must be a JSON array.")
            updated = []
            for item in parsed:
                if not isinstance(item, dict):
                    raise ValueError("Each parameter entry must be an object.")
                name = str(item.get("name", "")).strip()
                expression = str(item.get("expression", "")).strip()
                if not name:
                    raise ValueError("Parameter name is required.")
                model.java.param().set(name, expression)
                updated.append({"name": name, "expression": expression})
            return {"updated": updated, "count": len(updated)}
    
        return _run_tool("set_parameters", _impl)
  • Registration call: return _run_tool('set_parameters', _impl) — triggers the tool via the runtime lock and error handling framework.
    return _run_tool("set_parameters", _impl)
  • _run_tool helper — wraps the tool callback with logging, a runtime lock, error handling, and result formatting.
    def _run_tool(tool: str, callback) -> str:
        _setup_logging()
        with _runtime_lock:
            try:
                data = callback()
                return _tool_result(tool, True, data=data)
            except Exception as exc:
                logging.exception("Tool %s failed", tool)
                return _tool_result(tool, False, error=str(exc))
  • _tool_result helper — formats the tool result JSON payload with success, data, error, server status, and appends to operations log.
    def _tool_result(tool: str, success: bool, data: dict[str, Any] | None = None, error: str = "") -> str:
        global _last_command, _last_error
        _last_command = tool
        _last_error = error
        payload = {
            "success": success,
            "tool": tool,
            "timestamp": time.time(),
            "datetime": _now_iso(),
            "server": _status_payload(),
            "data": data or {},
            "error": error,
            "log_path": str(SERVER_LOG),
            "operations_path": str(OPERATIONS_FILE),
        }
        _append_operation(
            {
                "tool": tool,
                "success": success,
                "error": error,
                "data": data or {},
            }
        )
        _write_status({"last_command": tool, "last_error": error})
        return _json(payload)
Behavior2/5

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

With no annotations, the description must disclose behavior. It fails to explain safety (e.g., mutation effects), required permissions, or how parameters are updated (overwrite vs merge). Only a minimal action statement is provided.

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?

Single sentence, efficient and front-loaded. However, it is slightly too terse, missing necessary detail around parameter usage.

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

Completeness2/5

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

Despite having an output schema, the tool is incomplete: the parameter's format is unexplained, and no behavioral context is given. For a tool with one parameter, more detail is expected.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The sole parameter 'parameters_json' has no schema description (0% coverage). The description does not clarify the expected format (e.g., JSON string with key-value pairs), leaving the agent unable to construct a proper value.

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 the action ('Set') and the resource ('global parameters on the selected server-side model'), which is specific and distinct from siblings like get_parameters.

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

Usage Guidelines2/5

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

No explicit guidance on when to use this tool versus alternatives (e.g., get_parameters for reading), nor any prerequisites or conditions. Usage is only implied.

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/Ching-Chiang/comsol-mcp'

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