Skip to main content
Glama
Symbolic Algebra MCP Server

Symbolic Algebra MCP Server

factor_expression

Factors polynomials and rational expressions over rationals, Gaussian rationals, or a finite field, returning a key to the factored result for symbolic algebra workflows.

Instructions

Factors a polynomial or rational expression using SymPy's factor function.

By default the factorization is over the rationals. Equations are factored side by side.

Args:
    expr_key: The key of the expression (previously introduced) to factor.
    gaussian: If True, factor over the Gaussian rationals Q(i), e.g. x**2 + 1 = (x - i)(x + i).
    modulus: Optional prime p to factor over the finite field GF(p).

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

Returns:
    A key for the factored expression.

Input Schema

NameRequiredDescriptionDefault
modulusNo
expr_keyYes
gaussianNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.9/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 behavioral burden. It usefully discloses the default factorization domain, the side-by-side treatment of equations, and that the return value is a key for the factored expression. It does not cover error behavior for invalid or non-polynomial expressions, whether the tool mutates or extends state, or constraints on the modulus being prime beyond the prose 'prime p'.

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 first sentence states the core operation immediately, and the subsequent Args, Example, and Returns sections are well structured and free of redundancy. The example is long but earns its place by showing the key-based workflow and expected factored output.

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 output schema exists, so the description need not document the exact return shape, and it appropriately says the return is a key. Given the absence of annotations, it could still say more about state effects and failure modes, but for a well-defined mathematical factoring operation it is largely complete.

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

Parameters5/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 do all the work, and it does: expr_key is the key of a previously introduced expression; gaussian means factoring over Q(i) with a concrete example; modulus is an optional prime p for factoring over GF(p). These explanations add substantial meaning beyond the bare schema titles.

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 gives a specific verb and resource: it factors a polynomial or rational expression, and it names the underlying SymPy operation. It is clear what the tool does, but it does not explicitly distinguish itself from related sibling tools such as expand_expression, cancel_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 description explains the default domain (rationals) and the two alternative domains (Gaussian rationals and finite fields), which implies when the optional parameters matter. However, it never states when to choose factor_expression over related symbolic-manipulation siblings, nor does it give exclusions or prerequisites beyond noting that expr_key must have been previously introduced.

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