MCP Customer Support AI
# MCP Customer Support AI
A production-oriented **Model Context Protocol (MCP)** project built with **Node.js, TypeScript, MongoDB, and an LLM**.
This project demonstrates how an AI application can interact with external systems through MCP tools in a structured, secure, and scalable way.
The project is being developed incrementally, from a basic MCP server and tool to a production-style AI-powered customer support system.
---
## π Project Overview
The goal of this project is to build an AI-powered customer support assistant that can understand user requests and use MCP tools to perform real-world operations.
### Example
A user can ask:
> "Check my latest order and create a support ticket if it is delayed."
The AI can determine that it needs to:
1. Find the customer.
2. Retrieve the customer's orders.
3. Identify the delayed order.
4. Create a support ticket.
The AI does not directly access the database.
Instead, it interacts with the application through MCP tools.
```text
User
β
βΌ
AI / LLM
β
βΌ
MCP Client
β
βΌ
βββββββββββββββ
β MCP Server β
ββββββββ¬βββββββ
β
ββββββββββββββΌβββββββββββββ
βΌ βΌ βΌ
Customer Tool Order Tool Ticket Tool
β β β
ββββββββββββββΌβββββββββββββ
βΌ
Services
β
βΌ
MongoDB
```
---
# π― Project Objectives
This project demonstrates:
* MCP server development
* MCP tool creation
* MCP client communication
* AI tool calling
* TypeScript architecture
* MongoDB integration
* Service-layer architecture
* Input validation
* Error handling
* Authentication and authorization
* Logging and monitoring
* Audit logging
* Production-oriented MCP architecture
* AI agent workflows
---
# π οΈ Tech Stack
## Backend
* Node.js
* TypeScript
* MCP SDK
* Zod
* MongoDB
* Mongoose
## AI
* LLM integration
* Tool calling
* AI Agent workflow
## Development
* MCP Inspector
* Git
* GitHub
* npm
## Planned Production Infrastructure
* Docker
* Redis
* Authentication
* Rate limiting
* Logging
* Monitoring
* CI/CD
---
# π Project Structure
```text
mcp-customer-support/
β
βββ src/
β β
β βββ index.ts
β β
β βββ tools/
β β βββ customer.tools.ts
β β βββ order.tools.ts
β β βββ ticket.tools.ts
β β
β βββ services/
β β βββ customer.service.ts
β β βββ order.service.ts
β β βββ ticket.service.ts
β β
β βββ models/
β β βββ customer.model.ts
β β βββ order.model.ts
β β βββ ticket.model.ts
β β
β βββ db/
β β βββ database.ts
β β
β βββ middleware/
β β βββ auth.ts
β β
β βββ utils/
β βββ logger.ts
β βββ errors.ts
β
βββ tests/
β
βββ .env.example
βββ .gitignore
βββ package.json
βββ package-lock.json
βββ tsconfig.json
βββ README.md
```
---
# ποΈ Development Phases
The project is intentionally divided into phases so each phase introduces an important MCP or production concept.
---
# Phase 1 β MCP Server Foundation
### Objective
Create a basic MCP server and expose the first tool.
### Implemented
* Node.js project
* TypeScript configuration
* MCP SDK
* MCP server
* STDIO transport
* Zod input validation
* First MCP tool
* MCP Inspector integration
### First Tool
```text
find_customer
```
Input:
```json
{
"email": "ashwani@example.com"
}
```
Output:
```json
{
"id": "customer_123",
"name": "Ashwani Yadav",
"email": "ashwani@example.com"
}
```
### Architecture
```text
MCP Inspector
β
βΌ
MCP Client
β
β STDIO
βΌ
MCP Server
β
βΌ
find_customer()
β
βΌ
Dummy Data
```
### Status
**Completed β
**
---
# Phase 2 β Multiple MCP Tools
### Objective
Create multiple tools representing real customer-support operations.
### Tools
```text
find_customer
get_customer_orders
create_support_ticket
```
### Example
#### find_customer
```text
find_customer(email)
```
#### get_customer_orders
```text
get_customer_orders(customerId)
```
#### create_support_ticket
```text
create_support_ticket(
customerId,
orderId,
issue
)
```
### Expected Architecture
```text
MCP Server
β
βββββββββββββββββΌββββββββββββββββ
βΌ βΌ βΌ
find_customer() get_orders() create_ticket()
```
### Status
**Planned π§**
---
# Phase 3 β MongoDB Integration
### Objective
Replace dummy data with real persistent data.
### Database
MongoDB
### Collections
```text
customers
orders
support_tickets
```
### Architecture
```text
MCP Tool
β
βΌ
Service Layer
β
βΌ
Mongoose
β
βΌ
MongoDB
```
### Example
```text
find_customer()
β
βΌ
customer.service.ts
β
βΌ
Customer Model
β
βΌ
MongoDB
```
### Benefits
* Persistent data
* Proper database queries
* Indexing
* Schema validation
* Scalable data access
### Planned Index
```text
customers.email
```
This allows customer lookup by email to remain efficient as the dataset grows.
### Status
**Planned π§**
---
# Phase 4 β Service Layer & Clean Architecture
### Objective
Keep MCP tools separate from business logic.
Instead of putting database logic directly inside the MCP tool:
```text
Tool
β
Service
β
Database
```
### Example
```text
customer.tools.ts
β
βΌ
customer.service.ts
β
βΌ
customer.model.ts
β
βΌ
MongoDB
```
### Why?
This gives us:
* Separation of concerns
* Testability
* Reusability
* Maintainability
* Easier migration to REST/GraphQL/internal services
### Status
**Planned π§**
---
# Phase 5 β MCP Client
### Objective
Build a dedicated MCP client that connects to the MCP server.
```text
ββββββββββββββββ
β MCP Client β
ββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββ
β MCP Server β
ββββββββββββββββ
```
The client will be able to:
### Discover tools
```text
listTools()
```
### Execute tools
```text
callTool()
```
For example:
```text
callTool(
"find_customer",
{
email: "ashwani@example.com"
}
)
```
### Status
**Planned π§**
---
# Phase 6 β LLM Integration
### Objective
Connect an LLM to the MCP client.
The architecture becomes:
```text
User
β
βΌ
LLM
β
βΌ
MCP Client
β
βΌ
MCP Server
β
βΌ
Tools
β
βΌ
MongoDB
```
The LLM will decide which tool should be called based on the user's request.
### Example
User:
```text
Check my latest order.
```
AI:
```text
I need the customer's orders.
```
Tool:
```text
get_customer_orders()
```
The tool returns the order data.
The AI then generates a natural-language response.
### Status
**Planned π§**
---
# Phase 7 β AI Agent Workflow
### Objective
Allow the LLM to perform multi-step workflows.
Example request:
```text
Check my latest order and create a support
ticket if it is delayed.
```
The AI workflow:
```text
User Request
β
βΌ
LLM
β
βΌ
find_customer()
β
βΌ
get_customer_orders()
β
βΌ
Analyze orders
β
βΌ
Is order delayed?
/ \
Yes No
β β
βΌ βΌ
create_support_ticket Response
β
βΌ
Response
```
This demonstrates the difference between simply exposing tools and building an **AI agent capable of tool orchestration**.
### Status
**Planned π§**
---
# Phase 8 β Authentication & Authorization
### Objective
Secure MCP operations.
Authentication verifies:
> Who is the user?
Authorization verifies:
> What is the user allowed to do?
Example permissions:
```text
customer.read
order.read
ticket.create
ticket.update
admin.refund
```
Example:
```text
Customer
βββ find_customer β
βββ get_orders β
βββ create_ticket β
βββ refund_order β
Admin
βββ find_customer β
βββ get_orders β
βββ create_ticket β
βββ refund_order β
```
### Status
**Planned π§**
---
# Phase 9 β Error Handling
### Objective
Create consistent error handling across tools.
Example:
```text
CustomerNotFoundError
OrderNotFoundError
UnauthorizedError
ValidationError
DatabaseError
ToolExecutionError
```
MCP tool responses will clearly communicate failures.
Example:
```json
{
"isError": true,
"message": "Customer not found"
}
```
### Status
**Planned π§**
---
# Phase 10 β Logging & Observability
### Objective
Track MCP operations in production.
Each tool execution should provide information such as:
```text
Request ID
User ID
Tool name
Arguments
Execution time
Status
Error
Timestamp
```
Example:
```text
INFO Tool Execution
tool: get_customer_orders
customerId: customer_123
duration: 85ms
status: success
```
### Monitoring Goals
* Tool latency
* Error rate
* Database latency
* AI response latency
* Tool usage frequency
* Failed tool calls
### Status
**Planned π§**
---
# Phase 11 β Rate Limiting
### Objective
Protect the MCP server from excessive or abusive requests.
Potential strategy:
```text
User
β
βΌ
Rate Limiter
β
βββ Allowed βββ MCP Tool
β
βββ Blocked βββ Rate Limit Error
```
Redis can be introduced for distributed rate limiting.
Example:
```text
100 requests / minute / user
```
### Status
**Planned π§**
---
# Phase 12 β Audit Logging
### Objective
Record sensitive AI-driven operations.
For example:
```text
User:
customer_123
AI requested:
create_support_ticket
Order:
order_123
Action:
Support ticket created
Timestamp:
2026-08-23T10:30:00Z
```
This is particularly important when AI agents can perform actions that modify business data.
### Status
**Planned π§**
---
# Phase 13 β Testing
### Unit Tests
Test:
* Services
* Validation
* Business logic
* Error handling
### Integration Tests
Test:
```text
MCP Tool
β
Service
β
MongoDB
```
### MCP Tests
Test:
```text
MCP Client
β
MCP Server
β
Tool
```
### Example
```text
find_customer
β
valid email
β
customer returned
```
and:
```text
find_customer
β
invalid email
β
validation error
```
### Status
**Planned π§**
---
# Phase 14 β Dockerization
### Objective
Containerize the application.
```text
Docker
β
βββ MCP Server
β
βββ MongoDB
β
βββ Redis
```
Example production architecture:
```text
βββββββββββββββ
β AI App β
ββββββββ¬βββββββ
β
βΌ
βββββββββββββββ
β MCP Server β
ββββββββ¬βββββββ
β
ββββββββββββΌβββββββββββ
βΌ βΌ βΌ
MongoDB Redis Logs
```
### Status
**Planned π§**
---
# Phase 15 β CI/CD
### Objective
Automate testing and deployment.
Pipeline:
```text
Developer
β
βΌ
Git Push
β
βΌ
GitHub Actions
β
βββ Install dependencies
βββ Lint
βββ Type check
βββ Run tests
βββ Build
βββ Deploy
```
### Status
**Planned π§**
---
# π Environment Variables
Never commit `.env` to GitHub.
Use:
```text
.env
```
for local development.
Example:
```env
MONGODB_URI=mongodb://localhost:27017/mcp-support
OPENAI_API_KEY=your_api_key
JWT_SECRET=your_secret
```
Provide:
```text
.env.example
```
instead:
```env
MONGODB_URI=
OPENAI_API_KEY=
JWT_SECRET=
```
---
# π§ͺ Development
Install dependencies:
```bash
npm install
```
Run development server:
```bash
npm run dev
```
Build:
```bash
npm run build
```
Run production build:
```bash
npm start
```
---
# π MCP Inspector
The MCP Inspector is used to test the MCP server and inspect available tools during development.
Example:
```bash
npx @modelcontextprotocol/inspector npx tsx src/index.ts
```
The Inspector allows us to:
* Connect to the MCP server
* Discover tools
* Inspect tool schemas
* Execute tools
* Inspect responses
* Debug MCP communication
---
# π§ MCP Concepts Demonstrated
This project demonstrates the following MCP concepts:
### MCP Server
Provides capabilities to MCP clients.
### MCP Client
Connects to MCP servers and invokes their capabilities.
### Tools
Executable operations exposed to AI systems.
Examples:
```text
find_customer
get_customer_orders
create_support_ticket
```
### Resources
Read-only contextual data that can be exposed to an MCP client.
Potential future resources:
```text
customer://customer_123
order://order_123
```
### Prompts
Reusable prompt templates/workflows that can be exposed through MCP.
Potential example:
```text
customer_support_resolution
```
---
# π Production Architecture
The final architecture is planned to look like:
```text
βββββββββββββββββ
β User β
βββββββββ¬ββββββββ
β
βΌ
βββββββββββββββββ
β LLM / AI β
βββββββββ¬ββββββββ
β
βΌ
βββββββββββββββββ
β MCP Client β
βββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββββββββββββ
β MCP Server β
β β
β Authentication β
β Authorization β
β Validation β
β Rate Limiting β
β Logging β
βββββββββββββ¬βββββββββββββ
β
ββββββββββββββββββΌβββββββββββββββββ
βΌ βΌ βΌ
Customer Tool Order Tool Ticket Tool
β β β
ββββββββββββββββββΌβββββββββββββββββ
βΌ
Service Layer
β
βββββββββββββββββΌββββββββββββββββ
βΌ βΌ βΌ
MongoDB Redis Logging
```
---
# π Current Progress
| Phase | Feature | Status |
| ----- | ------------------------------ | ----------- |
| 1 | MCP Server Foundation | β
Completed |
| 2 | Multiple MCP Tools | π§ Planned |
| 3 | MongoDB Integration | π§ Planned |
| 4 | Service Layer | π§ Planned |
| 5 | MCP Client | π§ Planned |
| 6 | LLM Integration | π§ Planned |
| 7 | AI Agent Workflow | π§ Planned |
| 8 | Authentication & Authorization | π§ Planned |
| 9 | Error Handling | π§ Planned |
| 10 | Logging & Observability | π§ Planned |
| 11 | Rate Limiting | π§ Planned |
| 12 | Audit Logging | π§ Planned |
| 13 | Testing | π§ Planned |
| 14 | Dockerization | π§ Planned |
| 15 | CI/CD | π§ Planned |
---
# π‘ Example Future Conversation
Once all phases are complete, the system should support conversations such as:
**User**
> My latest order hasn't arrived. Can you check it and create a support ticket?
**AI**
```text
1. Find customer
2. Retrieve orders
3. Identify delayed order
4. Create support ticket
5. Return ticket information
```
**AI Response**
> Your order `ORD-123` is delayed. I've created support ticket `TICKET-456` for you.
---
# π Interview Topics Covered
This project can be used to demonstrate knowledge of:
* Model Context Protocol
* AI agents
* LLM tool calling
* Function calling
* MCP servers
* MCP clients
* Tool discovery
* Tool execution
* TypeScript
* Node.js
* MongoDB
* Mongoose
* Clean architecture
* Service-layer architecture
* Authentication
* Authorization
* RBAC
* Rate limiting
* Redis
* Logging
* Observability
* Docker
* CI/CD
* GitHub Actions
* Testing
* Scalable backend architecture
---
# π Future Improvements
Potential future enhancements include:
* Multiple MCP servers
* Payment MCP tools
* Email MCP tools
* CRM integration
* Slack integration
* GitHub integration
* Vector database
* RAG
* Semantic search
* Human-in-the-loop approval
* Tool permission policies
* Tool execution tracing
* Distributed MCP deployment
* Kubernetes deployment
---
# π¨βπ» Development Philosophy
The project follows these principles:
* Separation of concerns
* Strong typing
* Input validation
* Secure secret management
* Testable business logic
* Observable tool execution
* Least-privilege tool access
* Scalable architecture
* Clear MCP boundaries
---
# π License
This project is intended for learning, experimentation, and demonstrating MCP/AI engineering concepts.
Add an appropriate open-source license before distributing it publicly.
TDQS
Scored across 3 tools
Each tool targets a distinct entity and action: customer lookup by email, order retrieval, and ticket creation. There is no plausible way to confuse them, and the dependency (find customer, then fetch orders) is a workflow, not an ambiguity.
All names use consistent snake_case verb_noun form (get_, create_, find_). The only minor inconsistency is mixing 'find' and 'get' as lookup verbs, but the pattern remains readable and predictable.
Three tools is at the low end for a server framed as a full customer support AI; one tool per entity makes the surface feel thin. It is not egregious, but the scope implies more operations than are provided.
The surface supports only a one-shot flow of finding a customer, reading orders, and opening a ticket. There are no operations to read, update, comment on, or resolve tickets, and no order detail or customer history lookups, leaving agents at a dead end after ticket creation.