When to use
Extract coefficients of a polynomial in the given variable, **lowest degree 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
},
"variable": {
"type": "string",
"minLength": 1
}
},
"required": [
"expression",
"variable"
],
"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 |
|---|---|---|
| coefficients | string[] | `[c₀, c₁, …, cₙ]` where the polynomial is `c₀ + c₁·x + … + cₙ·xⁿ`. |
Example
Request
{
"expression": "2*x^2 + 3*x + 4",
"variable": "x"
}Response
{
"ok": true,
"result": {
"coefficients": [
"4",
"3",
"2"
]
}
}curl
curl -X POST https://tools.aieo.se/api/v1/coefficients \
-H 'Content-Type: application/json' \
-d '{"expression":"2*x^2 + 3*x + 4","variable":"x"}'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": "coefficients",
"arguments": {
"expression": "2*x^2 + 3*x + 4",
"variable": "x"
}
}
}Common errors
- Expression is not a polynomial in `variable`.Throws or returns a single-element list.
- 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`.