Skip to main content
Glama
Symbolic Algebra MCP Server

Symbolic Algebra MCP Server

calculate_gradient

Computes the gradient of a scalar field expression and returns a key for the resulting vector field, enabling symbolic vector calculus workflows.

Instructions

Calculates the gradient of a scalar field using SymPy's gradient function.

Args:
    scalar_field_key: The key of the scalar field expression.

Example:
    # First create a coordinate system
    create_coordinate_system("R")

    # Create a scalar field f = x^2 + y^2 + z^2
    scalar_field = introduce_expression("R_x**2 + R_y**2 + R_z**2")

    # Calculate gradient
    grad_result = calculate_gradient(scalar_field)
    # Returns (2x, 2y, 2z)

Returns:
    A key for the gradient vector field expression.

Input Schema

NameRequiredDescriptionDefault
scalar_field_keyYes

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.8/5.0
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that the result is a key referencing a gradient vector field expression and gives a concrete expected output (2x, 2y, 2z), which is useful. It does not state what happens on invalid keys, missing coordinate systems, or whether any state is mutated — meaningful gaps for a tool with zero annotation coverage.

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 core purpose is front-loaded in one sentence, followed by Args, a compact example, and Returns. The example is multi-step but each line illustrates a required precondition, so it mostly earns its place.

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?

An output schema exists, so return values need not be spelled out, yet the description adds a helpful prose summary of the return. Combined with the prerequisite example, an agent has what it needs to invoke the tool; only error/failure behavior is absent.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must define the single parameter. 'The key of the scalar field expression' plus the example showing a key produced by introduce_expression gives the agent enough to supply a valid value.

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 first sentence states a specific verb and resource: it computes the gradient of a scalar field, distinguishing it from siblings like calculate_curl and calculate_divergence which operate on vector fields. It stops short of explicitly naming those siblings, so an agent must infer the boundary from domain knowledge.

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

Usage Guidelines4/5

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

The worked example implicitly conveys the prerequisites (a coordinate system must exist, the scalar field must come from introduce_expression) and shows the correct call order. There is no explicit 'use this instead of X' or exclusion guidance, but the ordering context is clear enough to call the tool correctly.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.