Skip to main content
Glama
Sukkamit

Customer MCP Server

by Sukkamit

Customer MCP Server

Customer MCP Server is a project for connecting LLMs to customer data using the Model Context Protocol (MCP), allowing AI clients to access customer data securely and with clear governance boundaries.

System Overview

The system is designed so that the LLM can only query customer data through defined tools, without direct database access.

What's Supported

  • Retrieve basic customer profile information

  • Perform semantic search over customer interaction history using vector embeddings

  • Summarize purchase data and financial transactions with exact values

  • Record audit logs of transactions

  • Prevent prompt injection and unauthorized data access

Related MCP server: safedb-mcp

Architecture

LLM Client
    |
    | MCP Protocol
    v
MCP Server (Python)
    |
    +-------------------+
    |                   |
    v                   v
Semantic Search      SQL / Financial
PostgreSQL + pgvector PostgreSQL

Key Features

1. Customer Profile

  • Retrieve basic customer information such as customer_id, name, email, phone, created_at

  • Search customer conversation/interaction history using embedding vectors

  • Suitable for semantic search of broad queries such as refund issue, complaint, billing concern

3. Financial Summary

  • Calculate order count and total purchase amount from the database

  • Use SQL aggregation to produce accurate and reliable values

  • Return an audit log of transactions with a hash reference

Hybrid Query Example

Example query:

"What issues has the customer reported, and what is their total purchase amount?"

Flow:

search_customer_interactions()

    |
    v

pgvector similarity search

    +

get_customer_purchase_summary()

    |
    v

SQL aggregation

    |
    v

Combined verified response

Process:

  1. MCP Server invokes semantic search from interaction_history using pgvector

  2. MCP Server retrieves financial summary from purchase_orders using SQL aggregation

  3. Combine the results:

  • Customer Context

  • Relevant Interaction

  • Exact Financial Amount

Return them to the LLM

4. Security Guardrails

  • Detects prompt injection patterns

  • Validates customer_id before accessing data

  • Restricts data access to MCP tools only

Technologies Used

  • Python 3.12+

  • FastMCP

  • asyncpg

  • pydantic

  • openai

  • google-genai

  • PostgreSQL 17 + pgvector

  • Docker Compose

Project Structure

customer-mcp/
├── app/
│   ├── config.py
│   ├── database.py
│   ├── embeddings.py
│   ├── mcp_server.py
│   ├── security.py
│   └── tools/
│       ├── customer.py
│       ├── financial.py
│       └── semantic_search.py
├── docs/
│   └── ARCHITECTURE.md
├── sql/
│   ├── 01_extensions.sql
│   ├── 02_schema.sql
│   ├── 03_indexes.sql
│   ├── 04_seed.sql
│   └── 05_security.sql
├── docker-compose.yml
├── requirements.txt
├── test_customer.py
├── test_embedding.py
├── test_financial.py
├── test_search.py
├── test_security.py
└── README.md

Prerequisites

  • Python 3.12 or newer

  • Docker Desktop

  • Network access to install packages from PyPI

Installation and Setup

1. Create a virtual environment

py -3.12 -m venv venv

On Windows:

venv\Scripts\activate

2. Install dependencies

pip install -r requirements.txt

3. Set up environment variables

Create a .env file with the following example:

DATABASE_URL=postgresql://mcp_readonly_user:CHANGE_ME@localhost:5432/customer_mcp

GEMINI_API_KEY=your_gemini_api_key_here

4. Start PostgreSQL database

docker compose up -d

Docker Compose will create a PostgreSQL + pgvector container and automatically initialize the database from the SQL scripts in the sql/ folder.

Note: SQL scripts in docker-entrypoint-initdb.d run only the first time a PostgreSQL volume is created.

To reinitialize everything from scratch:

docker compose down -v

docker compose up -d

Initialization order

sql/01_extensions.sql Enable PostgreSQL extensions Enable pgvector sql/02_schema.sql Create customer tables Create interaction history table Create purchase tables Create immutable audit structure sql/03_indexes.sql Create database indexes Create pgvector HNSW index for semantic search sql/04_seed.sql Insert demo customer data Insert interaction history Insert purchase records Insert audit records sql/05_security.sql Create read-only database user Grant SELECT permission

Verify the container

docker ps

5. Run MCP Server

python -m app.mcp_server

MCP Inspector

You can also inspect MCP Tools through the UI.

mcp-inspector python -m app.mcp_server

Available MCP Tools

get_customer_profile

Retrieve customer profile information

Data source:

  • customers table

Returns:

  • customer_id

  • first_name

  • last_name

  • email

  • phone

  • created_at

Example input:

{
  "customer_id": "550e8400-e29b-41d4-a716-446655440000"
}

Semantic search for interaction history using pgvector

Example input:

{
  "customer_id": "550e8400-e29b-41d4-a716-446655440000",
  "query": "refund issue",
  "limit": 3
}

get_customer_purchase_summary

Retrieve exact purchase totals using SQL aggregation

Example input:

{
  "customer_id": "550e8400-e29b-41d4-a716-446655440000"
}

Available MCP Tools

Tool

Purpose

get_customer_profile

Retrieve customer profile information

search_customer_interactions

Semantic search customer conversation history

get_customer_purchase_summary

Retrieve exact financial summary and audit log

Testing

You can run the following test files from the repository root:

python test_embedding.py
python test_search.py
python test_financial.py
python test_security.py
python test_customer.py

Security Notes

  • LLM cannot access the database directly

  • Data access is allowed only through MCP Tools

  • Input validation is applied to customer_id

  • Detects prompt injection patterns

  • Financial data uses SQL aggregation to return exact values

  • Audit log is an immutable append-only structure

  • The database user for MCP has least-privilege permissions

  • UPDATE / DELETE / DDL operations are not allowed

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • MCP server unifying ERPs, CRMs, APIs and knowledge base for Claude, ChatGPT and Gemini.

  • The Ramp MCP server enables users to securely connect Ramp with AI assistants like ChatGPT and Claude to query financial data and take actions using natural language. It transforms Ramp's developer API into a SQL interface that LLMs can query, allowing admins to analyze spend trends, identify cost savings, and run complex SQL analyses on comprehensive datasets (transactions, purchase orders, vendors, users), while all users can manage cards, view transactions, request reimbursements, and get expense policy answers.

  • Authenticated LLM MCP Agent

    1
  • The Grafbase MCP server sits in front of a GraphQL API and exposes an MCP protocol-compliant interface that allows AI agents and LLMs to explore and query GraphQL APIs using natural language. It provides tools to search schemas, introspect types and fields, and execute GraphQL queries while minimizing context bloat by returning only relevant schema subsets, with built-in support for authentication, authorization, and configurable access control.

Related MCP Servers

  • F
    license
    A
    quality
    D
    maintenance
    An MCP server that connects LLMs to SQL databases for development assistance, enabling query execution, schema exploration, and data manipulation while providing safety controls against destructive operations.
    5
    -
  • A
    license
    A
    quality
    C
    maintenance
    Secure MCP server for safe, read-only DB access by AI agents, with SQL guardrails, table allowlists, PII masking, and audit logs
    6
    50
    7
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A governed MCP server for integrating AI agents with customer data, featuring role-based access control, field redaction, and human-in-the-loop approval for secure support operations.
    1
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    A governed analytics MCP server that provides LLM agents with safe, read-only access to data warehouses through a layered safety pipeline including AST validation, column/row governance, PII masking, cost limits, and audit.
    -

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Sukkamit/Customer-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server