A mathematical expression evaluator MCP server using asteval for safe expression evaluation
This server has significant quality gaps across naming, descriptions, and schema consistency. There are 4 tools registered, but 3 are duplicates named 'calculate' with identical or near-identical descriptions. The tool definitions visible in calculator_mcp_first_approach.py show basic schemas and descriptions, but lack depth in error handling guidance, parameter constraints, and output documentation. The schema for parameters is present but minimal. Descriptions are present but generic and do not follow the 50-200 character LLM-optimized baseline. No input validation constraints (enums, min/max) are visible. Error handling relies on ValueError without recovery guidance. The 'calculate_with_steps' tool references a deprecated Context.sample() pattern, indicating reliance on removed Sampling capability.
Evaluate a mathematical expression and return the result.
Evaluate a mathematical expression.
Evaluate a mathematical expression.
Evaluate a mathematical expression and show the calculation steps.
Three duplicate tools named 'calculate' with minimal description variation (only first has full docstring with examples, other two have bare 20-char descriptions). This violates single responsibility and creates ambiguity, LLM cannot distinguish which to invoke.
Parameter descriptions are minimal. 'expression' is described as 'A string containing a mathematical expression' in all tools, lacking constraint info (valid operators, supported functions, length limits, disallowed operations).
calculate_with_steps uses deprecated Context.sample() API (line in calculator_mcp_first_approach.py: 'response = await ctx.sample(prompt)'). Sampling was removed from MCP spec (deprecated since 2025-03-26). This tool will break in production.
Inferred effective spec: <=2025-11-25.
| Scored | Grade | Overall | Spec posture | Rubric |
|---|---|---|---|---|
| 2026-09-22 | F | 38 | <=2025-11-25 | v2 |
| 2026-03-09 | F | 32 | - | v1 |
No output schema documented. The rubric requires documenting return types. Both tools return numeric results or strings, but there is no schema definition of the output structure (e.g., is it a bare float, or {result: float, steps: string}?).
Error handling is bare. On invalid expression, tools raise ValueError with minimal message. No recovery guidance: 'Invalid expression: got "2++3", check for mismatched operators' would be actionable; raw error messages do not help LLM self-correct.
No input validation constraints visible. No enums, regex patterns, or length limits declared for 'expression' parameter. LLMs may pass absurdly long strings, invalid syntax, or unsafe functions (e.g., __import__). The tool uses asteval.Interpreter() without whitelisting safe functions.
Naming: 'calculate' is generic and does not distinguish behavior between the three instances. 'calculate' vs 'calculate_simple' vs 'calculate_detailed' or 'evaluate_expression_with_steps' would clarify intent. Current naming forces LLM to read descriptions to pick correctly.