Skip to main content
Glama
Symbolic Algebra MCP Server

Symbolic Algebra MCP Server

differentiate_expression

Computes symbolic derivatives of an expression with respect to a chosen variable, supports higher-order differentiation, and returns a key for the resulting expression.

Instructions

Differentiates an expression with respect to a variable using SymPy's diff function.

Args:
    expr_key: The key of the expression (previously introduced) to differentiate.
    var_name: The name of the variable to differentiate with respect to.
    order: The order of differentiation (default is 1 for first derivative).

Example:
    # Introduce a variable
    intro("x", [Assumption.REAL], [])

    # Create an expression to differentiate: x^3
    expr_key = introduce_expression("x**3")

    # First derivative
    first_deriv = differentiate_expression(expr_key, "x")
    # Returns 3x²

    # Second derivative
    second_deriv = differentiate_expression(expr_key, "x", 2)
    # Returns 6x

Returns:
    A key for the differentiated expression.

Input Schema

NameRequiredDescriptionDefault
orderNo
expr_keyYes
var_nameYes

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.1/5.0
Behavior3/5

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

With no annotations, the description must carry the full behavioral burden. It does disclose the key-in/key-out pattern (returns a key for the new expression) and the example implies variable prerequisites, but it never says what happens if var_name was not introduced or does not appear in the expression, nor any error behavior.

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, then Args, then a compact worked example showing first and second derivatives. The trailing Returns line duplicates the output schema and is minor waste, but overall the structure is efficient and scannable.

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 little prose, and the example plus Args are sufficient to call the tool correctly for common cases. Edge-case behavior (unknown variable, negative order) is the only meaningful gap.

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 Args block is doing real work: it explains that expr_key refers to a previously introduced expression, that var_name is the variable of differentiation, and that order defaults to 1. It stops short of clarifying whether order must be positive or what an order of 0 yields.

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 first sentence states a specific verb (differentiates) and resource (an expression with respect to a variable) and names the underlying operation (SymPy's diff), which cleanly separates it from integrate_expression, series_expansion and other calculus siblings.

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 makes the prerequisite explicit: the expression must be created first via introduce_expression and the variable must exist via intro. It does not name alternatives or state when not to use it (e.g. symbolic vs numeric), so it falls short of a 5.

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