Customer Registration MCP Server
Enables creating and managing customer records via an external API with Bearer token authentication, supporting required fields (name, email, phone) and extensive optional data including addresses, UTM parameters, and tags.
README
Customer Registration MCP Server & Chatbot
This project provides two main components:
- MCP Server: A Model Context Protocol server for customer registration via an external API
- AI Chatbot: An OpenAI GPT-4o-mini powered chatbot that integrates with the MCP server via REST API
Features
MCP Server
- ✅ MCP-compliant server implementation (stdio transport)
- ✅ Bearer token authentication
- ✅ Required field validation (name, email, phone)
- ✅ Support for all optional customer fields
- ✅ Comprehensive error handling
- ✅ Development logging
- ✅ TypeScript implementation
AI Chatbot
- ✅ OpenAI GPT-4o-mini integration
- ✅ Configurable tone/style via environment variables
- ✅ REST API endpoint (
/api/chat) - ✅ Automatic MCP tool invocation based on conversation
- ✅ Conversation history management
- ✅ Express-based HTTP server
Prerequisites
- Node.js 18+
- Yarn package manager
Installation
- Install dependencies:
yarn install
- Configure environment variables:
Copy the example file and edit with your values:
cp .env.example .env
Edit .env:
# MCP Server Configuration
CUSTOMER_API_HOST=https://your-api-host.com
CUSTOMER_API_TOKEN=your_bearer_token_here
NODE_ENV=development
# Chatbot Configuration
OPENAI_API_KEY=sk-your-openai-api-key-here
AGENT_TONE=Professional, helpful, and efficient
# Alternative: AGENT_STYLE=Encouraging, visionary, witty
# Chatbot Server Port (optional, defaults to 3000)
CHATBOT_PORT=3000
Note: AGENT_TONE or AGENT_STYLE controls the chatbot's personality.
Usage
Running the MCP Server (standalone)
Development Mode:
yarn dev
Or with watch mode:
yarn watch
Production Mode:
# Build
yarn build
# Run
yarn start
Running the AI Chatbot Server
Development Mode:
yarn chatbot:dev
Production Mode:
# Build
yarn chatbot:build
# Run
yarn chatbot:start
The chatbot server will start on port 3000 (or your configured CHATBOT_PORT).
Chatbot API Endpoints
POST /api/chat
Send a message to the chatbot:
curl -X POST http://localhost:3000/api/chat \
-H "Content-Type: application/json" \
-d '{
"message": "Register a customer: John Doe, john@example.com, +1234567890",
"context": {}
}'
Response:
{
"reply": "Great! I've successfully registered John Doe as a customer. The customer ID is 12345.",
"actions": [
{
"tool": "createCustomer",
"input": {
"name": "John Doe",
"email": "john@example.com",
"phone": "+1234567890"
},
"result": {
"status": "success",
"customerId": 12345,
"data": {...}
}
}
]
}
POST /api/chat/reset
Reset the conversation history:
curl -X POST http://localhost:3000/api/chat/reset
GET /health
Health check:
curl http://localhost:3000/health
MCP Tool: createCustomer
Required Parameters
name(string): Customer full nameemail(string): Customer email address (validated)phone(string): Customer phone number
Optional Parameters
retention(boolean): Retention flagidentification(string): Customer ID document (e.g., CPF)zipcode(string): ZIP/Postal codestate(string): State/Provincestreet(string): Street namenumber(string): Street numberneighborhood(string): Neighborhoodcity(string): Citylist_ids(number): List ID for categorizationcreate_deal(boolean): Whether to create a dealtags(string): Tags for the customerurl(string): URL referenceutm_term(string): UTM term parameterutm_medium(string): UTM medium parameterutm_source(string): UTM source parameterutm_campaign(string): UTM campaign parametercompany_id(string): Company IDutm_content(string): UTM content parameter
Example Request
{
"name": "Tony Stark",
"email": "newone@avengers.com",
"phone": "(12) 99756-0001",
"city": "São Paulo",
"retention": true,
"identification": "251.482.720-58",
"tags": "coyo-jan"
}
Example Success Response
{
"status": "success",
"customerId": 12345,
"data": {
"id": 12345,
"name": "Tony Stark",
"email": "newone@avengers.com",
...
}
}
Example Error Response
{
"status": "error",
"error": "Validation failed",
"errors": [
"email is required",
"phone is required"
]
}
Configuring with MCP Clients
To use this server with an MCP-compatible client (like Claude Desktop), add the following to your MCP settings configuration:
{
"mcpServers": {
"customer-registration": {
"command": "node",
"args": ["/absolute/path/to/mcpNova/build/index.js"],
"env": {
"CUSTOMER_API_HOST": "https://your-api-host.com",
"CUSTOMER_API_TOKEN": "your_bearer_token_here",
"NODE_ENV": "production"
}
}
}
}
How the Chatbot Works
- User sends a message to
/api/chat - Chatbot adds message to conversation history
- OpenAI GPT-4o-mini processes the message with configured system prompt
- If LLM determines an action is needed (e.g.,
createCustomer), it responds with JSON - Chatbot extracts the action and calls MCP server via stdio
- MCP server validates data and calls the external customer API
- Result is returned to LLM for a friendly follow-up message
- Final response sent back to user
Example Chatbot Conversations
Simple Registration:
User: Register a customer: Jane Smith, jane@smith.com, +1-555-1234
Chatbot: I've successfully registered Jane Smith! The customer ID is 67890.
Multi-turn Conversation:
User: I need to add a new customer
Chatbot: `I'd be happy to help! I'll need:
- Full name
- Email address
- Phone number`
User: Name: Bob Johnson, Email: bob@johnson.com, Phone: 555-9876, City: New York
Chatbot: Perfect! I've registered Bob Johnson. Customer ID: 11223
Project Structure
mcpNova/
├── src/
│ ├── index.ts # MCP Server (stdio)
│ ├── chatbotServer.ts # Express REST API server
│ └── services/
│ ├── customerService.ts # Customer API integration
│ ├── mcpClient.ts # MCP client (stdio communication)
│ └── chatbotService.ts # OpenAI integration & logic
├── build/ # Compiled TypeScript
├── package.json
├── tsconfig.json
├── .env # Environment variables (gitignored)
├── .env.example # Environment template
└── README.md
API Endpoint
POST https://{{host}}/api/v1/customers
Headers:
Authorization: Bearer {{TOKEN}}Content-Type: application/json
Development Logging
When NODE_ENV=development, the server logs:
- Request URLs and payloads
- Response status and data
- API errors with details
Error Handling
The server handles:
- Missing or invalid required fields
- HTTP errors from the external API
- Network connectivity issues
- Invalid Bearer tokens
- Malformed requests
Security
- Environment variables are used for sensitive data (API host and token)
.envfiles are gitignored- Bearer token is never logged or exposed
- Email validation prevents basic injection attempts
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。