CourtListener MCP Server

MCP

Official hosted MCP from the nonprofit Free Law Project: search US federal and state court opinions, dockets and judges, extract and verify case citations in documents, and subscribe to case alerts. Needs a free CourtListener account (browser sign-in); a lawyer should review results.

freelawproject/courtlistener-api-client33
README

CourtListener API Client

A Python client for the CourtListener API, providing access to millions of legal opinions, dockets, judges, and more from Free Law Project.

Using an LLM? See the CourtListener MCP and its documentation.

Installation

pip install courtlistener-api-client

Authentication

You'll need a CourtListener API token. You can get one by creating an account and generating a token in your profile settings.

Set it as an environment variable:

export COURTLISTENER_API_TOKEN="your-token-here"

Or pass it directly to the client:

from courtlistener import CourtListener

client = CourtListener(api_token="your-token-here")

Quickstart

from courtlistener import CourtListener

client = CourtListener()

# Get a specific opinion by ID
opinion = client.opinions.get(1)

# Search for opinions
response = client.opinions.list(cluster__date_filed__gte="2020-01-01")

# Access results from the current page
for opinion in response.get_results():
    print(opinion)

# Check the total count of matching results
print(response.get_count())

# Iterate through all results across pages
response = client.dockets.list(court="scotus")
for docket in response:
    print(docket)

Pagination

List queries return a ResourceIterator that handles pagination automatically:

results = client.dockets.list(court="scotus")

# Iterate through all results across all pages
for docket in results:
    print(docket)

# Or navigate pages manually
results = client.dockets.list(court="scotus")
print(results.get_results())  # current page results

if results.has_next():
    results.next()
    print(results.get_results())  # next page results

Lookups

A field's lookups are the comparisons you can filter it by, beyond an exact match. The endpoint pages list them after each field, as in date_filed: string (date) (lookups: gt, gte, lt, lte, range, …). Add one to a field name with a double underscore, or pass a dict of lookups:

client.clusters.list(date_filed__gte="2020-01-01")
client.clusters.list(date_filed={"gte": "2020-01-01", "lt": "2021-01-01"})

Fields that point at another endpoint take filters on that endpoint the same way, such as client.opinions.list(cluster__date_filed__gte="2020-01-01").

Available Endpoints

For the full list of endpoints and details about their operations, see the documentation.

API usage and rate limits

client.api_usage.get() returns your live throttle usage per scope and rate, daily request counts for the last 14 days, and membership status. The endpoint has its own throttle scope, so checking usage never spends the quota being checked and it stays reachable when you are rate limited.

usage = client.api_usage.get()

for row in usage["current_usage"]:
    print(row["scope"], row["rate"], row["remaining"], row["reset_at"])

print(usage["historical_usage"]["total"])

Async

AsyncCourtListener mirrors CourtListener method for method. Anything that makes a request is awaited, iteration uses async for, and the client is an async context manager.

from courtlistener import AsyncCourtListener

async with AsyncCourtListener() as client:
    opinion = await client.opinions.get(1)

    results = client.dockets.list(court="scotus")
    async for docket in results:
        print(docket)