Skip to main content
Glama
CalcsLive

CalcsLive MCP Server

by CalcsLive

calcslive_run_script

Execute unit-aware calculations using Physical Quantity scripts. Define inputs and outputs with symbols, values, units, and expressions to perform engineering calculations with automatic unit conversion and dependency resolution.

Instructions

Run stateless unit-aware calculations from Physical Quantity (PQ) script definitions. Define inputs and outputs as PQ objects with symbols, values, units, and expressions. No article creation needed - fully stateless. Automatically handles unit conversions, dependency graphs, and Greek letters. Example: Calculate circle area from radius using expression 'pi * r^2'.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pqsYesArray of Physical Quantity definitions. Each PQ can be an input (with value) or output (with expression).
inputsNoOptional: Override input PQ values. Example: {r: {value: 5, unit: 'cm'}}
outputsNoOptional: Specify output unit preferences. Example: {A: {unit: 'mm²'}}

Implementation Reference

  • Handler for executing the calcslive_run_script tool: extracts pqs, inputs, outputs; POSTs to CalcsLive API /articles/uac-script/run; formats human-readable results and detailed calculation for MCP response.
    if (request.params.name === "calcslive_run_script") {
      const { pqs, inputs = {}, outputs = {} } = request.params.arguments as any;
    
      try {
        const response = await fetch(`${CALCSLIVE_API_BASE}/api/v1/articles/uac-script/run`, {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            apiKey: API_KEY,
            pqs,
            inputs,
            outputs
          }),
        });
    
        if (!response.ok) {
          const errorData = await response.json() as any;
          throw new Error(errorData.error?.message || `API error: ${response.status}`);
        }
    
        const result = await response.json() as any;
    
        // Format response for MCP - use humanReadable for better AI consumption
        const humanReadable = result.data.humanReadable;
        const calculation = result.data.calculation;
    
        return {
          content: [
            {
              type: "text",
              text: `${humanReadable.summary}\n\nResults:\n${humanReadable.results.map((r: any) =>
                `• ${r.description} (${r.symbol}): ${r.result}${r.expression ? ` = ${r.expression}` : ''}`
              ).join('\n')}\n\nDetailed calculation:\n${JSON.stringify(calculation, null, 2)}`,
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text",
              text: `Error running script calculation: ${error.message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • src/index.ts:97-167 (registration)
    Tool registration in listTools handler: defines name, description, and detailed inputSchema for calcslive_run_script, including pqs array structure, optional inputs/outputs overrides.
    {
      name: "calcslive_run_script",
      description: "Run stateless unit-aware calculations from Physical Quantity (PQ) script definitions. Define inputs and outputs as PQ objects with symbols, values, units, and expressions. No article creation needed - fully stateless. Automatically handles unit conversions, dependency graphs, and Greek letters. Example: Calculate circle area from radius using expression 'pi * r^2'.",
      inputSchema: {
        type: "object",
        properties: {
          pqs: {
            type: "array",
            description: "Array of Physical Quantity definitions. Each PQ can be an input (with value) or output (with expression).",
            items: {
              type: "object",
              properties: {
                sym: {
                  type: "string",
                  description: "Symbol name for this PQ (e.g., 'r', 'v', 'A'). Supports Greek letters (α, β, η, ρ, etc.)."
                },
                description: {
                  type: "string",
                  description: "Human-readable description (e.g., 'radius', 'velocity', 'area')"
                },
                value: {
                  type: "number",
                  description: "Numeric value for input PQs. Omit for calculated outputs."
                },
                unit: {
                  type: "string",
                  description: "Unit (e.g., 'm', 'kg', 'kW'). Supports superscript (m³) and caret (m^3) notation."
                },
                expression: {
                  type: "string",
                  description: "Mathematical expression for calculated PQs (e.g., 'pi * r^2', 'v / t'). References other PQ symbols."
                },
                calcId: {
                  type: "string",
                  description: "Optional namespace for multi-calculation contexts (default: 'CA0')"
                },
                decimalPlaces: {
                  type: "number",
                  description: "Decimal places for display (default: 3)"
                }
              },
              required: ["sym", "unit"]
            },
            minItems: 1
          },
          inputs: {
            type: "object",
            description: "Optional: Override input PQ values. Example: {r: {value: 5, unit: 'cm'}}",
            additionalProperties: {
              type: "object",
              properties: {
                value: { type: "number" },
                unit: { type: "string" }
              },
              required: ["value", "unit"]
            }
          },
          outputs: {
            type: "object",
            description: "Optional: Specify output unit preferences. Example: {A: {unit: 'mm²'}}",
            additionalProperties: {
              type: "object",
              properties: {
                unit: { type: "string" }
              }
            }
          }
        },
        required: ["pqs"]
      }
    },
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key traits: 'stateless' (no persistence), 'automatically handles unit conversions, dependency graphs, and Greek letters' (functionality), and 'No article creation needed' (scope limitation). However, it lacks details on error handling, performance limits (e.g., computation time), or output format, which are important for a calculation tool.

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 description is appropriately sized and front-loaded: the first sentence states the core purpose, followed by key features and an example. Each sentence adds value (e.g., explaining statelessness, automation features). It could be slightly more structured by separating usage notes from features, but it avoids redundancy and is efficient.

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

Completeness3/5

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

Given the complexity (3 parameters with nested objects, no output schema, no annotations), the description is moderately complete. It covers the tool's purpose, key behaviors, and provides an example, but lacks details on output format, error cases, or how it differs from siblings. For a stateless calculation tool with rich input schema, more contextual guidance would be beneficial.

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 description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds some context by mentioning 'Define inputs and outputs as PQ objects' and providing an example, but it doesn't explain parameter semantics beyond what the schema provides (e.g., how 'pqs' array interacts with 'inputs'/'outputs' overrides). This meets the baseline for high schema coverage.

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?

The description clearly states the tool's purpose: 'Run stateless unit-aware calculations from Physical Quantity (PQ) script definitions.' It specifies the verb ('Run'), resource ('calculations'), and key characteristics ('stateless', 'unit-aware', 'from PQ script definitions'). However, it doesn't explicitly differentiate from sibling tools like 'calcslive_calculate' or 'calcslive_validate', which prevents a perfect score.

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 description implies usage context by stating 'No article creation needed - fully stateless' and providing an example, which suggests this tool is for one-off calculations. However, it doesn't explicitly state when to use this tool versus its siblings ('calcslive_calculate', 'calcslive_validate'), nor does it mention any prerequisites or exclusions. The guidance is present but not comprehensive.

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/CalcsLive/calcslive-mcp-server'

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