Skip to main content
Glama

sympy_piecewise

Define piecewise functions by specifying expression-condition pairs separated by semicolons.

Instructions

Create piecewise function (format: "expr,condition; expr2,condition2").

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pairsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the sympy_piecewise tool. Parses a semicolon-separated list of 'expr,condition' pairs, sympifies each, and constructs a SymPy Piecewise object.
    @mcp.tool()
    def sympy_piecewise(pairs: str) -> str:
        """Create piecewise function (format: "expr,condition; expr2,condition2")."""
        pieces = []
        for pair in pairs.split(";"):
            expr_str, cond = pair.split(",")
            pieces.append((_sympify(expr_str.strip()), _sympify(cond.strip())))
        return str(Piecewise(*pieces))
  • Registration via the @mcp.tool() decorator on the FastMCP instance 'mcp' at line 119.
    @mcp.tool()
    def sympy_piecewise(pairs: str) -> str:
  • Helper function used by the handler to convert string expressions to SymPy objects.
    def _sympify(expr: str) -> sympy.Basic:
        """Convert string expression to SymPy object."""
        return sympy.sympify(expr)
  • Input schema: a single string parameter 'pairs'. Output: a string (the string representation of the Piecewise object).
    def sympy_piecewise(pairs: str) -> str:
        """Create piecewise function (format: "expr,condition; expr2,condition2")."""
        pieces = []
        for pair in pairs.split(";"):
            expr_str, cond = pair.split(",")
            pieces.append((_sympify(expr_str.strip()), _sympify(cond.strip())))
        return str(Piecewise(*pieces))
Behavior2/5

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

No annotations are provided, so the description should disclose behavior beyond 'create'. It does not mention any side effects, error handling, or that the output is a sympy expression. Limited transparency.

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?

Single sentence, no filler, front-loaded with the purpose. Excellent conciseness.

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

Completeness3/5

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

While the tool is simple with one parameter, the description lacks any usage examples, error handling notes, or details about the output schema. Adequate but not comprehensive.

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?

The schema only specifies a string type for 'pairs' with 0% description coverage. The description supplies the format 'expr,condition; expr2,condition2', adding significant meaning beyond the schema.

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 description clearly states this tool creates a piecewise function and provides the required format. The name and verb+resource are specific, and it is distinct from all sibling tools.

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 guidance is given on when to use this tool versus alternatives like sympy_sympyfunc or sympy_piecewise integration tools (if any). The agent must infer usage context.

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