Skip to main content
Glama
Symbolic Algebra MCP Server

Symbolic Algebra MCP Server

cancel_expression

Simplifies a rational expression to canonical p/q form by cancelling common factors, making it easier to analyze or compare algebraic expressions.

Instructions

Puts a rational expression in canonical form p/q with common factors cancelled.

Uses SymPy's cancel function. Cancellation is formal: (x**2 - 1)/(x - 1)
becomes x + 1, even though the original is undefined at x = 1.

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

Example:
    intro("x", [Assumption.REAL], [])
    expr_key = introduce_expression("(x**2 - 1)/(x**2 - 2*x + 1)")
    result_key = cancel_expression(expr_key)
    # (x + 1)/(x - 1)

Returns:
    A key for the simplified rational 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.7/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 behavioral burden. It helpfully discloses that cancellation is formal and may change the domain, e.g. (x**2 - 1)/(x - 1) becomes x + 1 despite the original being undefined at x = 1. It does not state whether the original expression is mutated, how errors are handled for invalid keys, or what side effects occur.

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

Conciseness5/5

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

The description is front-loaded with the core purpose, followed by a concise Args section, a concrete example, and a short Returns note. Every section earns its place by clarifying usage or output for a new user.

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?

The tool has one parameter and an output schema, so the description does not need to explain return values in depth. It supplies the key mathematical caveat and an example, leaving only minor gaps around error behavior and interactions with sibling simplification tools.

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%, and the input schema only names the parameter as Expr Key. The description compensates well by explaining that expr_key is the key of a previously introduced expression to cancel, which is sufficient semantic guidance for the single required parameter.

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: canonicalizing a rational expression by cancelling common factors into p/q form. It clearly distinguishes the operation from general simplification through its formal cancellation example, but it does not name or contrast with sibling tools such as factor_expression or apart_expression.

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 example implies the intended workflow: first introduce an expression, then call cancel_expression with its key. However, there is no explicit guidance on when to use this tool versus simplify_expression, factor_expression, expand_expression, or apart_expression, so usage must be inferred.

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