Skip to content

v0.2.0 — Optional visual output (plot=True)

Latest

Choose a tag to compare

@agmonetti agmonetti released this 16 Oct 13:50
· 2 commits to main since this release

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.

// tool call
{ "expression": "x**3 - x - 2", "plot": true }
// response content: [ {type:"text", ...}, {type:"image", mimeType:"image/png", ...} ]

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; using plot=True without the extra
    returns an actionable error.
  • tests/test_plots.py: registry/tool coverage, plot=False contract
    regression, deterministic rendering, missing-Matplotlib error path, and an
    end-to-end MCP protocol test asserting image/png.
  • CI runs two jobs: default install and --extra viz (full plotting suite).

Changed

  • All tools registered with structured_output=False so returning
    [dict, Image] is well-defined regardless of type annotations.
  • Server instructions mention the plot option.

Fixed

  • plot=True no longer fails on scalar-valued SymPy functions (gamma,
    loggamma, erf, factorial, binomial, ...): the sampler falls back to
    per-point evaluation.
  • _trim_large_arrays now down-samples long numeric lists that contain None.
  • 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