Repository navigation
Optional visual output — plot=True
Every tool now accepts plot: bool = False. With plot=True the JSON result is
kept and a rendered PNG is added as an MCP image content block — phase
portraits, solution curves, bifurcation diagrams, Monte Carlo convergence and
distributions, integration areas, root brackets, the Lagrange polynomial, the
finite-difference tangent, and more.
Added
mathmethods/plots.py: plot registry + lazy Matplotlib rendering
(Figure+FigureCanvasAgg, deterministic PNG bytes).- Optional dependency extra
viz(matplotlib>=3.8). The default install is
unchanged and stdio startup stays light; usingplot=Truewithout the extra
returns an actionable error. tests/test_plots.py: registry/tool coverage,plot=Falsecontract
regression, deterministic rendering, missing-Matplotlib error path, and an
end-to-end MCP protocol test assertingimage/png.- CI runs two jobs: default install and
--extra viz(full plotting suite).
Changed
- All tools registered with
structured_output=Falseso returning
[dict, Image]is well-defined regardless of type annotations. - Server
instructionsmention theplotoption.
Fixed
plot=Trueno longer fails on scalar-valued SymPy functions (gamma,
loggamma,erf,factorial,binomial, ...): the sampler falls back to
per-point evaluation._trim_large_arraysnow down-samples long numeric lists that containNone.- 2D nonlinear phase portraits now overlay nullclines.
Install
# core (unchanged)
pip install mathmethods-mcp==0.2.0
# with plotting
pip install "mathmethods-mcp[viz]==0.2.0"Full changelog: https://github.com/agmonetti/mathmethods-mcp/blob/main/CHANGELOG.md