When to use
Numerically evaluate an expression, optionally binding free variables first.
Input schema
Validated server-side with Zod. The same schema feeds OpenAPI and the MCP tool list.
{
"type": "object",
"properties": {
"expression": {
"type": "string",
"minLength": 1,
"description": "Expression to numerically evaluate"
},
"substitutions": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
}
]
},
"description": "Optional variable -> numeric/string value bindings"
}
},
"required": [
"expression"
],
"additionalProperties": false
}Response shape
All tools return { ok: true, result } on success and { ok: false, error } on failure. The result object contains:
| Field | Type | Description |
|---|---|---|
| result | string | Decimal string. Constants like `pi` are evaluated to floating point. |
Example
Request
{
"expression": "sin(pi/4) + sqrt(2)",
"substitutions": {}
}Response
{
"ok": true,
"result": {
"result": "93222358/43945441"
}
}curl
curl -X POST https://tools.aieo.se/api/v1/evaluate \
-H 'Content-Type: application/json' \
-d '{"expression":"sin(pi/4) + sqrt(2)","substitutions":{}}'MCP call (JSON-RPC)
MCP clients call this tool as tools/call against /api/mcp:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "evaluate",
"arguments": {
"expression": "sin(pi/4) + sqrt(2)",
"substitutions": {}
}
}
}Common errors
- Free variables remain after substitution.Returns a symbolic expression instead of a number.
- A required field is missing or has the wrong type.Zod validation error, e.g. `Required` or `Expected string, received number`.
- Nerdamer cannot parse the expression (unbalanced parens, unknown function, stray characters).`Unexpected token …` or `… is not a valid expression`.