When to use
Replace each named variable with a numeric or symbolic value, then simplify.
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 substitute into"
},
"substitutions": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "Map of variable -> replacement value or expression"
}
},
"required": [
"expression",
"substitutions"
],
"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 | Resulting expression in nerdamer syntax. |
Example
Request
{
"expression": "a*x^2 + b*x + c",
"substitutions": {
"a": "1",
"b": "-3",
"c": "2"
}
}Response
{
"ok": true,
"result": {
"result": "-3*x+x^2+2"
}
}curl
curl -X POST https://tools.aieo.se/api/v1/substitute \
-H 'Content-Type: application/json' \
-d '{"expression":"a*x^2 + b*x + c","substitutions":{"a":"1","b":"-3","c":"2"}}'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": "substitute",
"arguments": {
"expression": "a*x^2 + b*x + c",
"substitutions": {
"a": "1",
"b": "-3",
"c": "2"
}
}
}
}Common errors
- Substitution value is itself invalid syntax.`Unexpected token …` from the inner parse.
{ "expression": "x+1", "substitutions": { "x": "1 +" } } - 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`.