NSE MCP Explorer

Testing Report

Test date: 2026-10-06, macOS (Darwin 27), Node 24.16, npm 11.13, Python 3.14.4, mcp (Python) 2.3.0, @modelcontextprotocol/sdk 1.32.1.

How to run

npm test                                   # offline suite — mock MCP server, no network
PYTHON_MCP=.venv/bin/python npm test       # also runs the Python example
npm run test:live                          # opt-in smoke test against real NSE
npm run build                              # typecheck + production UI build

Results summary

Area Result
Dependency install (npm install) ✅ 0 vulnerabilities
Typecheck (tsc --noEmit, strict) — server, shared, web, mock, tests, scripts, examples ✅ no errors
Production UI build (vite build) ✅ 321 KB JS (99 KB gzip), 10 KB CSS
Offline test suite ✅ 72 passed, 3 skipped (2 live tests + Python example when PYTHON_MCP unset)
Python example (PYTHON_MCP set) ✅ passed against the mock
Live smoke test (npm run test:live) ✅ 2/2 passed (both servers connected; tool list matched the catalog exactly; one call per server) — after a first run failed during an NSE outage, see below
Live tool coverage through the app ✅ 24 / 26 succeeded; 2 return NSE’s server-side error (expected)
Live guided examples ✅ all 17 examples (20 calls) succeeded
Live recipes ✅ deep dive (6 & 24 months), unusual volume (NIFTY), breadth trend
UI (mock and live) ✅ manual + scripted browser checks, see below

Automated suites (tests/)

File Tests What it covers
analytics.test.ts 21 candle parsing (bad rows, sorting, de-dup), split/bonus back-adjustment (single, compounded, no-op), SMA/EMA alignment, RSI (all-up, alternating, short input), returns, volatility, max drawdown, gap detection + CA matching, summarize on empty/uptrend data, relative volume guards, IST session progress, breadth labels
mcpResult.test.ts 10 JSON / bare number / text / empty / structuredContent parsing, soft-error detection, argument coercion (numeric strings, comma lists), missing/mistyped/unknown arguments
catalog.test.ts 10 26 tools (13+13) recorded; catalog ↔ NSE tool list consistency both ways; every catalog example and every guided example validates against the real NSE schema; param-option lists reference real params; date helpers
integration.test.ts 18 full MCP round-trips over Streamable HTTP against the mock: discovery, routing, wire capture with session id, bare numbers, soft errors, NSE’s nse_get_gainers bug, validation before network, unknown tools, stats, cache, reconnect after server restart (session 404 + stale keep-alive sockets), unreachable servers, one server hanging doesn’t slow the other (back-off), JSON-RPC error parity, all four recipes
api.test.ts 8 HTTP API: status, tools, execute, bad input (400), wire log, recipe validation (400/422), agent disabled (503), JSON 404
agent.test.ts 3 agent loop with a scripted fake model: all 26 tools offered, parallel tool calls executed over MCP and returned in one message with is_error flags, usage accounting, refusal handling, max-turn stop
examples.test.ts 3 runs examples/typescript/quickstart.ts, history-chunks.ts and (optionally) examples/python/quickstart.py against the mock
live.test.ts 2 opt-in: real NSE connection, tool-list parity, one call per server

The mock is a real MCP server built with the official SDK, replaying responses recorded from live NSE on 2026-10-06 (npm run record-fixtures), so the protocol path under test is the same as production.

Live testing log (2026-10-06, IST)

Time Observation
10:24 Raw protocol probe: both servers initialised; tools/list = 13 + 13; all 26 tools called once — 24 OK, nse_get_gainers/nse_get_losers returned the Java cast error
10:24 First curl attempts hung (timeout) until a different User-Agent was used — later the reverse happened. Interpreted as edge throttling keyed on client fingerprint. No UA rotation is used by the app.
10:35–10:37 App client blocked (timeouts) for ~1.5 min, then recovered
10:39–10:42 Fixture recording (1 request / 600 ms): Bhavcopy tools all OK; CM Market tools mostly timed out or returned 504/502 from NSE’s origin. Missing CM fixtures taken from the 10:24 probe.
10:56 npm run test:live failed: CM Market Live timed out (HTTP 504 seen via curl) — upstream outage
11:00 Both servers timing out
11:02 Both servers healthy again; npm run test:live ✅
11:04–11:07 Full 26-tool pass through the running app: first 4 CM calls timed out (a further blip), then 24/26 succeeded on retry; the 2 broken tools returned soft errors as expected
11:08 Live recipes: 24-month RELIANCE deep dive detected the raw −49.76% gap on 2024-10-28 and matched it to the 1:1 bonus (factor 0.5); adjusted series continuous. Unusual-volume (NIFTY) 11/11 calls OK. Breadth trend correctly skipped the 2 Oct holiday.
11:10 All 17 guided examples (20 calls) ✅

UI verification

Performed in the built-in browser against both mock and live backends:

Bugs found by this verification and fixed: card spacing inside grids; explorer too cramped at ~1000 px; volume-axis label overlapping the price axis; “prices adjusted” flag true when the split/bonus was outside the window; invalid deep-dive symbol returning 500 instead of 422; reconnect failing on stale keep-alive sockets; one hanging server slowing calls to the other; Python example written for the pre-2.0 mcp API.

Not tested / limitations