LeadMind MCP
README.md
# π§ LeadMind MCP β AI Lead Management CRM
<div align="center">






**Conversational AI lead management powered by the Model Context Protocol.**
Free-tier only β Groq LLM + SQLite. Zero paid APIs.
[π Live Dashboard](https://leadmind-frontend.onrender.com) Β· [π Backend API](https://leadmind-mcp-1.onrender.com) Β· [π MCP Docs](https://modelcontextprotocol.io) Β· [π§ Claude Desktop Config](#-claude-desktop-integration)
</div>
---
## β¨ Live Demo
> Try it right now β no login required. Dashboard resets every 4 hours.
| | |
|---|---|
| **Frontend Dashboard** | [https://leadmind-frontend.onrender.com](https://leadmind-frontend.onrender.com) |
| **Backend REST API** | [https://leadmind-mcp-1.onrender.com](https://leadmind-mcp-1.onrender.com) |
| **API Health Check** | [https://leadmind-mcp-1.onrender.com/health](https://leadmind-mcp-1.onrender.com/health) |
| **API Stats** | [https://leadmind-mcp-1.onrender.com/stats](https://leadmind-mcp-1.onrender.com/stats) |
---
## π― What is LeadMind?
LeadMind MCP is a complete AI-powered CRM that:
- **Auto-classifies leads** as Hot / Warm / Cold using Groq's Llama-3.3-70b
- **Suggests next actions** for each lead (AI-powered coaching)
- **Tracks full history** β every status change, classification, and note is audited
- **Works with Claude Desktop** via the Model Context Protocol β manage leads conversationally
- **Runs on free-tier everything** β Groq free API + SQLite + Render free hosting
---
## π Architecture
```
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Claude Desktop β
β (MCP Client β stdio) β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β MCP Protocol (stdio)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β leadmind-mcp/mcp_server.py β
β MCP Server β 8 Tools + 3 Resources β
β β
β βββββββββββ ββββββββββββ βββββββββββββββββββ β
β β Groq β β Fallbackβ β Cache (5 min) β β
β β Llama ββ β Rules ββ β TTL + SQLite β β
β β 70b β β Engine β β persistent β β
β βββββββββββ ββββββββββββ βββββββββββββββββββ β
β β β
β βΌ β
β βββββββββββββββββββ β
β β SQLite (WAL) β β
β β leadmind.db β β
β ββββββββββ¬βββββββββ β
βββββββββββββββββββββββββΌβββββββββββββββββββββββββββ
β
βββββββββββββββΌββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββ ββββββββββββ ββββββββββββββββ
β MCP CLI β β FastAPI β β Next.js β
β (Claude) β β REST API β β Dashboard β
β stdio β β :8000 β β (Render) β
ββββββββββββββ ββββββββββββ ββββββββββββββββ
```
---
## π Quick Start
### Prerequisites
- Python 3.12+
- [uv](https://docs.astral.sh/uv/) (recommended) or pip
- Groq API key (free at [console.groq.com](https://console.groq.com/keys)) β optional, fallback works without it
### 1. Clone & Install
```bash
git clone https://github.com/mansisonani07/leadmind-mcp.git
cd leadmind-mcp
pip install -r requirements.txt
```
### 2. Run the MCP Server (Claude Desktop)
```bash
python mcp_server.py
```
### 3. Run the REST API
```bash
python api_server.py # http://localhost:8000
```
### 4. Run the Web Dashboard
```bash
python web_dashboard.py # http://localhost:8000 (HTML + API combined)
```
### 5. Run the Next.js Frontend
```bash
cd ..
npm install
LEADMIND_BACKEND_URL=http://localhost:8000 npm run dev
```
---
## π€ Claude Desktop Integration
Add this to your Claude Desktop config file:
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
```json
{
"mcpServers": {
"leadmind": {
"command": "python",
"args": ["/path/to/leadmind-mcp/mcp_server.py"],
"env": {
"GROQ_API_KEY": "gsk_your_key_here"
}
}
}
}
```
Then ask Claude things like:
- *"Show me all hot leads"*
- *"Add a new lead: Sarah Chen, sarah@acme.com, interested in enterprise plan"*
- *"What should I do next with lead #5?"*
- *"Classify this: We need a CRM solution, budget approved, looking to sign next week"*
---
## π MCP Tools Exposed
| Tool | Description |
|------|-------------|
| `get_leads` | List leads, filter by status |
| `classify_lead` | AI classification β Hot/Warm/Cold with reasoning |
| `add_lead` | Add a lead + auto-classify on insert |
| `update_lead_status` | Manual status override + history log |
| `get_lead_stats` | Pipeline aggregate statistics |
| `get_lead_history` | Full event timeline per lead |
| `suggest_next_action` | AI-recommended next step for a lead |
| `bulk_import_leads` | CSV parse + batch classify |
### MCP Resources
| URI | Description |
|-----|-------------|
| `leads://dashboard` | Live pipeline snapshot |
| `audit://recent` | Recent tool-call audit log |
### MCP Prompts
| Name | Description |
|------|-------------|
| `weekly_lead_review` | Structured weekly summary |
---
## π‘ REST API Endpoints
| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/health` | Health check + service info |
| `GET` | `/stats` | Pipeline stats + Groq usage |
| `GET` | `/leads?status=Hot` | List leads (optional status filter) |
| `GET` | `/leads/{id}` | Single lead + history timeline |
| `POST` | `/leads` | Add a lead (auto-classifies) |
| `PATCH` | `/leads/{id}/status` | Update lead status |
| `GET` | `/leads/{id}/next-action` | AI next-action suggestion |
| `POST` | `/leads/bulk-csv` | Bulk import from CSV |
| `GET` | `/audit?limit=50` | Recent tool-call audit log |
| `GET` | `/dashboard` | Full dashboard snapshot |
| `POST` | `/demo/reset` | Reset database to seed data |
**Try it:**
```bash
curl https://leadmind-mcp-1.onrender.com/health
curl https://leadmind-mcp-1.onrender.com/leads?status=Hot
curl https://leadmind-mcp-1.onrender.com/stats
```
---
## β‘ Reliability Engineering
LeadMind is built with production-grade resilience:
| Feature | Description |
|---------|-------------|
| π **Three-tier classification** | Cache β Groq LLM β Rule-based fallback |
| π¦ **TTL Cache** | 5-minute cache avoids redundant Groq calls |
| π‘οΈ **Rate-limit handler** | Graceful degradation on Groq 429 errors |
| π **Auto-restart** | Dashboard auto-restarts Python if it crashes |
| ποΈ **SQLite WAL mode** | Concurrent reads + atomic writes |
| π **Demo auto-reset** | Fresh data every 4 hours (configurable) |
| π **Audit logging** | Every tool call tracked with duration |
---
## π¨ Dashboard Features
- **6 KPI cards** β Total leads, Hot leads, Conversion rate, Avg response, Groq calls, Sources
- **Pipeline distribution** β Visual bar chart by status
- **Source breakdown** β Leads by acquisition channel
- **Full leads table** β Search, filter by status, sort
- **Lead detail drawer** β Status update, AI next action, message, timeline
- **Add lead modal** β Auto-classifies with AI on submit
- **Audit log** β Every tool call with Groq/fallback/cache flags
- **MCP primitives panel** β Shows all exposed tools, resources, and prompts
- **Dark mode** β Toggle between light and dark themes
---
## π Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| `GROQ_API_KEY` | β | Free Groq API key |
| `DEMO_MODE` | `true` | Auto-reset DB to seed data |
| `DEMO_RESET_INTERVAL_SEC` | `14400` | Reset interval (4 hours) |
| `LEADMIND_AUTH_ENABLED` | `false` | Enable API key auth |
| `LEADMIND_API_KEY` | β | API secret key when auth enabled |
| `PORT` | `8000` | Backend listen port |
| `NEXT_PUBLIC_LEADMIND_BACKEND_URL` | β | Backend URL for Next.js frontend |
---
## π Project Structure
```
leadmind-mcp/
βββ mcp_server.py # MCP server (stdio) β used by Claude Desktop
βββ api_server.py # REST API server β used by Next.js frontend
βββ web_dashboard.py # Self-contained HTML dashboard + API
βββ tools.py # MCP tool implementations
βββ db.py # SQLite database layer
βββ groq_classifier.py # Groq LLM classification + caching
βββ fallback_classifier.py # Rule-based fallback classifier
βββ seed_data.py # Demo seed data (22 leads)
βββ config.py # Configuration from env vars
βββ cache.py # TTL cache implementation
βββ webhook_receiver.py # n8n / Gmail webhook receiver
βββ requirements.txt # Python dependencies
βββ claude_desktop_config.example.json
src/ # Next.js frontend (React + TypeScript)
βββ app/
β βββ page.tsx # Dashboard entry point
β βββ api/leadmind/[...path]/route.ts # API proxy
β βββ layout.tsx # Root layout with fonts + toasters
βββ components/leadmind/
β βββ DashboardPage.tsx # Main dashboard orchestrator
β βββ Header.tsx # App header with branding
β βββ StatsGrid.tsx # KPI cards + charts
β βββ LeadsTable.tsx # Searchable leads table
β βββ LeadDetailDrawer.tsx # Slide-out lead detail
β βββ AddLeadDialog.tsx # Add lead modal
β βββ AuditPanel.tsx # Tool call audit log
β βββ McpPrimitivesPanel.tsx # MCP tools/resources display
βββ lib/
β βββ leadmind-api.ts # API client (fetch wrapper)
β βββ leadmind-ui.ts # Status colors, formatters
βββ components/ui/ # shadcn/ui components
```
---
## π’ Deployment
### Render (Free Tier)
**Backend:** `render.com` β New Web Service
- Build: `pip install -r requirements.txt`
- Start: `python api_server.py`
- Set `GROQ_API_KEY` env var
**Frontend:** `render.com` β New Web Service
- Build: `npm install && npm run build`
- Start: `next start -p $PORT`
- Set `NEXT_PUBLIC_LEADMIND_BACKEND_URL=https://your-backend.onrender.com`
---
## π License
MIT License β free for personal and commercial use.
---
## π Credits
- [Groq](https://groq.com) β Free LLM inference (Llama-3.3-70b)
- [Model Context Protocol](https://modelcontextprotocol.io) by Anthropic
- [FastAPI](https://fastapi.tiangolo.com) β Python web framework
- [Next.js](https://nextjs.org) β React framework
- [shadcn/ui](https://ui.shadcn.com) β UI component library
---
<div align="center">
**Built with β€οΈ by [mansisonani07](https://github.com/mansisonani07)**
β If you find this useful, give it a star!
</div>
```
This server cannot be deployed
Maintenance
ActivitySlowing
ResponsivenessNo issues