courtlistener-mcp
An MCP server providing AI agents access to CourtListener's comprehensive legal database, featuring semantic search, hybrid search, citation verification, and research tools.
README
CourtListener MCP Server
An MCP (Model Context Protocol) server providing AI agents access to CourtListener's comprehensive legal database, featuring semantic search, hybrid search, citation verification, and research tools.
Intended for use with OpenCode and Claude Code via local system storage and runtime. Vibe-coded with Claude Code.
Why This Project?
This MCP server is the first to implement CourtListener's semantic search API (released November 2025), enabling natural language legal research with vector embeddings. While other MCP servers exist for CourtListener, they all use traditional keyword-only search.
Key Advantages:
- Semantic Search: Natural language queries using legal domain embeddings
- Hybrid Search: Combines semantic understanding with required keywords
- Citation Verification: Validates legal citations to prevent AI hallucinations
- Comprehensive Coverage: 12 tools covering 9+ million cases, 16,000+ judges, 3,353 courts
- Production Ready: Built with proper error handling, rate limiting, and async operations
Mission: Developed by DefendTheDisabled to support civil rights litigation and make legal research more accessible through AI-powered tools.
Features
Search Capabilities
- Semantic Search: Natural language case law search using CourtListener's vector embeddings
- Keyword Search: Boolean operators, fielded queries, and wildcards (AND, OR, NOT, phrases)
- Hybrid Search: Combine semantic understanding with required keywords for precision
- Citation Verification: Validate legal citations against 18+ million case records
Research Tools
- Case Retrieval: Full case metadata, opinion text, and docket information
- Judge Database: Search 16,000+ federal and state judges with biographical data
- Oral Arguments: Access 3.3+ million minutes of oral argument recordings
- Court Information: Browse and search 3,353 courts across all jurisdictions
Requirements
- Python 3.10 or higher (3.12 recommended)
- CourtListener API key (get one free here)
- An MCP-compatible client (tested with Claude Code and OpenCode)
Installation
Quick Start
# Clone the repository
git clone https://github.com/DefendTheDisabled/courtlistener-mcp.git
cd courtlistener-mcp
# Install dependencies
pip install -e .
Configuration
-
Copy the example environment file:
cp .env.example .env -
Edit
.envand add your CourtListener API key:COURTLISTENER_API_KEY=your_api_token_hereGet your free API key at: https://www.courtlistener.com/help/api/rest/
Usage
This server currently supports STDIO transport for local MCP clients. Future versions may include HTTP transport for remote access by web-based AI platforms.
OpenCode
Using CLI (Recommended):
opencode mcp add
Follow the prompts:
- Server name:
courtlistener - Type:
local - Command:
python - Args:
/absolute/path/to/courtlistener-mcp/src/server.py
Manual Configuration:
Add to your OpenCode config (~/.config/opencode/opencode.json for global, or opencode.json in project root):
{
"mcp": {
"courtlistener": {
"type": "local",
"command": ["python", "/absolute/path/to/courtlistener-mcp/src/server.py"],
"enabled": true
}
}
}
Notes:
- Use absolute paths (e.g.,
C:/Users/YourName/MCP/courtlistener/src/server.pyon Windows) - You can install to any directory you choose
- The
.envfile in the server directory will be auto-loaded - See OpenCode MCP documentation for more details
Claude Code
Using CLI:
claude mcp add courtlistener python /absolute/path/to/courtlistener-mcp/src/server.py
Manual Configuration:
Edit ~/.claude/settings.json:
{
"mcpServers": {
"courtlistener": {
"command": "python",
"args": ["/absolute/path/to/courtlistener-mcp/src/server.py"]
}
}
}
Notes:
- Use absolute paths
- The
.envfile in the server directory will be auto-loaded
Other MCP Clients
This server uses STDIO transport and follows the MCP specification.
Current limitation: Local clients only (runs as a child process on your system).
Future plans: We plan to develop an HTTP transport version that can be accessed remotely by web-based AI platforms (Claude web, ChatGPT, etc.) while maintaining security and proper authentication.
Available Tools
Search Tools (4)
| Tool | Description | Use Case |
|---|---|---|
courtlistener_search_cases_semantic |
Natural language case search | "Find cases about prisoners denied medical care" |
courtlistener_search_cases_keyword |
Boolean/fielded search | "deliberate indifference" AND prison |
courtlistener_search_cases_hybrid |
Semantic + required keywords | Best of both: context + precision |
courtlistener_verify_citation |
Validate citations | Verify "429 U.S. 97" exists and get details |
Retrieval Tools (4)
| Tool | Description |
|---|---|
courtlistener_get_case |
Get full case metadata by cluster ID |
courtlistener_get_opinion |
Get complete opinion text with citations |
courtlistener_get_docket |
Get docket information and filing history |
courtlistener_get_citing_cases |
Find all cases that cite a specific opinion |
Research Tools (4)
| Tool | Description |
|---|---|
courtlistener_search_judges |
Search judges by name, court, or appointment info |
courtlistener_search_oral_arguments |
Find oral argument recordings by case |
courtlistener_list_courts |
List all courts in the database |
courtlistener_get_court_info |
Get detailed information about a specific court |
Total: 12 tools providing comprehensive access to CourtListener's legal database.
Example Queries
Semantic Search (Natural Language)
Query: "prisoners denied medical treatment for serious conditions"
Returns cases semantically related to Eighth Amendment deliberate indifference claims, even if they don't use those exact terms.
Keyword Search (Boolean Operators)
Query: "deliberate indifference" AND prison AND medical
Court: ca9 (Ninth Circuit)
Date Range: 2020-2024
Precise Boolean search with field filtering for targeted research.
Hybrid Search (Best of Both)
Query: "prison conditions and medical care violations"
Required Terms: ["Eighth Amendment", "deliberate indifference"]
Semantic understanding of context + guaranteed inclusion of specific legal terms.
Citation Verification
Text: "In Estelle v. Gamble, 429 U.S. 97 (1976), the Court held..."
Validates the citation exists, returns full case metadata, and provides CourtListener URLs.
Judge Research
Query: "Sotomayor"
Returns biographical data, appointment history, education, and political affiliation.
Finding Citing Cases
Opinion ID: 109561 (Estelle v. Gamble)
Returns all subsequent cases that cite this opinion, essential for checking if a case is still good law.
Rate Limits
CourtListener provides 5,000 API requests per hour per authenticated user. The server handles rate limit errors gracefully and provides clear error messages.
Response Formats
All tools support two output formats:
- Markdown (default): Human-readable format for conversational use
- JSON: Structured data for programmatic processing
Specify format with the response_format parameter.
Troubleshooting
"API key not found" error
Make sure your .env file is in the same directory as server.py and contains:
COURTLISTENER_API_KEY=your_actual_key_here
Server not loading in Claude Code
- Check that you're using absolute paths in the MCP config
- Verify Python is in your PATH:
python --version - Test the server manually:
python /path/to/server.py - Check Claude Code logs for startup errors
"Rate limit exceeded" error
You've hit the 5,000 requests/hour limit. Wait an hour or use a different API key for testing.
Slow startup times
If the server takes 30+ seconds to start:
- Disable antivirus scanning for your Python installation and project directory
- This is often caused by real-time malware scanning on Windows
Citation not found
CourtListener has 18+ million citations but may not have very recent cases or unpublished opinions. Try:
- Checking the citation format (e.g., "429 U.S. 97" not "429 US 97")
- Using semantic search instead if you don't have a specific citation
- Verifying the case exists on courtlistener.com
Development
Running Tests
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/
Code Formatting
# Format code
black src/
# Sort imports
isort src/
Project Structure
courtlistener-mcp/
├── src/
│ ├── __init__.py
│ ├── server.py # FastMCP server with tool registration
│ ├── config.py # Environment configuration
│ └── api_client.py # CourtListener API wrapper
├── tests/
│ └── __init__.py # Test suite
├── .env.example # Environment template
├── .gitignore
├── pyproject.toml # Dependencies and metadata
├── README.md
└── LICENSE
Technology Stack
- MCP Framework: FastMCP 2.x
- HTTP Client: httpx (async with connection pooling)
- Validation: Pydantic 2.x
- Configuration: python-dotenv
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Areas where help is appreciated:
- Additional test coverage
- Performance optimizations
- Documentation improvements
- Bug reports and fixes
License
MIT License - see LICENSE file for details.
Acknowledgments
- CourtListener and the Free Law Project for providing free access to legal data
- FastMCP framework by Marvin
- The MCP community for protocol development and tooling
Related Projects
Support
- Issues: Please report bugs and feature requests via GitHub Issues
- CourtListener API: For API-related questions, see CourtListener's help documentation
- MCP Protocol: For MCP-specific questions, see the MCP documentation
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。