{"id":50626933,"url":"https://github.com/matthewjhunter/math-mcp","last_synced_at":"2026-06-06T16:01:53.318Z","repository":{"id":362460732,"uuid":"1234978721","full_name":"matthewjhunter/math-mcp","owner":"matthewjhunter","description":"MCP server exposing accurate math, statistics, and financial calculations to LLM clients","archived":false,"fork":false,"pushed_at":"2026-06-04T09:25:45.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-04T11:03:15.606Z","etag":null,"topics":["claude-code","financial","golang","llm","math","mcp","statistics"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matthewjhunter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-10T22:08:15.000Z","updated_at":"2026-06-04T09:25:49.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/matthewjhunter/math-mcp","commit_stats":null,"previous_names":["matthewjhunter/math-mcp"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/matthewjhunter/math-mcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewjhunter%2Fmath-mcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewjhunter%2Fmath-mcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewjhunter%2Fmath-mcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewjhunter%2Fmath-mcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matthewjhunter","download_url":"https://codeload.github.com/matthewjhunter/math-mcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthewjhunter%2Fmath-mcp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33988667,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-06T02:00:07.033Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["claude-code","financial","golang","llm","math","mcp","statistics"],"created_at":"2026-06-06T16:01:52.581Z","updated_at":"2026-06-06T16:01:53.312Z","avatar_url":"https://github.com/matthewjhunter.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# math-mcp\n\n[![CI](https://github.com/matthewjhunter/math-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/matthewjhunter/math-mcp/actions/workflows/ci.yml)\n[![Go Reference](https://pkg.go.dev/badge/github.com/matthewjhunter/math-mcp.svg)](https://pkg.go.dev/github.com/matthewjhunter/math-mcp)\n[![Go Report Card](https://goreportcard.com/badge/github.com/matthewjhunter/math-mcp)](https://goreportcard.com/report/github.com/matthewjhunter/math-mcp)\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)\n\nAn MCP server that exposes accurate math, statistics, and financial calculations\nto LLM clients. The intent is to give models a precise alternative to inferring\nnumeric answers from context — call a tool, get the right number.\n\nIn practice, that means catching the kind of mistakes LLMs make when asked to\nestimate. In one real-world test, the server identified two errors in a hand-\nmaintained financial planning document: a mortgage-payment comparator off by\n~$90/mo (which propagated to an ~$87/mo opportunity-cost claim) and a loan\npayoff term off by ~3 months because the napkin math ignored continuing\ninterest accrual.\n\nThree tool surfaces, one tool per function for discoverability:\n\n| Surface | Backend | Examples |\n| --- | --- | --- |\n| `math_*` | Go `math` stdlib (float64) | `math_sqrt`, `math_pow`, `math_sin`, `math_log`, `math_gamma`, `math_constants` |\n| `stats_*` | `gonum.org/v1/gonum/stat` (float64) | `stats_mean`, `stats_median`, `stats_stddev`, `stats_percentile`, `stats_correlation` |\n| `financial_*` | `github.com/razorpay/go-financial` (`shopspring/decimal`) | `financial_pmt`, `financial_npv`, `financial_pv`, `financial_fv`, `financial_rate`, `financial_nper` |\n\nAll tools echo their inputs back in the response so the model can verify what\nwas actually sent (defends against silent argument-order mistakes like swapping\nPV and FV). Domain errors (sqrt of a negative, log of zero, etc.) are returned\nas structured tool errors rather than silent NaN, and the error message\nincludes the offending value so the model can self-correct.\n\n## Install\n\n```sh\ngo install github.com/matthewjhunter/math-mcp/cmd/math-mcp@latest\n```\n\nRegister with Claude Code (user scope):\n\n```sh\nclaude mcp add math-mcp -s user -- math-mcp\n```\n\n## Conventions\n\n### Math surface — `math_*`\n\nSingle-input tools take `{ \"x\": \u003cfloat\u003e }`. Two-input tools take\n`{ \"x\": \u003cfloat\u003e, \"y\": \u003cfloat\u003e }`. `math_atan2` follows the standard\nmathematical convention: passing `x=3, y=4` returns the angle of the vector\n`(3, 4)` (i.e. `atan2(y, x)`).\n\nTrig functions take **radians**, not degrees — pipe through `math_deg_to_rad`\nif you have degrees. `math_log` is the natural logarithm (use `math_log10` or\n`math_log2` for other bases). `math_round` uses round-half-away-from-zero\n(not Python's banker's rounding). `math_mod` returns a result with the sign of\nthe dividend (Go/C convention; Python's `%` follows the divisor).\n\n### Stats surface — `stats_*`\n\nAggregate tools take `{ \"values\": [\u003cfloats\u003e] }`. `stats_percentile` adds a\n`percentile` field in `[0, 100]`. `stats_correlation` takes two equal-length\nseries `x` and `y`. Sample variants (`stats_variance`, `stats_stddev`) use\n`n-1` in the denominator; population variants (`stats_pop_variance`,\n`stats_pop_stddev`) use `n`. `stats_correlation` is Pearson (linear).\n\n### Financial surface — `financial_*`\n\nAll money inputs and outputs are passed as **decimal strings** (e.g.\n`\"0.0033333\"`, `\"200000\"`, `\"-1199.10\"`). Decimal precision is preserved\nend-to-end via `shopspring/decimal`; results include both the precise string\nform and a `result_float` convenience value. Sign convention follows numpy /\nExcel:\n\n- Money received (loan principal disbursed to you, account balance you own)\n  is **positive**.\n- Money paid out (regular payments, deposits) is **negative**.\n\nThe optional `when` field is `\"end\"` (default; ordinary annuity, the standard\nmortgage convention) or `\"begin\"` (annuity-due). The input schema advertises\nthese as a JSON Schema enum, so strict MCP clients can reject invalid values\nbefore the request reaches the server.\n\n`financial_npv` follows the **numpy_financial** convention: `cash_flow[0]` is\nthe period-0 cash flow and is **not** discounted; `cash_flow[i]` is divided by\n`(1+rate)^i`. Excel's `NPV()` treats the first value as period 1 — see the\ntool description for porting guidance.\n\n`financial_rate` solves for the periodic rate by Newton-Raphson and returns\nan error if the solver fails to converge within `max_iter` (default 100).\n\n## Correctness notes\n\nA few specific conventions worth knowing:\n\n- **`stats_median` averages the two middle values for even-length input** —\n  the textbook definition. `median([1,2,3,4]) = 2.5`.\n- **`stats_percentile` uses linear interpolation between order statistics**\n  (R type 7) — matches `np.percentile(x, p)` and Excel's `PERCENTILE.INC`.\n  Example: the 75th percentile of `[1,2,3,4]` is 3.25.\n- **Domain errors echo the offending input value** — `sqrt(-42.5)` returns\n  `\"math_sqrt: input must be non-negative (got -42.5)\"`, not a bare\n  \"invalid input\".\n\n## Status\n\n`go-financial` does not currently expose IRR or MIRR; they are deliberately\nomitted rather than approximated. If needed they can be added later via a\ndirect Newton-Raphson search over `financial_npv`.\n\n## Development\n\n```sh\ntask test    # go test -race ./...\ntask lint    # golangci-lint run\ntask vuln    # govulncheck ./...\ntask check   # test + vet + fmt + lint + vuln\ntask build   # build math-mcp binary\n```\n\nCI runs the equivalent of `task check` on every push and PR.\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines and\n[SECURITY.md](SECURITY.md) for vulnerability reporting.\n\n## License\n\nApache-2.0 — see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewjhunter%2Fmath-mcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthewjhunter%2Fmath-mcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewjhunter%2Fmath-mcp/lists"}