Skip to main content

Model Context Protocol (MCP) server for Indian Kanoon

Project description

Indian Kanoon MCP Server

An official Model Context Protocol (MCP) server for the Indian Kanoon API, built using the Python FastMCP framework.

This server allows LLMs (like Claude, Cursor, ChatGPT, etc.) to query the Indian Kanoon legal database directly, search for court judgments, download document texts, view citations, and retrieve document fragments.


Prerequisites & Installation

The server is built to run seamlessly with uv, Astral's fast Python package installer and runner.

1. Install uv

If you do not have uv installed, you can install it using one of the following methods:

macOS (Homebrew):

brew install uv

Linux/macOS (curl):

curl -LsSf https://astral.sh/uv/install.sh | sh

Windows:

powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

2. Install Project Dependencies

Navigate to the mcp_server directory and synchronize the dependencies:

uv sync

3. Set your API Token

Ensure the INDIANKANOON_API_TOKEN environment variable is set. For local testing, you can export it in your terminal:

export INDIANKANOON_API_TOKEN=your_actual_api_token_here

(Alternatively, you can also place it in a .env file in the directory where you run the server).


How to Run & Test the Server

Because this is a standard input/output (stdio) based MCP server, running it directly as a script (e.g. uv run server.py) will wait for JSON-RPC messages and throw a validation error if run interactively in a normal shell. Use the following methods to test and run it correctly:

1. Run the Integration Tests

We have provided a test script to verify that your configuration and API token are working correctly:

uv run python test.py

This runs a search query and fetches document fragments directly from the API.

2. Start the Interactive MCP Inspector

FastMCP comes with a developer console/UI that lets you inspect and trigger the server's tools in your web browser:

uv run mcp dev server.py

This will start the server and print a local URL (e.g., http://localhost:5173 or http://127.0.0.1:6274). Open that URL in your browser to view the interactive console.

Alternatively, you can manually launch the official MCP Inspector using npx:

npx @modelcontextprotocol/inspector uv run server.py

---## Connecting the Server to MCP Clients

You can connect the server to clients without using absolute paths by installing it locally as a tool, or using uvx directly (once the package is published to PyPI).

Option A: Local Tool Installation (Recommended for Local Dev)

Navigate to the mcp_server directory and install the package globally using uv:

uv tool install .

This registers indian-kanoon-mcp as a global executable on your system. You can then run it from anywhere.

Claude Desktop Configuration:

Add this to your claude_desktop_config.json:

{
  "mcpServers": {
    "indian-kanoon": {
      "command": "indian-kanoon-mcp",
      "env": {
        "INDIANKANOON_API_TOKEN": "your_actual_api_token_here"
      }
    }
  }
}

Cursor IDE:

In Cursor Settings -> Features -> MCP:

  • Name: indian-kanoon
  • Type: stdio
  • Command: indian-kanoon-mcp

Option B: Using uvx / pip (Once Published to PyPI)

If you publish the package to PyPI (as indian-kanoon-mcp), users won't even need to download this repository. They can run it directly:

Claude Desktop Configuration:

{
  "mcpServers": {
    "indian-kanoon": {
      "command": "uvx",
      "args": [
        "indian-kanoon-mcp"
      ],
      "env": {
        "INDIANKANOON_API_TOKEN": "your_actual_api_token_here"
      }
    }
  }
}

Cursor IDE:

  • Name: indian-kanoon
  • Type: stdio
  • Command: uvx indian-kanoon-mcp

(Alternatively, users can install it globally via pip install indian-kanoon-mcp or uv tool install indian-kanoon-mcp and use indian-kanoon-mcp as the command).


Exposed Tools

The server registers four main tools with the LLM:

1. search_kanoon

Search the Indian Kanoon legal database for documents.

  • Arguments:
    • query (string, required): The search query. Supports logical operators (ANDD, ORR, NOTT), phrase queries (in quotation marks), and metadata prefixes:
      • doctypes:supremecourt (or delhi, bombay, etc.)
      • fromdate:DD-MM-YYYY / todate:DD-MM-YYYY
      • title:kesavananda
      • cite:citation
      • author:arijit pasayat
      • bench:arijit pasayat
    • page_num (integer, optional, default: 0): Page index.
    • max_pages (integer, optional, default: 1): Maximum pages to retrieve.
    • max_cites (integer, optional): Optional list size for citations per matching document (capped at 50).

2. get_document

Retrieve the full text, metadata, and citation listings of a specific document.

  • Arguments:
    • doc_id (integer, required): Unique document ID (tid).
    • max_cites (integer, optional, default: 0): Maximum citations to retrieve in citeList (up to 50).
    • max_citedby (integer, optional, default: 0): Maximum references citing this document in citedbyList (up to 50).

3. get_document_fragment

Retrieve highlighted text fragments/snippets matching a query within a specific document.

  • Arguments:
    • doc_id (integer, required): Unique document ID (tid).
    • query (string, required): Search term or phrase to find fragments of.

4. get_original_document

Retrieve the original PDF/text copy if available (Base64-encoded PDF).

  • Arguments:
    • doc_id (integer, required): Unique document ID (tid).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

indian_kanoon_mcp-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

indian_kanoon_mcp-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file indian_kanoon_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: indian_kanoon_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for indian_kanoon_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e053c68803e85c3f7bec616067fd6892d44eb87e1cb9bea93f07ada7b6815433
MD5 1e789b4e740687e15d5994e485f0c9f9
BLAKE2b-256 1b5a336731e7e134ec32ebf2a814555a1cb1a307befbf49898f855c7dc82b476

See more details on using hashes here.

File details

Details for the file indian_kanoon_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: indian_kanoon_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for indian_kanoon_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e8fb33235e4955d49dbfe37468090dff8267609399c9b9bd306c762504ec2f72
MD5 12e7064311bb509c4c6d7398a9dc76c9
BLAKE2b-256 2076e943666286faff7d471c4a0b684d5af0bb25f8bee0f5bca6ecb017ca3bc9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page