MCP server for Jawafdehi corruption cases, NES entities and NGM judicial data
Project description
Jawafdehi MCP Server
Model Context Protocol (MCP) server providing tools for querying Nepal's judicial data from the NGM (Nepal Governance Modernization) database.
Features
- Modular tool architecture for easy extension
- Unified document converter with smart auto-detection (Likhit + MarkItDown)
ngm_query_judicial: Execute SELECT queries against NGM court and court case tablesngm_extract_case_data: Extract complete judicial case information to Markdownsearch_jawafdehi_cases: Search published Jawafdehi accountability casesget_jawafdehi_case: Retrieve detailed case informationcreate_jawafdehi_case: Create a draft Jawafdehi case with simple fieldspatch_jawafdehi_case: Patch a Jawafdehi case with RFC 6902 operationssearch_nes_entities: Search Nepal Entity Service for persons and organizationsget_nes_entities: Retrieve complete entity profilesget_nes_tags: Fetch all available entity tagsconvert_date: Convert dates between AD and BS calendarsconvert_to_markdown: Convert documents with smart auto-detection- Likhit for Nepal government PDFs (CIAA press releases, etc.)
- MarkItDown for Office docs (DOCX, PPTX, XLSX), general PDFs, web pages
- Automatic fallback if Likhit fails
- Read-heavy access with authenticated Jawafdehi case write tools
- Timeout protection (default 15s)
- Comprehensive error handling
Architecture
The server uses a modular tool architecture:
src/jawafdehi_mcp/
├── server.py # Main MCP server
└── tools/ # Tool implementations
├── __init__.py # Tool registry
├── base.py # BaseTool abstract class
├── ngm_judicial.py # NGM judicial query tool
└── example_tool.py # Example tool template
Adding New Tools
- Create a new file in
src/jawafdehi_mcp/tools/(e.g.,my_tool.py) - Subclass
BaseTooland implement required methods:name: Tool identifierdescription: Tool descriptioninput_schema: JSON schema for inputsexecute(): Tool execution logic
- Import your tool in
tools/__init__.py - Add an instance to the
TOOLSlist inserver.py
See tools/example_tool.py for a template.
Installation
cd services/jawafdehi-mcp
poetry install
Configuration
Set the required environment variable:
export NGM_DATABASE_URL="postgresql://user:password@host:5432/database"
export JAWAFDEHI_API_TOKEN="your-drf-token"
Usage
As MCP Server
Add to your MCP client configuration:
{
"mcpServers": {
"jawafdehi": {
"command": "poetry",
"args": ["run", "jawafdehi-mcp"],
"cwd": "/path/to/services/jawafdehi-mcp",
"env": {
"NGM_DATABASE_URL": "postgresql://user:password@host:5432/database",
"JAWAFDEHI_API_TOKEN": "your-drf-token"
}
}
}
}
For Jawafdehi write tools, the token must belong to a user permitted by the Jawafdehi API to create or edit cases.
Available Tables
The following tables from NGM database are accessible:
courts- Court master table (district, high, supreme, special courts)court_cases- Court case metadata and registration informationcourt_case_hearings- Hearing records for each casecourt_case_entities- Plaintiff and defendant information
Note: The scraped_dates table is excluded from queries.
Documentation
- Architecture Overview - System design and structure
- Adding Tools Guide - How to add new tools
Development
Adding New Tools
See docs/ADDING_TOOLS.md for a complete guide on adding new tools to the server.
Running Tests
poetry run pytest
Linting
./scripts/format.sh --check
Formatting
poetry run black src/ tests/
poetry run isort src/ tests/
License
Open source - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jawafdehi_mcp-0.1.0.tar.gz.
File metadata
- Download URL: jawafdehi_mcp-0.1.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4a506ec09aaa0dc35643f6d2dd5ab4e6b2248656b6231e20e073835843ef485
|
|
| MD5 |
f3344e29a0c011d4b1604790e922d604
|
|
| BLAKE2b-256 |
9592c52c556bc474b8cbe7eeafd96abd059e5c5187f7c909abaeecb5cc349a7f
|
File details
Details for the file jawafdehi_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jawafdehi_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c868d21aa5084c5fb36b4b323894be10cd71744bbf7d8fadb38ba6e4e37c3c23
|
|
| MD5 |
d42263610ee84068e10be6560cfe5170
|
|
| BLAKE2b-256 |
2ca351ed1262d4ba771232ec908768375e1cef3518c4da81b3ba3e21eabef605
|