NSE MCP Explorer

Troubleshooting

“Request timed out” / requests hang for 20 s

Most common issue. Observed causes during development:

  1. Edge throttling after bursts. NSE’s CDN (Akamai) sometimes stops answering a client for ~1–3 minutes after a burst of requests: the connection opens, then nothing comes back. → Wait a couple of minutes. Avoid hammering: keep NSE_MCP_MAX_CONCURRENCY low (default 2), keep NSE_MCP_MIN_INTERVAL_MS ≥ 250, keep the cache on (NSE_MCP_CACHE_TTL_S=60). Do not try to get around it by rotating User-Agents or IPs — that is evading NSE’s controls.
  2. Origin outages. NSE’s servers occasionally return 502 Bad Gateway / 504 Gateway Time-out or time out entirely (seen on 2026-10-06 for several minutes, once on both servers at the same time). → The dashboard shows which server is down. Retry later or switch to npm run dev:mock.

Check reachability yourself:

curl -s -o /dev/null -w '%{http_code}\n' -X POST https://mcp.nseindia.in/cmmkt/mcp -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"check","version":"1"}}}'

200 = healthy; 000 = timeout; 502/504 = NSE origin problem.

Dashboard says “Not connected”

The backend connects in the background at startup. If NSE was unreachable then, the next tool call retries the connection automatically. Refresh the dashboard after running a tool.

A tool returns “Soft error”

NSE reports most failures inside a successful result: {"error": "..."} with isError: false.

Message Meaning
Symbol 'X' not found / Symbol not found: X Use the exact NSE ticker — find it with nse_lookup_symbol.
Failed to parse cached data: … ArrayList cannot be cast to … Map Known NSE bug in nse_get_gainers / nse_get_losers. Use nse_get_market_movers.

The date I asked for isn’t the date I got

Bhavcopy tools answer for the nearest/latest trading day when the date is a holiday, weekend, outside the 5-year window or badly formatted (yyyy-MM-dd is required). Always read the returned date.

A stock shows a −50% day

That’s almost certainly a 1:1 bonus or a split — Bhavcopy prices are unadjusted. Check get_corporate_actions; the Insights → Stock deep dive page adjusts automatically.

Live prices aren’t changing

Outside 09:15–15:30 IST (Mon–Fri) the live data is the last snapshot. During market hours the caches refresh every 1–5 minutes (cm_get_data_status).

Browser: CORS error when calling NSE directly

NSE only allows its own origins. Call NSE MCP from a backend (as this project does), never from browser JavaScript.

Python: ImportError: cannot import name 'streamablehttp_client'

mcp 2.x renamed it to streamable_http_client, which yields (read, write) (two values) and uses snake_case fields (server_info, is_error). The example targets mcp>=2. Pass terminate_on_close=False — NSE doesn’t support the session-ending DELETE.

Port 5180 already in use

PORT=5190 npm run dev

AI agent page says “disabled”

Set ANTHROPIC_API_KEY in .env and restart. The rest of the app doesn’t need it.