Skip to main content
Glama
Ching-Chiang

comsol-mcp

by Ching-Chiang

ensure_component

Create or verify a component with specified name and dimension in the active COMSOL model, ensuring it is available for further modeling steps.

Instructions

Ensure a component exists in the selected server-side model.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentNocomp1
dimensionNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core Java-based handler that ensures a component exists in the COMSOL model. If the component tag is not yet present, it creates it via the Java API.
    def _ensure_component_java(model: Any, component: str, dimension: int) -> dict[str, Any]:
        java = model.java
        if component not in list(java.component().tags()):
            java.component().create(component, True)
        return {"component": component, "dimension": dimension}
  • MCP tool registration for 'ensure_component'. Decorated with @mcp.tool(), defines the public interface with parameters (component, dimension), and dispatches via _run_tool to the inner _impl handler.
    @mcp.tool()
    def ensure_component(component: str = "comp1", dimension: int = 2) -> str:
        """Ensure a component exists in the selected server-side model."""
    
        def _impl() -> dict[str, Any]:
            return _ensure_component_java(_require_model(), component.strip() or "comp1", int(dimension))
    
        return _run_tool("ensure_component", _impl)
  • Tool signature acts as the schema: component (str, default 'comp1') and dimension (int, default 2).
    def ensure_component(component: str = "comp1", dimension: int = 2) -> str:
  • _run_tool is the generic execution wrapper used by ensure_component (and all other tools) to handle logging, locking, and result/error 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))
Behavior2/5

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

No annotations provided, so description must disclose behavior. It implies idempotency but does not clarify what happens if component already exists (no-op vs update). No mention of side effects, permissions, or error conditions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence is concise, but at the cost of omitting essential details. Not a model of efficient communication.

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?

Given 2 parameters with no descriptions, and existence of output schema, the description fails to provide sufficient context about prerequisites, behavior, or return values.

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?

Schema has 0% parameter descriptions. The description adds no explanation for 'component' or 'dimension', leaving the agent to guess their meaning and valid values.

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?

Description clearly states the action (ensure existence) and resource (component) and context (selected server-side model). However, it does not differentiate from sibling tools like ensure_geometry or ensure_mesh, which also create/verify entities.

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 guidance on when to use this tool versus alternatives, such as ensure_geometry or ensure_mesh. No prerequisites or conditions mentioned.

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