indiankanoon-mcp-connector
v1.1.0
Published
Local stdio MCP server exposing IndianKanoon's case-law API as tools, with a per-session spend cap.
Maintainers
Readme
IndianKanoon MCP Connector
A local stdio MCP (Model Context Protocol) server that gives Claude, or any other
MCP-compatible client, tools to search and fetch Indian case law from IndianKanoon's
official, paid-per-call REST API at api.indiankanoon.org. It does not touch the free
indiankanoon.org website — everything goes through the official, licensed API using
your own token.
This connector is powered by IKanoon (https://indiankanoon.org). Data is provided by IndianKanoon "AS IS," with no accuracy warranty. Every call is billed to your own IndianKanoon account at the rates below; the in-memory spend guard is a safety net against a runaway loop within one connector process, not a financial guarantee — see Spend guard below before relying on it for a hard budget.
Quickstart
Sign up at https://api.indiankanoon.org/signup/ for a personal API token (Rs 500 free trial credit on signup).
Add this to your MCP client's config (shown for Claude Code/Desktop; any MCP client that supports a stdio server with an
envblock works the same way):"indiankanoon": { "type": "stdio", "command": "npx", "args": ["-y", "[email protected]"], "env": { "INDIANKANOON_API_TOKEN": "<paste your token here>" } }Pin an exact version (
@1.1.0, not@latest) rather than letting it float — MCP clients generally don't re-prompt for approval when a tool's definition changes behind an unpinned version, so pinning is the simplest defence against a future version silently doing something different from what you approved.Restart or reconnect your MCP client and confirm
indiankanoonshows connected.
For local development instead of the published package, clone this repo, run
npm install, and point args at the local index.js (see Development below).
Configuration
| Env var | Required | Default | Notes |
|---|---|---|---|
| INDIANKANOON_API_TOKEN | Yes | — | From your IndianKanoon API account. The connector fails fast at boot with a clear stderr message if this is unset — never on the first tool call. |
| INDIANKANOON_SESSION_SPEND_CAP_INR | No | 50 | In-memory spend cap for this connector process's lifetime. Resets when the process restarts. |
| INDIANKANOON_SESSION_CALL_CAP | No | 500 | In-memory call-count cap, same lifetime as above. |
Tools
| Tool | Params | Cost | Notes |
|---|---|---|---|
| search_case_law | formInput and/or citedby (at least one required), doctypes, fromdate/todate (DD-MM-YYYY), title, cite, author, bench, sortby (mostrecent/leastrecent), addedToday, maxcites (0-50), pagenum, maxpages | Rs 0.50 / page returned | Billed only for pages actually returned, not maxpages requested. |
| get_judgment | tid (required), maxcites/maxcitedby (0-50) | Rs 0.20 | Full text; maxcites/maxcitedby also return the citation graph (real field names cites/citedby) at no extra charge. |
| get_document_fragment | tid, formInput (both required) | Rs 0.05 | Query-highlighted snippet without full text. |
| get_document_metainfo | tid (required) | Rs 0.02 | Court/date/judges/citation only — cheapest check available. |
| get_court_copy | tid (required) | Rs 0.50 | Scanned original. Use sparingly — get_judgment is cheaper and searchable. |
| get_spend_status | none | free | Local state only — cumulative spend/calls this process has made, and headroom left. |
citedby is a reverse-citation search: pass a tid to find documents that cite it,
paginable via pagenum/maxpages — the only way to get past get_judgment's hard
50-result maxcitedby cap for a heavily-cited judgment. None of sortby, addedToday,
or citedby are documented on IndianKanoon's own paid-API docs page; all three were
found in IndianKanoon's reference client and confirmed working against the live paid
API — see Build notes.
Spend guard
Two independent, env-configurable caps (see Configuration above), enforced in-memory for the life of the connector process, reset on restart. A tripped cap returns an MCP error content block and never silently proceeds; failed API calls never count against spend. This protects against a runaway loop within one session — it is not a budgeting tool across days, and a process restart resets it to zero, so treat your IndianKanoon account's own balance as the real backstop, not this cap.
Development
git clone https://github.com/rohankgeorge/indiankanoon-mcp-connector.git
cd indiankanoon-mcp-connector
npm install
cp .env.example .env # fill in your tokenThe MCP Inspector's CLI mode drives the server non-interactively (no browser needed) — useful for manual testing after any change:
# list the registered tools
npx @modelcontextprotocol/inspector --cli node index.js --method tools/list
# run a real search
npx @modelcontextprotocol/inspector --cli node index.js \
--method tools/call --tool-name search_case_law \
--tool-arg formInput="arbitration clause survives termination" \
--tool-arg doctypes=supremecourt --tool-arg maxcites=5
# fetch a judgment (use a tid from the search above)
npx @modelcontextprotocol/inspector --cli node index.js \
--method tools/call --tool-name get_judgment --tool-arg tid=<tid>Set INDIANKANOON_API_TOKEN (and optionally the two cap vars) in the shell
environment before running these — they call the real, billed API.
Contributing
Issues and pull requests are welcome. There's no automated way to mock IndianKanoon's
real API cheaply, so CI only smoke-tests that the server boots and lists its tools
correctly (see .github/workflows/ci.yml) — any change to a tool's actual behaviour
should be re-verified manually against the live API using the Inspector commands above
before opening a PR, and the PR description should say what was verified and how. See
CONTRIBUTING.md for more, and SECURITY.md to report a vulnerability privately.
License
MIT — see LICENSE.
Build notes
Everything below was confirmed against the live API, not assumed:
- Request shape: every endpoint is sent as
POST <path>?<querystring>with an empty body andAuthorization: Token <token>/Accept: application/jsonheaders — copied from IndianKanoon's own reference Python client (https://github.com/sushant354/IKAPI), which uses the same shape. doctypes/fromdate/todate/title/cite/author/bench/sortby/citedbyare NOT separate query parameters. A live test withdoctypessent as its own&doctypes=supremecourtparam was silently ignored (results spanned every court). These filters only work embedded askey: valueoperator text insideformInputitself (e.g.formInput=... doctypes: supremecourt), which is whatcomposeFormInput()inindiankanoon.jsdoes.addedTodayis a bare flag (added:today, no value) handled as its own line in the same function.maxcites,pagenum, andmaxpagesare genuine separate query parameters (they shape the response, not the query) — also confirmed live.sortbyconfirmed live: reversingmostrecent/leastrecenton the same query flipped a result set from 2026 dates descending to 1950 dates ascending.addedTodayconfirmed live: narrowed a 336,946-result query down to 420.citedbyconfirmed live: a reverse-citation search against a case with 149 citing documents paginated correctly past the first 10 (maxpages=2returned 20), and the first result matched the same case'scitedbyarray from a priorget_judgmentcall exactly.pagesReturnedforsearch_case_law: confirmed live at 10 results per page — amaxpages=3call on a broad query returned exactly 30 docs.ceil(docs.length / 10)is the correct page count. A zero-hit search still bills as 1 page (Rs 0.50) — confirmed live.- Field names differ from IndianKanoon's own docs. The raw
/search/response's citation array is calledcites(notciteListas the docs page's prose implies) — this connector renames it tociteListinsearch_case_law's own output for readability, but reads the rawcitesfield internally. The raw/doc/response usescites/citedby(notciteList/citedbyList) and is passed straight through fromget_judgment— the tool description names the real field names. tidaccepts numbers as well as strings. IndianKanoon's own JSON returnstidas a bare number (e.g.39641512), not a string, so copying atidstraight out of a search result would fail strict string validation. Alltidfields usez.coerce.string()instead ofz.string()to accept either.- Env-var cap parsing bug, found and fixed during verification:
Number(process.env.X) || defaultsilently replaces0with the default, because0is falsy in JS — soINDIANKANOON_SESSION_CALL_CAP=0(a legitimate "block everything" value) was being ignored. Fixed with anenvNumber()helper that only falls back when the var is unset, empty, or non-numeric. - Spend guard, call-cap enforcement, and no-token-leakage (including on a bad/expired token, which correctly returns a 401 naming the env var, never the token value) were all confirmed against the live API.
- A
@hono/node-servermoderate advisory (path traversal in its optional static-file serving) shows up innpm auditas a transitive dependency of the MCP SDK. It's part of the SDK's HTTP transport, which this connector never uses (stdio only) — not a live exposure here, but worth re-checking if the SDK is ever switched to an HTTP transport.
