Skip to main content

bahi-mcp

MCP server that gives AI assistants (Claude, Cursor, VS Code and others) access to Indian mutual fund data, NSE/BSE market data and financial calculators.

Bahi (बही) is the traditional Indian ledger. This server keeps the numbers straight so your assistant doesn't guess them.

Disclaimer: bahi-mcp provides information and calculations from public data sources (AMFI via the mftool library, and Yahoo Finance for stocks) and from assumptions you supply. It is not investment or tax advice and the author is not a SEBI-registered adviser. Data may be delayed or inaccurate, and tax rules change. Verify before making decisions.

What you can ask

  • "Compare these three flexi-cap funds on 3-year return, volatility and max drawdown."
  • "How often has this fund beaten 12% on rolling 3-year returns?"
  • "If I had invested ₹10,000 a month in scheme 119551 since January 2020, what would it be worth today, and what is my XIRR?"
  • "What's the Nifty at, and how has RELIANCE done over the last year?"
  • "How much tax would I pay if I sell this equity fund after 14 months with a ₹2 lakh gain?"
  • "How much corpus do I need to retire at 55 if I spend ₹60,000 a month today?"

Tools

Mutual fund data (AMFI)

Tool What it does
search_schemes Search schemes by name, returns AMFI scheme codes
get_scheme_quote Latest NAV and quote for a scheme code
get_scheme_details Fund house, type, category, start date
get_nav_history NAV history with optional date range (capped to keep responses small)
get_portfolio_value Current value of a list of holdings (scheme code + units)
clear_cache Drop cached AMFI data so the next call fetches fresh NAVs

Mutual fund analytics

Tool What it does
calculate_sip_returns Monthly SIP simulation on a fund's real NAV history: invested, units, value, absolute return, XIRR
compare_funds Side-by-side 1/3/5-year returns, volatility, max drawdown and Sharpe ratio for 1 to 5 funds
get_rolling_returns Distribution of rolling returns: min, max, mean, median, how often positive or above a threshold

Stocks and market data (NSE/BSE, via Yahoo Finance; unofficial and best-effort)

Tool What it does
get_stock_quote Latest price, day and 52-week range for an NSE/BSE stock
get_index_quote Nifty 50, Sensex, Bank Nifty, Nifty IT, India VIX
get_stock_history OHLCV history for a stock or index

Calculators

Tool What it does
calculate_xirr XIRR for any dated cash flows
calculate_cagr CAGR between two values over a date range
calculate_emi Loan EMI, total payment, total interest
calculate_fd / calculate_rd Fixed and recurring deposit maturity
calculate_lumpsum_value Future value of a one-time investment
project_sip SIP projection at an assumed return, with optional yearly step-up
calculate_swp Does a corpus last under a monthly withdrawal?
plan_retirement Corpus needed and the monthly SIP to build it
estimate_mf_tax Capital gains tax estimate on a fund redemption (FY 2026-27 rules)

Dates can be DD-MM-YYYY or YYYY-MM-DD.

Install

Requires Python 3.10+.

pip install bahi-mcp                # mutual funds + calculators
pip install "bahi-mcp[stocks]"      # adds NSE/BSE stock and index data

Or run without installing, using uv:

uvx bahi-mcp
uvx --with yfinance bahi-mcp        # with stock data

Configure your MCP client

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "bahi-mcp": {
      "command": "uvx",
      "args": ["--with", "yfinance", "bahi-mcp"]
    }
  }
}

Drop "--with", "yfinance" if you don't need stock data. Restart Claude Desktop.

Cursor and other clients

{
  "bahi-mcp": {
    "command": "uvx",
    "args": ["--with", "yfinance", "bahi-mcp"]
  }
}

Notes on data and accuracy

  • Mutual fund data comes from AMFI through mftool (3.4 or newer). NAVs are published after market close, usually by about 9 PM IST. mftool caches NAVs for 24 hours, so use clear_cache after the evening update to see the latest.
  • Stock data comes from Yahoo Finance through yfinance. It is unofficial, can be delayed, rate-limited or change without notice. Don't use it for trading decisions.
  • Tax estimates follow FY 2026-27 rules for equity funds (STCG 20%, LTCG 12.5% above ₹1.25 lakh, long-term after 12 months; debt funds at slab rate). Surcharge, loss set-off and older indexation rules are not modelled.
  • Projections (project_sip, calculate_swp, plan_retirement) assume constant returns. Real markets don't behave that way.

Development

git clone https://github.com/NayakwadiS/bahi-mcp
cd bahi-mcp
python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate
pip install -e ".[dev,stocks]"
pytest
python -m bahi_mcp               # runs the server over stdio

Layout in src/bahi_mcp/:

  • analytics.py, fund_analytics.py, calculators.py: pure Python, no network, fully tested offline
  • data.py: AMFI access through mftool
  • market.py: stock and index access through yfinance
  • server.py: the MCP tool definitions

Roadmap

  • Portfolio overlap and fund-to-fund correlation
  • Document search over factsheets and SEBI/RBI circulars
  • Hosted version with caching

Contributing

Issues and pull requests are welcome.

License

MIT. See LICENSE.

Metadata

Release files for bahi-mcp 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bahi-mcp 0.2.0
File Size Uploaded Provenance Actions
bahi_mcp-0.2.0.tar.gz 21.9 kB Without provenance Details for bahi_mcp-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bahi-mcp 0.2.0
File Interpreter ABI Platform Actions
bahi_mcp-0.2.0-py3-none-any.whl Python 3 none any Details for bahi_mcp-0.2.0-py3-none-any.whl

Total release size: 42.8 kB

Release files / bahi_mcp-0.2.0.tar.gz

Download URL bahi_mcp-0.2.0.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
92238b8d19cc567c37d8ecaed3c91a56de6fc36ba8dcc5d8fc623bedebe44146
BLAKE2b-256 checksum
How to use checksums
19251b32f16bbc0bc47814e141ea6e5c7a85ba9b9d835dff2a1af84b30024552
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / bahi_mcp-0.2.0-py3-none-any.whl

Download URL bahi_mcp-0.2.0-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0820cc7547d6a00b5ddd5c03fbb14c4f4f410332b6e172cd2ccc7e5a97e7bfa
BLAKE2b-256 checksum
How to use checksums
9ae139410b66717cc8feb68bd3fa000afd0193ea2d92ae12841c2cc331997f2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for bahi-mcp 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page