Skip to main content
Glama

sympy_coeff

Retrieve the coefficient of a variable raised to a given power in a symbolic expression.

Instructions

Get coefficient.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exprYesExpression
xYesVariable
nNoPower of x

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `sympy_coeff` tool handler function. It is decorated with @mcp.tool(), takes expr (string expression), x (variable), and n (power, default 1) as parameters, converts the expression to a SymPy object via _sympify() helper, calls .coeff() on it, and returns the coefficient as a string.
    @mcp.tool()
    def sympy_coeff(expr: str, x: str, n: int = 1) -> str:
        """Get coefficient.
    
        Args:
            expr: Expression
            x: Variable
            n: Power of x
    
        Returns:
            Coefficient as string
    
        Example:
            >>> sympy_coeff("3*x**2 + 2*x + 1", "x", 2)
            "3"
        """
        return str(_sympify(expr).coeff(_sympify(x), n))
  • The _sympify() helper function used by sympy_coeff to convert a string expression into a SymPy Basic object so .coeff() can be called on it.
    def _sympify(expr: str) -> sympy.Basic:
        """Convert string expression to SymPy object."""
        return sympy.sympify(expr)
  • The FastMCP instance (mcp) that registers the tool via the @mcp.tool() decorator on line 1704.
    mcp = fastmcp.FastMCP("mcp-sympy")
  • Module imports, including fastmcp and sympy, used by the sympy_coeff handler.
    """MCP tools that expose SymPy's symbolic mathematics functionality."""
    
    import fastmcp
    import sympy
    from sympy import (
Behavior1/5

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

No annotations are present, and the description provides no behavioral details. It does not disclose what happens for invalid inputs, non-polynomial expressions, or when the coefficient is zero. The agent cannot anticipate side effects or error conditions.

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

Conciseness2/5

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

The description is extremely short (two words), which sacrifices necessary information. Conciseness should not come at the cost of clarity; here it is under-specified and fails to earn its place by not providing critical context.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Although an output schema exists, the description does not explain return values or usage context. Given that the tool extracts coefficients from symbolic expressions (a non-trivial operation), the description is vastly incomplete for correct agent use.

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

Parameters3/5

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

The input schema has 100% coverage with minimal descriptions for each parameter. The tool description adds no extra meaning beyond what the schema provides. Per the guidelines, baseline 3 is appropriate since schema coverage is high, even though schema descriptions are also sparse.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description only says 'Get coefficient,' which is minimally more than the name. It neither specifies the type of coefficient nor the mathematical context (e.g., polynomial coefficient). Among many sibling tools like sympy_degree, sympy_derivative, it does not distinguish itself clearly.

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

Usage Guidelines2/5

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

No usage guidance is provided. The description does not indicate when to use this tool versus alternatives such as sympy_coeff, sympy_degree, or sympy_derivative. The agent has no help in deciding which tool to select.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/daedalus/mcp-sympy'

If you have feedback or need assistance with the MCP directory API, please join our Discord server