
MCP server for numerical methods and dynamic systems: root finding, integration, ODEs, Monte Carlo
MCP server for numerical methods and dynamic systems: root finding, integration, ODEs, Monte Carlo, 1D/2D dynamical systems, and combat models.
·
A Model Context Protocol server that exposes a
numerical-methods core as tools an LLM agent can call directly from a chat
(VS Code, Zed, Claude, opencode, etc.). It is built on top of the
numerical-methods engine of the academic project modeladoYsimulacion-web
(UADE); the math core is vendored into this repository so the server is
fully self-contained.
Runs on-demand without any global installation:
claude mcp add mathmethods npx -y @agmonetti/mathmethods-mcpAdd to your claude_desktop_config.json or .cursor/mcp.json:
{
"mcpServers": {
"mathmethods": {
"command": "npx",
"args": ["-y", "@agmonetti/mathmethods-mcp"]
}
}
}Ideal for instant startup without network latency on every invocation:
npm install -g @agmonetti/mathmethods-mcp{
"mcpServers": {
"mathmethods": {
"command": "mathmethods-mcp"
}
}
}Any MCP client can also run the Python package directly with Astral's uvx:
claude mcp add mathmethods-mcp -- uvx mathmethods-mcp{
"mcpServers": {
"mathmethods": {
"command": "uvx",
"args": ["mathmethods-mcp"]
}
}
}git clone https://github.com/agmonetti/mathmethods-mcp.git
cd mathmethods-mcp
uv sync --extra dev
uv run server.pyEvery client config above also works with
uv run --frozen --project <checkout> python <checkout>/server.py in place of
npx -y @agmonetti/mathmethods-mcp or uvx mathmethods-mcp.
| Tool | What it does |
|---|---|
root_bisection | Bisection on [a, b] (requires a sign change) |
root_newton_raphson | Newton–Raphson with numeric derivative |
root_punto_fijo | Fixed-point iteration x = g(x) |
root_aitken | Aitken Δ² acceleration of fixed point |
root_comparar | All four methods compared on the same problem |
| Tool | What it does |
|---|---|
integral_rectangulo | Composite midpoint rule |
integral_trapecio | Composite trapezoidal rule |
integral_simpson13 | Composite Simpson 1/3 (n even) |
integral_simpson38 | Composite Simpson 3/8 (n multiple of 3) |
integral_comparar | All four rules compared on the same integral |
| Tool | What it does |
|---|---|
finite_differences | Forward/backward/central 1st & 2nd derivatives |
| Tool | What it does |
|---|---|
ode_rk4 | Runge–Kutta 4 (4th order) |
ode_heun | Heun predictor–corrector (2nd order) |
ode_euler | Explicit Euler (1st order) |
interpolation_lagrange | Lagrange interpolating polynomial |
| Tool | What it does |
|---|---|
mc_hit_or_miss_1d | Hit-or-miss estimator (correct for sign-changing f) |
mc_valor_promedio_1d | Mean-value estimate of ∫ₐᵇ f(x) dx |
mc_valor_promedio_2d | Mean-value estimate of a double integral |
mc_valor_promedio_3d | Mean-value estimate of a triple integral |
mc_estadistico_1d | M×N replicated experiment with statistical analysis |
mc_convergencia_1d | Running average showing the estimate converging |
| Tool | What it does |
|---|---|
dynamic_1d_solve | Equilibria, stability, phase portrait and time series |
dynamic_1d_equilibria | Find and classify the equilibria of x' = f(x) |
dynamic_1d_bifurcation | Equilibria vs parameter (bifurcation diagram) |
dynamic_2d_linear_solve | Linear X' = A·X + B: classification, eigenvalues, analytic solution |
dynamic_2d_nonlinear_solve | Nonlinear x' = f(x,y): equilibria, Jacobian, nullclines |
dynamic_2d_conservative_solve | Divergence-free check, Hamiltonian/energy, closed orbits |
dynamic_2d_lanchester_solve | Lanchester combat model with analytic time-to-annihilation |
dynamic_2d_nonhomogeneous_solve | Non-homogeneous X' = A·X + B(t) with time-varying forcing |
Math expressions use Python/SymPy syntax: x**2, sin(x), exp(x),
sqrt(x), log(x). Common shorthand is accepted too: e^x, sen(x), ln(x)
and the caret ^ for powers. The Greek combat parameters of Lanchester use the
Unicode symbols α β γ ε μ δ.
Every tool accepts a plot=False | True flag. With plot=True the response
contains the usual JSON plus a rendered PNG (an MCP image content block):
phase portraits, solution curves, bifurcation diagrams, Monte Carlo
convergence, and so on.
"Solve y' = y, y(0)=1 on [0,1] with RK4 and show me the plot."Plotting needs the optional viz extra (Matplotlib), which is not part of
the default install so the stdio server startup stays light:
pip install "mathmethods-mcp[viz]" # pip
uvx --from "mathmethods-mcp[viz]" mathmethods-mcp # uv
uv sync --extra viz # from a checkoutIf plot=True is used without the extra, the tool returns a clear error telling
you how to install it. Clients that do not render images still receive the JSON
result alongside the image, so nothing is lost.
mathmethods-mcp/
├── server.py # FastMCP app + all tools
├── mathmethods/
│ ├── compiler.py # hardened expression validation (whitelist, caps)
│ ├── plots.py # optional PNG rendering (plot=True), lazy matplotlib
│ ├── server.py # FastMCP app and tool definitions
│ └── core/ # vendored math core (from modeladoYsimulacion-web)
│ ├── root_finding.py ├── integration.py
│ ├── ode.py ├── interpolation.py
│ ├── differentiation.py├── monte_carlo.py
│ ├── dynamic_1d.py ├── dynamic_2d_linear.py
│ ├── dynamic_2d_non_homogeneous.py ├── dynamic_2d_nonlinear.py
│ ├── dynamic_2d_conservative.py ├── dynamic_2d_lanchester.py
│ └── utils.py
├── tests/ # test_tools.py + test_dynamic_tools.py + test_plots.py
├── mcp.example.json # server registration template (copy to .vscode/mcp.json)
├── requirements.txt
└── pyproject.tomlcd mathmethods-mcp
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtAfter creating the venv, verify it is isolated (
venv/bin/python -c "import sys; print(sys.prefix)"should print the venv path, not/usr). If your system Python produces a broken venv, trypython3 -m venv --copies venv.
Local (STDIO) — default transport, used by VS Code / Claude Desktop:
uv run python server.pyRemote (Streamable HTTP) — the server prints a URL such as http://127.0.0.1:8000/mcp:
MCP_TRANSPORT=streamable-http uv run python server.pyThe transport can also be chosen with the MCP_TRANSPORT environment variable
(stdio | streamable-http | sse), and the HTTP host/port with
MCP_HTTP_HOST / MCP_HTTP_PORT (defaults 127.0.0.1:8000).
Every client registers the same command, uvx mathmethods-mcp (no paths, no
venv). If the server is not published yet or you work from a checkout, use
uv run --frozen --project <PROJ> python <PROJ>/server.py instead.
Remote (Streamable HTTP) — optional; start it once in a terminal, then
point the client at http://127.0.0.1:8000/mcp:
MCP_TRANSPORT=streamable-http uvx mathmethods-mcpCreate .vscode/mcp.json (git-ignored) — or copy mcp.example.json:
{
"servers": {
"mathmethods-stdio": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@agmonetti/mathmethods-mcp"]
},
"mathmethods-http": {
"type": "http",
"url": "http://127.0.0.1:8000/mcp"
}
}
}Open the file and press Start next to the server you want; reload the
window if it doesn't appear (Developer: Reload Window).
Add the entry under context_servers (note: not mcp_servers) in
~/.config/zed/settings.json or the project-level .zed/settings.json:
{
"context_servers": {
"mathmethods": {
"command": "npx",
"args": ["-y", "@agmonetti/mathmethods-mcp"]
}
}
}You can also manage them via Settings → AI → MCP Servers.
Both opencode and the OpenChamber desktop app share the same configuration
format. Add the entry under mcp in opencode.json (project root) or in the
global ~/.config/opencode/opencode.jsonc:
{
"mcp": {
"mathmethods": {
"type": "local",
"command": ["npx", "-y", "@agmonetti/mathmethods-mcp"],
"enabled": true
}
}
}Or register it with the CLI (equivalent):
opencode mcp add mathmethods -- npx -y @agmonetti/mathmethods-mcpFor a remote server running on http://127.0.0.1:8000/mcp:
{
"mcp": {
"mathmethods": {
"type": "remote",
"url": "http://127.0.0.1:8000/mcp",
"enabled": true
}
}
}Verify with opencode mcp list.
Add the entry under mcpServers in the Antigravity config file, typically
~/.gemini/antigravity/mcp_config.json:
{
"mcpServers": {
"mathmethods": {
"command": "npx",
"args": ["-y", "@agmonetti/mathmethods-mcp"]
}
}
}If the file path differs on your install, use the in-IDE Settings → Integrations → MCP Servers panel instead, which writes the same format.
The GitHub Copilot CLI (copilot) lets you add a server interactively:
copilotthen inside the session:
/mcp add
Server name: mathmethods
Server type: 1 (Local/STDIO)
Command: npx -y @agmonetti/mathmethods-mcpPress Ctrl+S to save. The settings are stored in
~/.copilot/mcp-config.json (top-level mcpServers); check the connection
with /mcp show.
Both use the mcpServers format. In Claude Desktop, edit
claude_desktop_config.json; in Claude Code:
claude mcp add mathmethods npx -y @agmonetti/mathmethods-mcp{
"mcpServers": {
"mathmethods": {
"command": "npx",
"args": ["-y", "@agmonetti/mathmethods-mcp"]
}
}
}npx @modelcontextprotocol/inspector node server.py # or
npx @modelcontextprotocol/inspector --transport http http://127.0.0.1:8000/mcpAsk your agent things like:
x^3 - 3x + 1 in [0, 1]."sin(x)/x from 0 to 1 using Simpson with n=10."y' = y with y(0)=1 from x=0 to x=1 with step 0.1 (RK4)."sin(x) over [0, 2pi] with Monte Carlo hit-or-miss."x' = mu*x*(1 - x/K) with K=2, mu=1."x' = 2x - y, y' = x + 2y and sketch its trajectories."The server is read-only: the tools only compute numbers, they never touch the filesystem, the network or any destructive operation. Still, the inputs are driven by an LLM, so defense in depth is applied:
mathmethods/compiler.py + mathmethods/core/utils.py):
length cap, symbol whitelist, function whitelist, and a lexical gate that
rejects attribute access (./__) and unknown tokens BEFORE SymPy parses.
SymPy's sympify/parse_expr can execute arbitrary Python (verified RCE),
so every parse site — in this project and in the upstream backend — routes
through the gate.dynamic_2d_nonhomogeneous_solve with time-varying forcing on a
non-diagonal matrix A shows the homogeneous solution only (the particular
term is computed for diagonal systems); the numeric RK4 trajectory is always
correct.Releases are automated: bump the version, push a tag, and both registries are updated by CI. No tokens or repository secrets are stored — PyPI and npm use GitHub OIDC (Trusted Publishing).
Bump the version in three places (they must match the tag):
pyproject.toml, mathmethods/__init__.py and package.json.
Refresh the lockfile — CI runs uv lock --check, and the lock records the
project version, so forgetting this breaks the build:
uv lockAdd an entry to CHANGELOG.md.
Commit and push, then tag:
git commit -am "chore: release v0.3.0"
git tag v0.3.0 && git push origin main --tagsPushing a v* tag runs .github/workflows/release.yml, which:
test + viz) — a red commit can never be released;pyproject.toml and package.json;@agmonetti/mathmethods-mcp) with an
automatic provenance attestation.Configure these once; afterwards every tag publishes with no manual step.
PyPI — project mathmethods-mcp → Settings → Publishing → add a trusted publisher:
| Field | Value |
|---|---|
| Owner | agmonetti |
| Repository | mathmethods-mcp |
| Workflow name | release.yml |
| Environment name | pypi |
npm — package @agmonetti/mathmethods-mcp → Settings → Trusted Publisher:
| Field | Value |
|---|---|
| Provider | GitHub Actions |
| Organization or user | agmonetti (no @) |
| Repository | mathmethods-mcp |
| Workflow filename | release.yml |
| Environment name | npm |
| Allowed actions | ✅ npm publish (and/or npm stage publish) |
npm gotchas. A trusted publisher created after 2026-09-03 defaults to stage publish only — tick npm publish or the release fails with
ENEEDAUTH. A brand-new trusted publisher expires if it does not get a successful publish within 2 days, so set it up right before the first release. While there, set Publishing access to require 2FA and disallow tokens.
If you ever need to publish by hand (e.g. before the tag exists):
uv build # sdist + wheel in dist/
uv publish # uses UV_PUBLISH_TOKEN or `uv login`
npm publish --access public # requires `npm login`Once published, every client config just works with uvx mathmethods-mcp (no
paths, no venv).
The math lives in modeladoYsimulacion-web/backend/app/methods/. When the
upstream code changes, copy the files here again:
cp ../modeladoYsimulacion-web/backend/app/methods/{root_finding,integration,ode,interpolation,monte_carlo,dynamic_1d,dynamic_2d_linear,dynamic_2d_non_homogeneous,dynamic_2d_nonlinear,dynamic_2d_conservative,dynamic_2d_lanchester}.py mathmethods/core/
cp ../modeladoYsimulacion-web/backend/app/core/utils.py mathmethods/core/utils.pyThen rewrite the from app.core.utils import ... imports to from .utils import ... in the copied files.
uv run pytest.github/workflows/ci.yml); coverage report next.Pick your client and paste the snippet. Each one is the same server, written the way that client expects it.
claude mcp add mathmethods -- npx -y @agmonetti/mathmethods-mcp{
"mcpServers": {
"mathmethods": {
"args": [
"-y",
"@agmonetti/mathmethods-mcp"
],
"command": "npx"
}
}
}code --add-mcp '{"name":"mathmethods","args":["-y","@agmonetti/mathmethods-mcp"],"command":"npx"}'[mcp_servers.mathmethods]
command = "npx"
args = ["-y", "@agmonetti/mathmethods-mcp"]Runs locally on your device. Your client starts the server itself, so nothing has to be hosted.
Paste this prompt into your agent. It reads this page and does the setup for you.
Read https://aiagentslisting.com/mcp/mathmethods-mcp to learn what the "Mathmethods Mcp" MCP server does and how to install it. Add it to my coding agent's MCP configuration as documented on that page, then confirm the server connects and list the tools it exposes.Agents can also browse this directory over MCP at https://aiagentslisting.com/api/mcp
claude mcp add mathmethods npx -y @agmonetti/mathmethods-mcp
claude mcp add mathmethods-mcp -- uvx mathmethods-mcpnpx @modelcontextprotocol/inspector node server.py # or
npx @modelcontextprotocol/inspector --transport http http://127.0.0.1:8000/mcpThis server runs locally, so we can't read its tool list over the web yet.
Paste this line near the top of your repository's README. The badge always renders the current score.
[](https://aiagentslisting.com/mcp/mathmethods-mcp)Nothing comparable is listed yet.
v0.2.0v0.2.0 — Optional visual output (plot=True)Release notesConnect to the AI Agents Listing MCP server at https://aiagentslisting.com/api/mcp using the HTTP transport and complete the sign-in when it asks. Then call the submit_review tool for the listing "mathmethods-mcp" with a rating from 1 to 5 and a short note on what worked and what did not.No reviews yet
Be the first to share your experience with this tool.
One email a week. New agents, MCP servers and skills, and what is actually getting traction.