Precisioncalc Mcp

io.github.inity13由 GitHub 帳號 inity13 發布v2.1.1更新於 Oct 27, 2026

High-precision finance & business calculations for AI agents — exact decimals, never floats.

已驗證Streamable HTTP可網頁執行金融資料與分析

概覽

AI 產生的概覽

確定性的財務與業務計算伺服器,讓助理以精確十進位計算 SaaS 指標、匯率、NPV/IRR、貸款與折舊。

可以做什麼
  • 計算 LTV、CAC、流失率、NRR、GRR、Rule of 40、損益兩平等 SaaS 與業務指標,並列出支援的指標及其參數
  • 在九種主要貨幣之間換算金額,可使用離線靜態匯率表或即時/歷史 ECB 匯率
  • 依美國、英國、歐盟或其他國家假日及自訂假日在工作日上進行加減與計數
  • 執行成長、NPV、IRR、貸款攤還與折舊計算,可選擇回傳完整明細表
  • 在一次請求中批次執行最多 100 項計算,並查詢伺服器健康狀態
適用情境
適合助理需要提供可稽核的財務或業務數字、且擔心浮點誤差或憑空生成公式的情況,每項結果都會附上所用公式、輸入與假設。也適合需要多步計算的 SaaS 指標或估值工作。
執行需求
可使用託管的 Streamable HTTP 端點,或透過 npm 套件以 stdio 在本機執行(README 另提供 Python 3.11+ 自架方式)。託管免費方案不需憑證;付費方案需 API 金鑰,透過 X-API-Key 或 Authorization: Bearer 傳送。即時與歷史匯率需要網路存取,且在託管端點上需付費方案。
安裝前請注意
託管免費方案每個 IP 每天僅 15 次呼叫,只提供靜態匯率且不含 batch_calculate;即時匯率與批次計算需透過 Stripe 訂閱付費方案(Starter 或 Pro)。達到額度時伺服器會回傳含結帳連結的升級資訊,助理可能向使用者顯示付費提示。自架需設定 STRIPE_SECRET_KEY、PRECISIONCALC_API_KEYS 等密鑰。即時匯率請求會把貨幣查詢傳送給外部匯率服務。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Precisioncalc Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。

交給代理程式安裝

把這段提示詞貼上到 Claude Code、Codex、Cursor 等代理程式,或 SourceWeft 對話中。代理程式會讀取該伺服器的安裝指南,先向你展示發布者、端點和登入方式,經你同意後再把它新增到你的客戶端。金鑰不會寫進任何命令。

閱讀 https://sourceweft.com/mcp/io.github.inity13%2Fprecisioncalc-mcp/install.md,並按其中說明把這個 MCP 伺服器接入我的客戶端。修改任何設定之前,先告訴我它的發布者、端點和登入方式,等我確認。不要把 API 金鑰寫進命令或我會提交的檔案;問我金鑰應從哪裡取得。

檢視代理程式所依據的安裝指南

其他 MCP 客戶端

把它新增到你客戶端的 mcpServers 設定中。

{
  "mcpServers": {
    "precisioncalc": {
      "type": "http",
      "url": "https://precisioncalc-mcp.pages.dev/mcp"
    }
  }
}

README

PrecisionCalc MCP

A deterministic Model Context Protocol (MCP) server that gives LLM agents reliable, high-precision business, finance, and operational calculations.

LLMs routinely lose precision or hallucinate on multi-step financial formulas, currency conversions, business-day logic, and growth math. PrecisionCalc offloads that work to exact, transparent tools. Every monetary/financial value is computed with Python's decimal module (never floats), and every result is returned in a consistent, agent-parseable JSON envelope that includes the exact value, a human-readable value, the formula applied, the inputs used, the unit, and any assumptions/warnings.

v2 highlights: live + historical FX (ECB), 14 SaaS metrics, NPV/IRR, loan amortization, depreciation, a batch_calculate tool, per-country holidays, API-key auth + rate limiting + usage metering on the HTTP transport, structured JSON logging, optional OpenTelemetry tracing, and property-based tests.

🌐 Live hosted server (free, no install)

A public remote MCP server runs on Cloudflare's edge — point any Streamable-HTTP MCP client at it:

https://precisioncalc-mcp.pages.dev/mcp

Install via npm (stdio, no hosting)

Run the server locally over stdio with a single command — nothing to deploy:

bash
npx -y precisioncalc-mcp

Claude Desktop / any stdio MCP client (claude_desktop_config.json):

json
{ "mcpServers": { "precisioncalc": { "command": "npx", "args": ["-y", "precisioncalc-mcp"] } } }

This is the same deterministic engine as the hosted server, running on your machine.

json
{ "mcpServers": { "precisioncalc": {    "type": "http", "url": "https://precisioncalc-mcp.pages.dev/mcp" } } }

The edge build (worker-src/) is a Cloudflare Pages Function that mirrors the Python engine using decimal.js — verified 17/17 exact output parity. Landing page + docs: https://precisioncalc-mcp.pages.dev.

Plans (hosted endpoint)

PlanPriceDaily callsLive/historical FXbatch_calculate
Free (no key)$015 / day (per IP)❌ static only❌
Starter$12/mo5,000 / day✅✅
Pro$39/mo50,000 / day✅✅

Checkout is Stripe (subscription). On success you get an API key instantly; send it as X-API-Key: <key> (or Authorization: Bearer <key>). Manage/cancel at /portal. When a limit is hit, tools return a structured status:"error" envelope with type, usage, and an upgrade block containing checkout URLs — so an agent can surface the paywall to the user and act on it. Self-host (below) for unlimited calls with your own keys.

Billing internals live in worker-src/billing.mjs (Stripe REST + Cloudflare KV for keys and daily counters). Server env: STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, PRICE_STARTER, PRICE_PRO, FREE_DAILY, STARTER_DAILY, PRO_DAILY, and a PRECISIONCALC_KV namespace binding (see wrangler.toml).

Rebuild/redeploy the edge server:

bash
npm install          # decimal.js + esbuildnpm run deploy       # bundles worker-src -> site/_worker.js and deploys to Pages

What it does

11 tools, all returning a uniform structured response:

ToolPurpose
calculate_metric14 SaaS/business metrics (LTV, CAC, churn, MRR growth, NRR, GRR, Rule of 40, magic number, break-even, ...)
currency_convertConvert 9 major currencies; static (offline) or live/historical ECB rates
business_daysAdd/count business days, next/previous; US/UK/EU + any ISO country + custom holidays
compound_growthFuture value, present value, CAGR; 7 compounding frequencies incl. continuous
net_present_valueNPV / discounted cash flow of a cashflow series
internal_rate_of_returnIRR (Newton + bisection fallback)
loan_amortizationLevel-payment loan: payment, totals, full schedule, extra-payment payoff
depreciationstraight-line / declining-balance / sum-of-years-digits schedules
batch_calculateRun many calculations in one request
list_metricsDiscovery: every metric with descriptions + required params
health_checkServer status, version, capabilities

Consistent response envelope

Success:

json
{  "status": "success",  "value": "1600",                       // exact, full-precision (string for money/rates)  "formatted_value": "$1,600.00",        // human-readable  "formula": "LTV = (ARPU * gross_margin) / churn_rate",  "inputs_used": { "arpu": "100", "gross_margin": "0.8", "churn_rate": "0.05" },  "unit": "USD",  "notes": ["LTV = (ARPU x gross_margin) / churn_rate.", "..."]}

Error (never raised across the tool boundary):

json
{  "status": "error",  "error": {    "type": "missing_parameter",    "message": "Missing required parameter 'churn_rate'.",    "hint": "Include 'churn_rate' in params. See list_metrics for the full schema."  }}

Project structure

precisioncalc-mcp/├── server.py                 # MCP server: tool definitions + transports├── security.py               # API-key auth + token-bucket rate limit + metering (ASGI)├── observability.py          # Structured JSON logging + optional OpenTelemetry├── requirements.txt / pyproject.toml├── Dockerfile / .dockerignore├── fly.toml / render.yaml    # One-click hosting configs├── .env.example├── calculations/│   ├── _util.py              # Decimal coercion, validation, formatting│   ├── metrics.py            # 14 business/SaaS metrics + catalog│   ├── currency.py           # FX: static + Frankfurter (live/historical) providers│   ├── business_days.py      # Region-aware holidays (built-in + `holidays` lib)│   ├── growth.py             # FV / PV / CAGR│   └── finance.py            # NPV / IRR / loan amortization / depreciation├── schemas/responses.py      # Response envelope helpers├── examples/agent_example.py # End-to-end MCP client demo├── site/                     # Static landing/docs page (Cloudflare Pages)└── tests/                    # 49 unit tests + Hypothesis property tests

Requirements

  • Python 3.11+ (developed/tested on 3.12)
  • Core: mcp, python-dateutil
  • Recommended: uvicorn + starlette (HTTP transport), holidays (per-country calendars)
  • Optional: opentelemetry-sdk (tracing), pytest + hypothesis (tests)

The server auto-detects the SDK layout and works with mcp >= 2.0 (MCPServer), mcp 1.x (FastMCP), or the standalone fastmcp package.


Run it locally

bash
cd precisioncalc-mcppython -m venv .venv && source .venv/bin/activatepip install -r requirements.txt          # or: pip install -e ".[all]"
# stdio transport (default; how MCP clients launch it)python server.py            # or: precisioncalc-mcp   (console entrypoint)
# Streamable HTTP transport (endpoint: /mcp)python server.py httpPRECISIONCALC_API_KEYS=key1,key2 PRECISIONCALC_FX_PROVIDER=frankfurter python server.py http

Demo + tests:

bash
python examples/agent_example.py         # live end-to-end over stdiopython tests/test_calculations.py        # 28 core tests (no pytest needed)python tests/test_v2.py                  # 17 v2 testspython tests/test_properties.py          # Hypothesis property tests# or simply:  pytest -q

Register with an MCP client (stdio)

json
{ "mcpServers": { "precisioncalc": {    "command": "python", "args": ["/absolute/path/to/precisioncalc-mcp/server.py"] } } }

Deploy

Docker

bash
docker build -t precisioncalc-mcp .docker run --rm -p 8000:8000 -e PRECISIONCALC_API_KEYS=your-key precisioncalc-mcpdocker run --rm -i precisioncalc-mcp python server.py stdio

Fly.io

bash
fly launch --no-deployfly secrets set PRECISIONCALC_API_KEYS=key1,key2fly deploy

Render.com

Push to GitHub, then New + → Blueprint and point at the repo (render.yaml). Set PRECISIONCALC_API_KEYS as a secret in the dashboard.


Configuration (env vars)

VarDefaultPurpose
PRECISIONCALC_HOST / PRECISIONCALC_PORT127.0.0.1 / 8000HTTP bind
PRECISIONCALC_API_KEYS(empty)Comma-separated keys. Empty = open mode (still metered/limited by IP)
PRECISIONCALC_RATE_LIMIT_PER_MIN / _BURST120 / 40Token-bucket limits
PRECISIONCALC_METRICS_PATH/metricsUsage-metrics endpoint
PRECISIONCALC_FX_PROVIDERstaticstatic or frankfurter (live/historical ECB)
PRECISIONCALC_FX_TTL / _TIMEOUT3600 / 4FX cache TTL / HTTP timeout (s)
PRECISIONCALC_LOG_LEVEL / _LOG_JSONINFO / 1Logging
PRECISIONCALC_OTEL01 enables OpenTelemetry tracing if SDK present

Tools & parameters

calculate_metric(metric, params, currency="USD")

Rates/margins are decimals (0.05 = 5%).

metricparamsunit
ltvarpu, churn_rate, gross_margin(=1)currency
cactotal_spend, new_customerscurrency
ltv_cac_ratioltv, cacratio
payback_period_monthscac, monthly_revenue_per_customer, gross_margin(=1)months
contribution_marginrevenue, variable_costscurrency
gross_marginrevenue, cogspercent
churn_ratecustomers_lost, customers_at_startpercent
mrr_growth_ratebeginning_mrr, ending_mrrpercent
arrmrrcurrency
break_even_unitsfixed_costs, price_per_unit, variable_cost_per_unitunits
nrrstarting_mrr, expansion_mrr, contraction_mrr, churned_mrrpercent
grrstarting_mrr, contraction_mrr, churned_mrrpercent
rule_of_40growth_rate, profit_marginpercent
magic_numbercurrent_quarter_revenue, prior_quarter_revenue, prior_quarter_sm_spendratio

currency_convert(amount, from_currency, to_currency, date=None, live=None)

USD, EUR, GBP, JPY, CAD, AUD, CHF, CNY, INR. date (YYYY-MM-DD) or live=true uses live/historical ECB rates (frankfurter.app), with automatic static fallback on any network failure. Returns rate, provider, is_live, and timestamps.

business_days(operation, start_date, days=None, end_date=None, region="US", custom_holidays=None)

operation: add_business_days | count_business_days (inclusive) | next_business_day | previous_business_day. region: US | UK | EU | NONE, or any ISO country code when the holidays package is installed (DE, FR, CA, AU, JP, IN, ...).

compound_growth(operation, rate, years, present_value, future_value, begin_value, end_value, compounding="annually", currency="USD")

operation: future_value | present_value | cagr. compounding: daily | weekly | monthly | quarterly | semiannually | annually | continuous.

net_present_value(rate, cashflows, currency="USD")

NPV = Σ CFₜ/(1+rate)ᵗ. cashflows[0] = period 0 (usually the negative outlay).

internal_rate_of_return(cashflows, guess=0.1)

Per-period rate where NPV = 0. Requires a sign change in the cashflows.

loan_amortization(principal, annual_rate, term_months, extra_payment=0, currency="USD", include_schedule=false)

Returns monthly payment, months-to-payoff, total interest, total paid, and (optionally) the full month-by-month schedule.

depreciation(method, cost, salvage_value, useful_life_years, currency="USD")

method: straight_line | declining_balance | sum_of_years_digits. Returns the full yearly schedule; book value converges to salvage_value.

batch_calculate(calls)

calls: list of {"tool": <name>, "arguments": {...}} (max 100). One item failing never aborts the batch.

list_metrics() / health_check()

Discovery + status. No parameters.


Example MCP tool-call payloads

json
{ "name": "calculate_metric",  "arguments": { "metric": "rule_of_40", "params": { "growth_rate": 0.30, "profit_margin": 0.15 } } }
json
{ "name": "currency_convert",  "arguments": { "amount": 5000, "from_currency": "EUR", "to_currency": "GBP", "date": "2024-01-15" } }
json
{ "name": "net_present_value",  "arguments": { "rate": 0.10, "cashflows": [-10000, 3000, 4200, 6800] } }
json
{ "name": "loan_amortization",  "arguments": { "principal": 250000, "annual_rate": 0.065, "term_months": 360, "include_schedule": false } }
json
{ "name": "batch_calculate",  "arguments": { "calls": [    { "tool": "internal_rate_of_return", "arguments": { "cashflows": [-10000, 3000, 4200, 6800] } },    { "tool": "depreciation", "arguments": { "method": "declining_balance", "cost": 50000, "salvage_value": 5000, "useful_life_years": 5 } }  ] } }

Design decisions & assumptions

  • Decimal everywhere money/rates matter; value is serialized as a string to prevent float loss in JSON, with a separate pretty formatted_value. Precision = 50 sig figs.
  • Rates/margins are decimals (0.05 = 5%), documented in every tool.
  • FX: static USD-based table (as_of 2024-06-01) is the offline default; frankfurter provider adds live + historical ECB rates with in-memory TTL cache and graceful static fallback.
  • Business days: holidays computed per-year (floating US, Easter-based UK/EU); count is inclusive; add accepts negatives; custom holidays unioned; any ISO country via holidays lib.
  • IRR uses Newton's method with a bracketed bisection fallback; requires a sign change.
  • Errors never cross the tool boundary as exceptions — always status:"error" with a machine type + actionable hint.
  • HTTP hardening is opt-in via env: API keys, token-bucket rate limiting, /metrics usage.
  • SDK compatibility shim runs on mcp>=2.0, mcp 1.x, or standalone fastmcp unchanged.

Monetization hooks

  • Auth — PRECISIONCALC_API_KEYS; requests need X-API-Key or Authorization: Bearer.
  • Rate limiting — per-key token bucket (per-IP in open mode); swap for Redis to scale.
  • Usage metering — in-memory counters exposed at /metrics; the seam for per-key billing.
  • FX provider — calculations/currency.py::RateProvider is the drop-in point for a licensed feed.

Roadmap (post-v2)

  1. Redis-backed rate limiting + billing-grade usage metering.
  2. Persisted historical FX + more providers; multi-currency carry through metrics.
  3. Bond pricing/yield, WACC, options (Black-Scholes), tax/VAT, unit conversions.
  4. Prometheus exporter + Grafana dashboard alongside OTel traces.
  5. Published PyPI package + Docker image on GHCR; hosted multi-tenant SaaS.

來源:README.md,提交 0b38a7a

工具

11

calculate_metric

Compute a business/SaaS/finance metric with exact decimal precision. Metrics: ltv, cac, ltv_cac_ratio, payback_period_months, contribution_margin, gross_margin, churn_rate, mrr_growth_rate, arr, break_even_units, nrr, grr, rule_of_40, magic_number. Rates/margins are decimals (0.05=5%). Call list_metrics for schemas.

輸入參數metric必填params必填currency

list_metrics

List every supported metric with descriptions and required/optional params.

無需輸入參數。

currency_convert

Convert an amount between major currencies (USD, EUR, GBP, JPY, CAD, AUD, CHF, CNY, INR) with Decimal precision. Static offline table on the free tier; live/historical ECB rates (date/live=true) require a paid plan.

輸入參數dateliveamount必填to_currency必填from_currency必填

business_days

Business-day arithmetic honoring weekends + regional holidays. operation: add_business_days (needs days, negative ok) | count_business_days (needs end_date, inclusive) | next_business_day | previous_business_day. region: US | UK | EU | NONE. custom_holidays: list of YYYY-MM-DD.

輸入參數daysregionend_dateoperation必填start_date必填custom_holidays

compound_growth

Compound-interest/growth math. operation: future_value (rate, years, present_value) | present_value (rate, years, future_value) | cagr (begin_value, end_value, years). rate is annual decimal (0.08=8%). compounding: daily|weekly|monthly|quarterly|semiannually|annually|continuous.

輸入參數rateyearscurrencyend_valueoperation必填begin_valuecompoundingfuture_valuepresent_value

net_present_value

Net Present Value (discounted cash flow). NPV = sum(CF_t/(1+rate)^t). cashflows[0] = period 0 (usually the negative outlay).

輸入參數rate必填currencycashflows必填

internal_rate_of_return

Internal Rate of Return: per-period rate where NPV=0 (Newton + bisection). Requires a sign change in cashflows.

輸入參數guesscashflows必填

loan_amortization

Level-payment loan: monthly payment, total interest, payoff, and (optional) full schedule. payment = P*r/(1-(1+r)^-n), r=annual_rate/12.

輸入參數currencyprincipal必填annual_rate必填term_months必填extra_paymentinclude_schedule

depreciation

Asset depreciation schedule. method: straight_line | declining_balance | sum_of_years_digits. Book value converges to salvage_value.

輸入參數cost必填method必填currencysalvage_value必填useful_life_years必填

batch_calculate

PAID FEATURE. Run many calculations in one request. calls: list of {tool, arguments} (max 100). One failure never aborts the batch.

輸入參數calls必填

health_check

Server health/status metadata.

無需輸入參數。

版本歷史

1
  1. v2.1.1最新Sep 16, 2026

評分

已滿足適用檢查項的 100%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通必需25 分
  • 已宣告認證方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分