Customer Registration MCP Server
A Model Context Protocol (MCP) server for creating customers via an external API with Bearer token authentication.
Features
✅ MCP-compliant server implementation
✅ Bearer token authentication
✅ Required field validation (name, email, phone)
✅ Support for all optional customer fields
✅ Comprehensive error handling
✅ Development logging
✅ TypeScript implementation
Prerequisites
Node.js 18+
Yarn package manager
Installation
Install dependencies:
Configure environment variables:
Create a .env file in the root directory:
Usage
Development Mode
Run the server with auto-reload:
Or with watch mode:
Production Mode
Build the project:
Run the compiled server:
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
Example Success Response
Example Error Response
Configuring with MCP Clients
To use this server with an MCP-compatible client (like Claude Desktop), add the following to your MCP settings configuration:
Project Structure
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 gitignoredBearer token is never logged or exposed
Email validation prevents basic injection attempts
License
MIT
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Tools
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.