Skip to main content
Glama
GhostLex MCP Server

GhostLex MCP Server

README.md
# GhostLex MCP Server ๐Ÿ‡ฎ๐Ÿ‡ณโš–๏ธ

GhostLex Research Systems as a Model Context Protocol (MCP) Server. 
This exposes our core Indian legal AI capabilities to any MCP-compatible environment (Claude Desktop, Cursor, Antigravity Editor, ChatGPT, etc.).

## ๐Ÿš€ What It Does

This server provides **5 tools** and **1 resource** for deep legal research on the newly enacted **BNS/BNSS/BSA** (Bharatiya Nyaya Sanhita, etc.):
1. `analyze_legal_query` โ€” Deep legal research with full statutory mapping and landmark Supreme Court citations.
2. `search_vault` โ€” Search locally cached research to save API credits.
3. `list_vault_entries` โ€” View all past research currently in the vault.
4. `generate_word_report` โ€” Full pipeline: Research โ†’ Format to `GhostLex_Analysis_*.docx` โ†’ Save.
5. `get_case_summary` โ€” Quick 200-word summary on any Indian legal topic.

**Resource:**
- `ghostlex://vault` โ€” Exposes the entire JSON case vault as readable context for the AI.

## ๐Ÿ› ๏ธ Setup & Installation

### 1. Prerequisites
Ensure you have Python 3.10+ installed.

### 2. Install Dependencies
```bash
cd "the ghost engine"
pip install -r requirements.txt
```

### 3. API Key
You **must** set your Google AI Studio API key as an environment variable before running the server or connecting to it.
- **Windows:** `set GOOGLE_API_KEY="your_api_key_here"`
- **Mac/Linux:** `export GOOGLE_API_KEY="your_api_key_here"`

## ๐Ÿ”Œ Connecting to Claude Desktop / Antigravity

Add the following to your MCP configuration file (`mcp_config.json` or `claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "ghostlex-legal-ai": {
      "command": "python",
      "args": [
        "C:/path/to/the ghost engine/ghostlex_mcp_server.py"
      ],
      "env": {
        "GOOGLE_API_KEY": "your_api_key_here"
      }
    }
  }
}
```
*(Make sure to change the path to where your `ghostlex_mcp_server.py` file actually lives!)*

## ๐Ÿงช Testing Locally (MCP Inspector)

You can run the interactive MCP inspector to test all tools directly in your browser:

```bash
set GOOGLE_API_KEY="AIzaSy..." # your key
mcp dev ghostlex_mcp_server.py
```
This will open a web UI where you can click "Call Tool" and verify everything works.

## ๐Ÿ›ก๏ธ DPDP Compliance
This server automatically runs a compliance sweep on startup, erasing any generated `.docx` reports older than 24 hours to comply with the DPDP Act 2023.

---
*Prepared by GhostLex Research Desk | Copyright ยฉ 2026 GhostLex Research Systems*
*Created and Open-Sourced by **Kabir Khan***