npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

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.

Readme

IndianKanoon MCP Connector

npm version CI License: MIT

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

  1. Sign up at https://api.indiankanoon.org/signup/ for a personal API token (Rs 500 free trial credit on signup).

  2. Add this to your MCP client's config (shown for Claude Code/Desktop; any MCP client that supports a stdio server with an env block 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.

  3. Restart or reconnect your MCP client and confirm indiankanoon shows 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 token

The 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 and Authorization: Token <token> / Accept: application/json headers — 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/citedby are NOT separate query parameters. A live test with doctypes sent as its own &doctypes=supremecourt param was silently ignored (results spanned every court). These filters only work embedded as key: value operator text inside formInput itself (e.g. formInput=... doctypes: supremecourt), which is what composeFormInput() in indiankanoon.js does. addedToday is a bare flag (added:today, no value) handled as its own line in the same function. maxcites, pagenum, and maxpages are genuine separate query parameters (they shape the response, not the query) — also confirmed live.
  • sortby confirmed live: reversing mostrecent/leastrecent on the same query flipped a result set from 2026 dates descending to 1950 dates ascending.
  • addedToday confirmed live: narrowed a 336,946-result query down to 420.
  • citedby confirmed live: a reverse-citation search against a case with 149 citing documents paginated correctly past the first 10 (maxpages=2 returned 20), and the first result matched the same case's citedby array from a prior get_judgment call exactly.
  • pagesReturned for search_case_law: confirmed live at 10 results per page — a maxpages=3 call 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 called cites (not citeList as the docs page's prose implies) — this connector renames it to citeList in search_case_law's own output for readability, but reads the raw cites field internally. The raw /doc/ response uses cites/citedby (not citeList/citedbyList) and is passed straight through from get_judgment — the tool description names the real field names.
  • tid accepts numbers as well as strings. IndianKanoon's own JSON returns tid as a bare number (e.g. 39641512), not a string, so copying a tid straight out of a search result would fail strict string validation. All tid fields use z.coerce.string() instead of z.string() to accept either.
  • Env-var cap parsing bug, found and fixed during verification: Number(process.env.X) || default silently replaces 0 with the default, because 0 is falsy in JS — so INDIANKANOON_SESSION_CALL_CAP=0 (a legitimate "block everything" value) was being ignored. Fixed with an envNumber() 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-server moderate advisory (path traversal in its optional static-file serving) shows up in npm audit as 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.