mcp-leadgen-orchestrator

mcp-leadgen-orchestrator

Enables automated lead generation, AI enrichment, personalized messaging, and outreach orchestration through MCP tools and n8n workflows.

Category
Visit Server

README

MCP-Powered Lead Gen + Enrichment + Outreach System

A full-stack lead generation and outreach automation system built with Model Context Protocol (MCP), n8n orchestration, Groq AI, and a real-time monitoring dashboard.

๐ŸŽฏ Features

  • Lead Generation: Generate 200+ realistic leads with valid contact information
  • AI Enrichment: Enrich leads with company insights, personas, and pain points using Groq LLM
  • Message Personalization: Create personalized emails and LinkedIn DMs with A/B variations
  • Smart Outreach: Send messages with retry logic, rate limiting, and error handling
  • Real-time Monitoring: Track pipeline progress with a modern React dashboard
  • MCP Integration: Orchestrate workflow through Model Context Protocol
  • n8n Workflow: Visual workflow automation and orchestration

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   n8n       โ”‚โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚  MCP Server  โ”‚โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚   Backend   โ”‚
โ”‚  Workflow   โ”‚      โ”‚   (Tools)    โ”‚      โ”‚  Services   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚                      โ”‚
                            โ”‚                      โ–ผ
                            โ”‚               โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                            โ”‚               โ”‚   SQLite    โ”‚
                            โ”‚               โ”‚   Database  โ”‚
                            โ”‚               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ–ผ
                     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                     โ”‚   Frontend   โ”‚
                     โ”‚  Dashboard   โ”‚
                     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“‹ Prerequisites

  • Python 3.10+
  • Node.js 18+
  • n8n (remote self-hosted instance)
  • Groq API key (free tier available at https://console.groq.com)
  • ngrok account (free tier available at https://ngrok.com)

๐Ÿš€ Quick Start

1. Clone and Setup

cd e:\intern-assigment\linkind-mcp

2. Configure Environment

# Copy example environment file
cp .env.example .env

# Edit .env and add your Groq API key
# GROQ_API_KEY=your_key_here

3. Install Python Dependencies

# Create virtual environment
python -m venv venv

# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

4. Install Frontend Dependencies

npm install

5. Initialize Database

python backend/database.py

6. Start the Services

Terminal 1 - MCP Server:

python mcp_server/server.py

Terminal 2 - API Backend:

python backend/api.py

Terminal 3 - Frontend:

npm run dev

7. Access the Applications

  • Frontend Dashboard: http://localhost:3000
  • API Backend: http://localhost:8000
  • API Docs: http://localhost:8000/docs
  • n8n Editor: Your remote n8n instance URL

8. Setup ngrok Tunnel

To connect your local API with the remote n8n instance:

# In a new terminal, start ngrok
ngrok http 8000

Copy the ngrok URL (e.g., https://abc123.ngrok-free.app) and update your n8n workflow nodes to use this URL.

๐Ÿ“ Project Structure

linkind-mcp/
โ”œโ”€โ”€ backend/              # Python backend services
โ”‚   โ”œโ”€โ”€ api.py           # FastAPI application
โ”‚   โ”œโ”€โ”€ database.py      # SQLite database setup
โ”‚   โ”œโ”€โ”€ lead_generator.py # Lead generation logic
โ”‚   โ”œโ”€โ”€ enrichment.py    # Lead enrichment service
โ”‚   โ”œโ”€โ”€ messaging.py     # Message generation
โ”‚   โ””โ”€โ”€ outreach.py      # Message sending
โ”œโ”€โ”€ mcp_server/          # MCP server implementation
โ”‚   โ”œโ”€โ”€ server.py        # MCP server main
โ”‚   โ””โ”€โ”€ tools.py         # MCP tool definitions
โ”œโ”€โ”€ frontend/            # Next.js React frontend
โ”‚   โ”œโ”€โ”€ pages/          # Next.js pages
โ”‚   โ”œโ”€โ”€ components/     # React components
โ”‚   โ””โ”€โ”€ styles/         # CSS styles
โ”œโ”€โ”€ data/               # SQLite database storage
โ”œโ”€โ”€ .env.example        # Environment template
โ””โ”€โ”€ README.md           # This file

๐Ÿ”ง Configuration

Dry Run vs Live Run

Toggle between modes in the frontend or set in .env:

DRY_RUN_MODE=true   # Logs messages without sending
DRY_RUN_MODE=false  # Actually sends messages

Rate Limiting

Configure in .env:

RATE_LIMIT_PER_MINUTE=10  # Max messages per minute
MAX_RETRIES=2             # Retry attempts for failed sends

Email Configuration

For live email sending, configure SMTP:

SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=your_email@gmail.com
SMTP_PASSWORD=your_app_password  # Use Gmail App Password

๐ŸŽฎ Usage

How the System Works

The system now operates through automated triggers from external sources:

  1. Lead Capture:

    • Google Sheets: Add a new row with lead information
    • Facebook Lead Ads: User submits an instant form
  2. Automatic Processing:

    • n8n detects the new lead from trigger
    • Processes and normalizes the lead data
    • Sends to your local API via ngrok
    • API enriches the lead with AI insights
    • Generates personalized messages
    • Sends outreach (email/LinkedIn)
  3. Monitor Progress:

    • Open frontend dashboard at http://localhost:3000
    • View real-time metrics and lead status
    • Check enrichment data and generated messages

Pipeline Stages

  1. Process Lead โ†’ Receives and validates external lead data
  2. Enrich Lead โ†’ Adds AI-generated company insights and personas
  3. Generate Messages โ†’ Creates personalized email + LinkedIn DM
  4. Send Outreach โ†’ Delivers messages (or logs in dry-run mode)

Testing with Sample Data

Add a test lead to your Google Sheet with:

  • Name: John Smith
  • Email: john.smith@company.com
  • Phone: +1-555-0123
  • Job Title: VP of Sales
  • Company: TechCorp Solutions
  • Comments: Interested in improving team productivity and automation tools

The n8n workflow will automatically detect and process it, generating personalized messages based on the comments provided.

n8n Workflow Setup

  1. Access your n8n instance (remote self-hosted)
  2. Import the workflow: Navigate to n8n and import n8n/n8n-workflow.json
  3. Configure triggers:
    • Google Sheets Trigger: Connect your Google account and select the spreadsheet with lead data
      • Required columns: name, email, phone, job_title, company, comments
    • Facebook Lead Ads Trigger: Connect your Facebook account and select the form
      • Required fields: full_name, email, phone_number, job_title, company_name, comments
  4. Update API endpoints: Replace placeholder URLs in all HTTP Request nodes with your ngrok URL:
    • Run Pipeline: https://YOUR-NGROK-URL.ngrok-free.app/pipeline/run
    • Get Metrics: https://YOUR-NGROK-URL.ngrok-free.app/metrics
    • Get Leads: https://YOUR-NGROK-URL.ngrok-free.app/leads
  5. Activate the workflow

๐Ÿงช Testing

Test Lead Processing

python backend/lead_generator.py

Test API Endpoint

curl -X POST http://localhost:8000/pipeline/run \
  -H "Content-Type: application/json" \
  -d '{
    "dry_run": true,
    "enrichment_mode": "offline",
    "lead_count": 200,
    "channel": "both",
    "lead_data": {
      "name": "Jane Doe",
      "email": "jane@example.com",
      "phone": "+1-555-0199",
      "job_title": "CTO",
      "company": "Innovation Labs",
      "comments": "Looking for AI solutions to streamline operations",
      "source": "test"
    }
  }'

๐Ÿ“Š Database Schema

Leads are tracked through these statuses:

  • NEW โ†’ Lead created
  • ENRICHED โ†’ Lead enriched with insights
  • MESSAGED โ†’ Messages generated
  • SENT โ†’ Outreach sent successfully
  • FAILED โ†’ Process failed

๐Ÿ†“ Free Resources Used

  • Groq: Free tier LLM API (100 requests/minute)
  • SQLite: Local database (no limits)
  • n8n: Self-hosted open-source (free)
  • ngrok: Free tier for tunneling (https://ngrok.com)
  • External Lead Sources: Facebook Lead Ads, Google Sheets
  • FastAPI: Python web framework
  • Next.js: React framework <<<<<<< HEAD

๐Ÿ” Security Notes

  • Keep your ngrok URL private - it exposes your local API
  • Rotate ngrok URLs regularly (free tier URLs change on restart)
  • Use environment variables for sensitive data
  • Enable authentication on n8n in production
  • Never commit .env files to version control

๐Ÿ“ License

MIT

๐Ÿค Contributing

This is a take-home assignment project. For production use, consider adding:

  • Unit tests
  • WebSocket/SSE for real-time updates
  • Multi-tenant support
  • Export functionality
  • Advanced targeting rules
  • Mailhog (optional): Local SMTP testing server

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured