Skip to content

gagan0116/mcp_customer_support

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

139 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VARA.ai

Gemini 3 Python MCP Multi-Agent Neo4j

A multi-agent customer support platform built with Gemini 3, Neo4j, and MCP that delivers verified refund decisions with grounded, explainable reasoning from a policy knowledge graph.

πŸ† Google DeepMind Gemini 3 Hackathon Submission


πŸš€ Live Demo

Demo URL https://storage.googleapis.com/mcp_frontend/index.html
Demo Video YouTube Demo

No login required. The demo is publicly accessible.


πŸ“‹ Problem Statement

Customer support teams spend 70%+ of their time on repetitive refund/return requests. Each request requires:

  • Reading customer emails with attachments
  • Cross-referencing order databases
  • Consulting return policy documents
  • Making consistent decisions

VARA.ai automates this entire workflow using Gemini 3's advanced reasoning capabilities.


πŸ’‘ Solution Overview

VARA.ai is an end-to-end AI system that:

  1. Monitors Gmail for incoming refund/return requests
  2. Classifies emails using Gemini's understanding capabilities
  3. Extracts order details from email text and invoice attachments (Gemini Vision)
  4. Verifies against database using MCP-connected PostgreSQL
  5. Adjudicates requests by traversing a policy knowledge graph
  6. Records decisions with full reasoning transparency

πŸ§ͺ Testing Instructions

Demo URL

https://storage.googleapis.com/mcp_frontend/index.html

No login required. The demo is publicly accessible.


Feature 1: Email Processing Pipeline

  1. Open the demo URL β€” You'll land on the Email Pipeline page

  2. Select a scenario from the "Select Demo Scenario" dropdown

  3. View the request β€” Email content and attached invoice displayed on the left panel

  4. Click "Process Email Request" to trigger the full AI pipeline

  5. Watch the pipeline execute in real-time (~1 minute to complete):

    • Email Classification
    • Order Extraction (Gemini Vision)
    • Database Verification
    • Policy Adjudication (Extended Thinking)
    • Decision with Explanation

Note: In production, this pipeline runs automatically when a customer sends an email to vara.assist@gmail.com. The demo uses pre-defined scenarios because processing a real email requires the corresponding order to exist in our database. This website serves as a prototype to demonstrate the fully automated end-to-end pipeline.


Feature 2: Policy Knowledge Base

  1. Click "Policy Knowledge Base" in the navigation bar

Option A: View Existing Graph

  • Click "Visualize Graph" to view the pre-compiled knowledge graph (Best Buy return policy)
  • Interactive controls:
    • Scroll to zoom
    • Drag to pan
    • Click nodes for details

Option B: Compile New Policy (20-25 min)

  1. Upload any company's terms and conditions PDF
  2. Full compilation takes ~20-25 minutes (based on document length), orchestrated entirely by Gemini 3 Pro

The multi-agent system will automatically:

πŸ“„ Parse PDF β†’ Markdown (LlamaParse)
        ↓
🧠 Design graph schema (Ontology Agent)
        ↓
πŸ“€ Extract entities & relationships (Extraction Agent)
        ↓
πŸ” Validate quality (Critic Agent)
        ↓
πŸ”¨ Build Neo4j graph (Builder Agent)

πŸ€– Multi-Agent System

5 Specialized Agents

Agent Role Gemini Feature
Ontology Agent Designs knowledge graph schema from policy documents Structured Output
Extraction Agent Extracts policy rules, conditions, and relationships JSON Schema
Critic Agent Validates extraction quality and suggests improvements System Instruction
Builder Agent Constructs Neo4j knowledge graph with Cypher queries Structured Output
Adjudicator Agent Makes refund decisions with full reasoning Extended Thinking

πŸ”§ MCP (Model Context Protocol) Servers

VARA.ai uses FastMCP to create modular, tool-based AI capabilities:

db_verification_server β€” Order Database Access

Tool Description
list_orders_by_customer_email Fetch order history for a customer email
find_order_by_invoice_number Lookup single order with full details
find_order_by_order_invoice_id Alternative lookup by order_invoice_id
list_order_items_by_order_invoice_id Get line items for an order
verify_from_email_matches_customer Check if email exists in customers table
get_customer_orders_with_items Deep fetch with order items
select_order_id LLM-assisted order matching
llm_find_orders Generate SQL from natural language

doc_server β€” Invoice Processing

Tool Description
process_invoice Decode base64 PDF, parse text, and save to file

defect_analyzer β€” Product Defect Analysis

Tool Description
analyze_defect_image Analyze product defect images using Gemini Vision

πŸ”· Core Services

Neo4j Graph Engine

Policy knowledge graph operations for storing and querying return policies.

Function Description
check_neo4j_connection Test database connectivity
get_graph_schema Retrieve node labels and relationships
get_graph_statistics Node/relationship counts
execute_cypher_query Run read-only Cypher queries
execute_cypher_write Run write Cypher (CREATE, MERGE)
execute_cypher_batch Bulk graph construction
create_node Create/merge a node with properties
create_relationship Create relationship between nodes
create_schema_constraints Set up indexes and constraints
clear_graph Delete all data (destructive)
validate_graph_integrity Check for missing citations, orphans
sample_graph_data Get sample nodes for verification

Policy Engine

PDF document parsing using LlamaParse for policy ingestion.

Function Description
parse_all_policy_documents Parse all PDFs in directory to combined Markdown
parse_single_policy_document Parse a single PDF document

πŸ› οΈ Tech Stack

AI/ML

  • Gemini 3 API
  • google-genai SDK
  • Multi-Agent System

Databases

  • PostgreSQL (pg8000)
  • Neo4j Aura

Cloud (GCP)

  • Cloud Run
  • Cloud Tasks
  • Pub/Sub
  • Cloud SQL
  • Cloud Storage
  • Firestore
  • Secret Manager

Frameworks

  • FastAPI
  • uvicorn
  • FastMCP (mcp[cli])
  • SSE-Starlette

Processing

  • LlamaParse
  • pypdf
  • BeautifulSoup4
  • Pillow

πŸ“ Project Structure

mcp_customer_support/
β”‚
β”œβ”€β”€ gmail-event-processor/           # πŸ“§ Email Ingestion Service (Cloud Run)
β”‚   β”œβ”€β”€ app.py                       # FastAPI Pub/Sub endpoint
β”‚   β”œβ”€β”€ classifier.py                # Gemini email classification
β”‚   β”œβ”€β”€ gmail_processor.py           # Gmail API integration
β”‚   β”œβ”€β”€ store_email.py               # GCS storage & Cloud Tasks queue
β”‚   β”œβ”€β”€ history_store.py             # Firestore state tracking
β”‚   β”œβ”€β”€ secret_manager.py            # Credentials management
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── requirements.txt
β”‚
β”œβ”€β”€ mcp_processor/                   # βš™οΈ Main Processing Service (Cloud Run)
β”‚   β”œβ”€β”€ app.py                       # Cloud Tasks endpoint
β”‚   β”œβ”€β”€ processor.py                 # MCPProcessor orchestrator
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── requirements.txt
β”‚
β”œβ”€β”€ policy_compiler_agents/          # πŸ€– Multi-Agent System
β”‚   β”œβ”€β”€ agent.py                     # Pipeline orchestrator
β”‚   β”œβ”€β”€ ontology_agent.py            # Graph schema design
β”‚   β”œβ”€β”€ extraction_agent.py          # Entity & relationship extraction
β”‚   β”œβ”€β”€ critic_agent.py              # Quality validation
β”‚   β”œβ”€β”€ builder_agent.py             # Neo4j graph construction
β”‚   β”œβ”€β”€ adjudicator_agent.py         # Decision making (Extended Thinking)
β”‚   β”œβ”€β”€ graph_traversal.py           # Policy graph traversal
β”‚   β”œβ”€β”€ source_retrieval.py          # Citation lookup
β”‚   β”œβ”€β”€ visualize_graph.py           # Graph visualization
β”‚   β”œβ”€β”€ ingestion.py                 # Document ingestion
β”‚   └── tools.py                     # Shared utilities
β”‚
β”œβ”€β”€ db_verification/                 # πŸ—„οΈ MCP Server - Database
β”‚   β”œβ”€β”€ db_verification_server.py    # MCP tools for order lookup
β”‚   β”œβ”€β”€ db.py                        # Cloud SQL connector
β”‚   └── llm_sql_runner.py            # Natural language SQL
β”‚
β”œβ”€β”€ doc_server/                      # πŸ“„ MCP Server - Document Processing
β”‚   └── mcp_doc_server.py            # Invoice PDF parsing
β”‚
β”œβ”€β”€ defect_analyzer/                 # πŸ” MCP Server - Defect Analysis
β”‚   └── mcp_server.py                # Gemini Vision defect analysis
β”‚
β”œβ”€β”€ neo4j_graph_engine/              # πŸ”· Neo4j Graph Operations
β”‚   β”œβ”€β”€ mcp_server.py                # Graph query functions
β”‚   └── db.py                        # Neo4j async driver
β”‚
β”œβ”€β”€ policy_engine/                   # πŸ“š Policy Document Parser
β”‚   └── mcp_server.py                # LlamaParse integration
β”‚
β”œβ”€β”€ knowledge_base_server/           # 🌐 Policy Compiler Web Service
β”‚   β”œβ”€β”€ main.py                      # FastAPI server with SSE
β”‚   β”œβ”€β”€ compiler_service.py          # Compilation orchestration
β”‚   └── static/                      # Web UI assets
β”‚
β”œβ”€β”€ web_dashboard_ui/                # πŸ–₯️ Frontend Dashboard
β”‚   └── static/                      # HTML/CSS/JS assets
β”‚
β”œβ”€β”€ policy_docs/                     # πŸ“š Policy Documents
β”‚   β”œβ”€β”€ combined_policy.md           # Parsed policy content
β”‚   β”œβ”€β”€ combined_policy_index.json   # Citation index
β”‚   └── policy_pdfs/                 # Source PDF files
β”‚
β”œβ”€β”€ artifacts/                       # πŸ“Š Processing Outputs
β”‚   └── knowledge_graph/             # Graph build artifacts
β”‚
β”œβ”€β”€ Sample_Database_Creation/        # πŸ”§ Database Setup Scripts
β”‚   β”œβ”€β”€ invoice.sql                  # Schema definitions
β”‚   └── process_invoices_update_db.py
β”‚
β”œβ”€β”€ scripts/                         # πŸ› οΈ Utility Scripts
β”‚   β”œβ”€β”€ cloud_db_connect.py          # Database connection test
β”‚   └── setup_gmail_auth.py          # OAuth setup
β”‚
β”œβ”€β”€ mcp_client.py                    # πŸ§ͺ Interactive MCP client
β”œβ”€β”€ requirements.txt                 # Python dependencies
β”œβ”€β”€ Dockerfile                       # Container configuration
β”œβ”€β”€ cloudbuild_gmail_processor.yaml                  # Gmail processor deployment
β”œβ”€β”€ cloudbuild_mcp_processor.yaml    # MCP processor deployment
└── cloudbuild_policy_compiler.yaml  # Policy compiler deployment

πŸš€ Local Development Setup

Prerequisites

  • Python 3.11+
  • Docker (optional)
  • Google Cloud account with enabled APIs
  • Neo4j Aura instance
  • LlamaParse API key

Installation

# Clone the repository
git clone https://github.com/gagan0116/mcp_customer_support.git
cd mcp_customer_support

# Create virtual environment
python -m venv venv
venv\Scripts\activate  # Windows
# source venv/bin/activate  # macOS/Linux

# Install dependencies
pip install -r requirements.txt

Environment Variables

Create a .env file in the project root:

# Gemini API
GEMINI_API_KEY=your_gemini_api_key

# Neo4j Aura
NEO4J_URI=neo4j+s://your-instance.databases.neo4j.io
NEO4J_USER=neo4j
NEO4J_PASSWORD=your_neo4j_password

# Cloud SQL (PostgreSQL)
CLOUD_INSTANCE=project:region:instance
CLOUD_DB_NAME=refunds_db
CLOUD_DB_USER=postgres
CLOUD_DB_PASS=your_db_password

# LlamaParse
LLAMA_CLOUD_API_KEY=your_llamaparse_key

# Google Cloud Storage
GCS_BUCKET_NAME=your_bucket_name

Running Locally

# Run the MCP client (interactive testing)
python mcp_client.py

# Run the policy compiler web service
cd knowledge_base_server
python main.py

πŸ‘₯ Contributors

Name GitHub
Gagan Vadlamudi @gagan0116
Naga Sai Satish Amara

πŸ”— Links

About

MCP-compatible customer service agent that automates refund/return requests from emails with Database verification, Policy clause evaluation and human review escalation.

Topics

Resources

Stars

Watchers

Forks

Contributors