Skip to main content
Glama
Symbolic Algebra MCP Server

Symbolic Algebra MCP Server

expand_expression

Expands algebraic expressions by distributing products and integer powers of sums, including expanding equations side by side.

Instructions

Expands an expression algebraically using SymPy's expand function.

Distributes products and expands integer powers of sums. Equations are expanded side by side.

Args:
    expr_key: The key of the expression (previously introduced) to expand.

Example:
    intro("x", [Assumption.REAL], [])
    expr_key = introduce_expression("(x + 1)**3")
    result_key = expand_expression(expr_key)
    # x^3 + 3x^2 + 3x + 1

Returns:
    A key for the expanded expression.

Input Schema

NameRequiredDescriptionDefault
expr_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?

With no annotations, the description carries the full burden. It does disclose useful behavior — that the result is a new key, and that equations are expanded side by side — but it never says whether the original expression is preserved or mutated, nor what happens if expr_key is unknown or the expression cannot be expanded. That is a meaningful gap for a mutation-capable algebra 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?

Front-loaded with the verb and mechanism, then a compact example that demonstrates input and expected output. The Args/Returns block is slightly redundant given the output schema, and the `intro(...)` line in the example adds incidental noise, but nothing is padded.

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?

For a one-parameter tool with an output schema, the description supplies mechanism, prerequisite, and a worked example, which is close to sufficient. The missing pieces are failure behavior and whether the source expression is left intact — details an agent would want before calling a destructive-looking transform.

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 carry the parameter, and its arg doc does explain that expr_key is the key of a previously introduced expression. That is the essential semantic (an opaque handle produced by introduce_expression) and it is stated clearly, though it doesn't describe the expected key format.

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?

States a specific verb and resource ("Expands an expression algebraically") and adds a concrete mechanism (SymPy expand, distribution of products, integer powers of sums). It doesn't explicitly contrast with close siblings like factor_expression, simplify_expression or series_expansion, so an agent must infer the boundary from the verb alone.

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 example makes the call context clear: the expression must already be introduced via introduce_expression, and the "previously introduced" note in the arg doc reinforces this. It gives no explicit when-not guidance or named alternatives (e.g., use factor_expression to go the other direction), so the agent still has to reason about applicability.

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