Skip to main content
Glama
ecourts-mcp-server

ecourts-mcp-server

by rithik-cmyk

ecourts-mcp-server v1.2.0

An MCP (Model Context Protocol) server that connects LLMs to the EcourtsIndia Partner API v1.3, enabling AI agents to search Indian court cases, retrieve orders, read cause lists, and access AI-generated summaries.

Tools (9 total)

Tool

Description

Billing

ecourts_get_case

Full case detail by CNR — parties, orders, IAs, notices, documents, hearings, FIR, linked cases, file AI status, case AI analysis

Per-request

ecourts_lookup_case

Workflow tool — find a case by human-readable number (e.g. "CS(OS) 123/2024") instead of CNR, returns full details

Per-request

ecourts_search_cases

Rich search with 30+ filter params, year filters, date ranges, faceted aggregations

Per-request

ecourts_get_order

Download order PDF with metadata (certified true copies)

Per-request

ecourts_get_order_ai

Extracted order text + pre-computed AI analysis (summary, outcome, key points)

Per-request

ecourts_get_court_structure

Browse state → district → complex → court hierarchy

Free

ecourts_search_causelist

Search cause list entries across all courts

₹1/request

ecourts_get_causelist_dates

Available cause list dates

Free

ecourts_refresh_case

Queue a fresh scrape of case data

Per-request

Related MCP server: mcp-juridico-brasil

Quick Start

npm install
npm run build
export ECOURTS_API_TOKEN="eci_live_your_token_here"
npm start

Deployment

Docker

# Build
docker build -t ecourts-mcp-server .

# Run
docker run -d \
  -e ECOURTS_API_TOKEN=eci_live_your_token_here \
  -p 3000:3000 \
  ecourts-mcp-server

# Health check
curl http://localhost:3000/health

Docker Compose

# Set your token
export ECOURTS_API_TOKEN=eci_live_your_token_here

# Start
docker compose up -d

# Verify
curl http://localhost:3000/health

Cloud Deployment

The Docker image works with any container platform:

  • AWS ECS / Fargate — Use the health check endpoint at /health

  • Google Cloud Run — Set PORT=8080 (Cloud Run default), server auto-adapts

  • Azure Container Apps — Standard HTTP container deployment

  • Railway / Render / Fly.io — Push the Dockerfile, set ECOURTS_API_TOKEN in secrets

The image runs as a non-root user, includes a HEALTHCHECK, and defaults to HTTP transport on port 3000.

Claude Desktop (stdio)

{
  "mcpServers": {
    "ecourts": {
      "command": "node",
      "args": ["/path/to/ecourts-mcp-server/dist/index.js"],
      "env": {
        "ECOURTS_API_TOKEN": "eci_live_your_token_here"
      }
    }
  }
}

Claude Code (stdio)

claude mcp add ecourts -- node /path/to/ecourts-mcp-server/dist/index.js

Running Tests

npm test                # 110 unit tests via vitest
npm run test:integration  # 24 integration tests (requires ECOURTS_API_TOKEN)
npm run test:all          # both

Tests cover: query parameter serialization, all formatting functions, facet rendering, all 14 API error code branches, schema boundary validation, safeHandler wrapper, truncation, date validation, and typed fields. Integration tests cover court structure hierarchy, case search with filters/sort/years, case detail, order metadata, cause list search by date, case refresh, and error scenarios.

CI/CD

The .github/workflows/ci.yml pipeline:

  1. Build & test on Node 20 and 22 (on push/PR to main)

  2. Docker build + health check on push to main

Architecture

src/
├── index.ts              # Entry point, transport (stdio/HTTP), health endpoint
├── constants.ts          # Base URLs, character limits
├── types.ts              # Full TypeScript interfaces for all API responses
├── schemas/index.ts      # Zod input validation with date regex enforcement
├── services/
│   ├── api-client.ts     # HTTP client, binary download, repeated-key array serializer, error handling
│   └── formatting.ts     # Markdown formatters for case, search, causelist, order
└── tools/index.ts        # 9 tool registrations with MCP annotations

Environment Variables

Variable

Required

Description

ECOURTS_API_TOKEN

Yes

EcourtsIndia Partner API bearer token

TRANSPORT

No

stdio (default) or http

PORT

No

HTTP port (default 3000, only for http transport)

Changelog

v1.2.0 (current)

Code Quality:

  • Eliminated all unsafe type casts — linkCases, subordinateCourt, and firDetails are now proper typed fields on CourtCaseData

  • CauseListEntry expanded with petitionerAdvocates, respondentAdvocates, internalCaseNo, dateCreated, dateModified

  • Proper AvailableDatesResponse and CaseFileSummary types replace inline anonymous types

  • All date parameters validated with YYYY-MM-DD regex at schema level

New Features:

  • ecourts_lookup_case — workflow tool that finds cases by human-readable number (e.g. "CS(OS) 123/2024") instead of CNR

  • Order file status in case detail — ecourts_get_case now shows which orders have AI analysis available with summary previews

  • Health check endpoint — GET /health for load balancers and container orchestrators

  • Error-safe HTTP transport — Express handler now catches errors instead of hanging

  • ecourts_get_order PDF download — returns order PDF as embedded resource with metadata (filename, file size) extracted from HTTP headers

Deployment:

  • Multi-stage Dockerfile (22MB Alpine image, non-root user, HEALTHCHECK)

  • docker-compose.yml with health check and token validation

  • GitHub Actions CI (Node 20/22 matrix, Docker build verification)

  • Test suite expanded to 110 unit tests + 24 integration tests

v1.1.0

  • Fixed array parameter serialization (courtCodes, caseTypes, etc.)

  • Added isError flag on MCP error responses

  • Complete error code handling (11 API error codes)

  • 15+ new search parameters (year filters, date ranges, categories, bench types)

  • Facet counts in search output

  • Comprehensive case detail formatting (all sections)

v1.0.0

  • Initial release with 8 tools covering all EcourtsIndia Partner API endpoints

Available Tools

3 tools
ecourts_get_caseGet Case DetailsA
Read-onlyIdempotent

Retrieve comprehensive details for an Indian court case by CNR (Case Number Record).

Returns: case status, parties (petitioners/respondents), advocates, judges, hearing history, listing dates, judgment orders, interim orders, interlocutory applications, notices, filed documents, tagged/connected matters, linked cases, earlier court details, FIR details (criminal), subordinate court, and AI case analysis.

Args:

  • cnr (string): Case Number Record, e.g. "DLHC010001232024"

Use this tool first to discover available order filenames (judgmentOrders[].orderUrl, interimOrders[].orderUrl) before calling ecourts_get_order or ecourts_get_order_ai.

Inputs: cnr (required).

ecourts_get_causelist_datesGet Cause List Available DatesA
Read-onlyIdempotent

Get dates for which cause list data is available, filtered by location.

At least one parameter is required: state, district_code, court_complex_code, or court_no.

Free endpoint (no credit charge, authentication required). Use the returned dates with ecourts_search_causelist to avoid empty searches.

Inputs: state, court_no, district_code, court_complex_code.

ecourts_search_casesSearch Court CasesA
Read-onlyIdempotent

Search for Indian court cases with text queries, filters, date ranges, year filters, and faceted aggregations.

Text search args (all optional): query, advocates, judges, petitioners, respondents, litigants

Filter args (arrays): court_codes, case_types, case_statuses, judicial_sections, case_categories, bench_types

Year filters (integer arrays): filing_years, registration_years, first_hearing_years, next_hearing_years, decision_years

Date ranges (YYYY-MM-DD): filing_date_from/to, registration_date_from/to, first_hearing_date_from/to, next_hearing_date_from/to, decision_date_from/to

Controls: include_facet_counts (bool), sort_by, sort_order, page, page_size (max 100)

Returns: matching cases with CNR, parties, dates, facet counts. Supply at least one search term or filter.

Inputs: page, query, judges, sort_by, +28 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: searching cases with filters, retrieving cause list availability dates, and getting detailed case info by CNR. No overlap in functionality.

    Naming Consistency5/5

    All tools follow a consistent 'ecourts_<verb>_<noun>' pattern (search_cases, get_causelist_dates, get_case), making them predictable and easy to distinguish.

    Tool Count2/5

    Only 3 tools are provided, which is too few for the apparent scope of an Indian court case retrieval system. The descriptions reference missing tools like ecourts_search_causelist and ecourts_get_order, indicating the set is incomplete.

    Completeness2/5

    The tool surface has significant gaps: there is no tool to actually retrieve a cause list or obtain court orders, even though the get_case tool returns order URLs. Users cannot complete full workflows as described.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers