NSEPython & NSEPythonServer 2.99 — Full Section Support + Official NSE MCP Integration

v2.99 — Full Section Support, Shape-Detection Fixes, and a New Official MCP Integration

Two things in this release: a full audit pass that found and fixed everything left over from the
Akamai fix in v2.98, and a brand-new feature — NSE just launched their own official MCP server, and
both libraries now wrap all 36 of its tools.


Bug Fixes (full function-by-function audit, every one live-tested, several independently

re-verified by a second skeptical pass before shipping)

  • nse_quote(symbol, section=X) now supports every section value — trade_info, info,
    metadata, priceInfo, securityInfo, industryInfo, preOpenMarket — not just trade_info
    from v2.98. An unrecognized section value raises a clear error instead of hitting a dead path.
  • pcr() and nse_quote_meta() had a real bug: they assumed option-chain data always came in the
    nested {'CE':{...},'PE':{...}} per-strike shape, but silently returned a wrong-looking 0.0 / {}
    when fed the flat per-leg shape nse_quote_derivatives() actually returns now. Both functions
    auto-detect which shape they were given and return the correct answer either way.
  • nse_optionchain_ltp() — same root issue. It was doing entry.get(optionType), which only makes
    sense for the nested shape; fixed to handle the flat per-leg shape too (confirmed: CE/PE prices now
    resolve correctly against both).
  • Case-insensitive symbol handling across nse_quote_ltp/nse_quote_meta/nse_quote_derivatives
    ("banknifty" now works, not just "BANKNIFTY").
  • MIDCPNIFTY and NIFTYNXT50 were missing from the recognized index list — added.
  • get_fao_participant_oi() had garbage Unnamed: N columns from a header-row parsing issue — fixed.
  • nse_preopen_movers(filter=X) was silently ignoring its own filter argument — fixed.
  • nse_holidays(type=X) crashed with UnboundLocalError on a bad type — now a clear ValueError.
  • Crash-on-edge-case guards added to black_scholes_dexter(), get_beta(), expiry_history(),
    nse_preopen() (zero variance, blank dates, empty pre-open window, etc).

One claimed-broken item from internal testing turned out to be a false alarm on re-check:
derivative_history(instrumentType="futures") works fine with a real, valid expiry date — an earlier
test pass had used expired/invalid expiry dates and mistook the correctly-empty result for a bug.


New: NSE’s Own Official MCP Server, Wrapped

NSE now runs its own free, no-auth-required MCP server at
mcp.nseindia.in — announced at nseindia.com/nse-mcp. 36 tools
across two endpoints: historical OHLCV, corporate actions, index valuation, moving averages, 52-week
high/low, volume analysis, stock comparisons on one side (21 tools); live quotes, market movers,
gainers/losers, index data on the other (15 tools).

This matters because it’s a second, independent data path — not the scrape-based nseindia.com
site this library normally talks to, so it isn’t subject to any of the Akamai Bot Manager issues v2.98
spent its whole changelog working around. No session warm-up, no TLS fingerprint dance, no API key.

Every function is prefixed nse_mcp_ so it’s obvious at a glance which data path a line of code is
using:

  • One named wrapper per tool — nse_mcp_get_stock_history(symbol, months=3, ...),
    nse_mcp_cm_get_stock_quote(symbol), nse_mcp_compare_stocks(symbols, months=6), all 36 of them.
  • nse_mcp_list_tools() — live discovery, returns the real tool list straight from the server (not a
    hardcoded copy), so it stays accurate if NSE adds more tools.
  • nse_mcp_call(tool_name, **kwargs) — generic escape hatch, works for any tool by name, including
    future ones this library hasn’t caught up to yet.

No new dependency — it reuses the same curl_cffi session the rest of the library already needs.

Full docs + the complete tool list + working examples:

Known gap, NSE’s bug not ours: 2 of the 36 tools (nse_mcp_nse_get_gainers,
nse_mcp_nse_get_losers) currently raise a clear error because NSE’s own server throws a Java
ArrayList/Map cast exception internally — confirmed reproducible, not something fixable from this
side. Use nse_mcp_nse_get_market_movers() instead, which covers the same data and works fine.


Links

As always — if you hit anything broken, reply here with the exact call and the error.