Skip to main content
Glama

analyze_formula

Analyzes mathematical properties of formulas, including domain, range, and critical points, to support mathematical visualization and computation.

Instructions

Analyzes mathematical properties of a formula (domain, range, critical points).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formulaYes
analysis_typeNobasic

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The @mcp.tool()-decorated handler function that implements the core logic of 'analyze_formula'. It parses the formula with sympy, computes domain, range (for detailed), or critical points based on analysis_type, and returns formatted results.
    @mcp.tool()
    def analyze_formula(formula: str, analysis_type: AnalysisType = "basic") -> str:
        """Analyzes mathematical properties of a formula (domain, range, critical points)."""
        try:
            x = sympy.symbols('x')
            expr = sympy.sympify(formula)
            results = [f"Analysis for '{formula}' ('{analysis_type}' type):"]
            if analysis_type == "basic" or analysis_type == "detailed":
                domain = continuous_domain(expr, x, sympy.S.Reals)
                results.append(f"- Domain: {domain}")
            if analysis_type == "detailed":
                f_range = function_range(expr, x, domain)
                results.append(f"- Range: {f_range}")
            if analysis_type == "critical_points":
                derivative = sympy.diff(expr, x)
                results.append(f"- Derivative: {derivative}")
                critical_points = sympy.solveset(derivative, x, domain=sympy.S.Reals)
                if not critical_points:
                    results.append("- Critical Points: None found.")
                else:
                    results.append(f"- Critical Points: {critical_points}")
            return "\n".join(results)
        except Exception as e:
            return f"Error analyzing formula '{formula}'. Details: {e}"
  • AnalysisType Literal type definition used for the analysis_type parameter in the tool's input schema, specifying 'basic', 'detailed', or 'critical_points'.
    AnalysisType = Literal["basic", "detailed", "critical_points"]
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't describe how it behaves: no information on computational complexity, error handling for invalid formulas, output format details (though an output schema exists), or whether this is a read-only operation. For a tool with no annotations, this leaves significant behavioral gaps.

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 a single, efficient sentence that front-loads the core purpose. Every word earns its place: 'analyzes' (verb), 'mathematical properties' (scope), 'formula' (resource), and specific examples in parentheses. There's zero waste or redundancy.

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?

Given the tool's moderate complexity (2 parameters, one with enum), no annotations, and the presence of an output schema, the description is minimally adequate. The output schema reduces the need to explain return values, but the description lacks details on behavioral traits and parameter usage. It's complete enough for basic understanding but has clear gaps in guidance and transparency.

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?

Schema description coverage is 0%, so the schema provides no parameter descriptions. The description mentions 'analysis_type' implicitly through the examples (domain, range, critical points), which correspond to the enum values, but doesn't explain the 'formula' parameter's format or constraints. It adds some meaning beyond the bare schema but doesn't fully compensate for the coverage gap, especially for the required 'formula' 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?

The description clearly states the verb 'analyzes' and the resource 'mathematical properties of a formula', with specific examples (domain, range, critical points). It distinguishes from siblings like 'plot_math_function' or 'validate_formula' by focusing on analysis rather than visualization or validation. However, it doesn't explicitly differentiate from all siblings (e.g., 'hello' is unrelated).

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose 'analyze_formula' over 'validate_formula' for formula checking, or when analysis is preferred over plotting with 'plot_math_function'. There are no explicit when/when-not statements or named alternatives.

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/TheGrSun/Desmos-MCP'

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