sabrewolfai-dev/crm-mcp-server
If you are the rightful owner of crm-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A minimalistic Model Context Protocol (MCP) Server that integrates with Supabase, Cal.com, Gmail, and Twilio APIs to provide a comprehensive suite of functionalities for database operations, event scheduling, email management, and communication services.
MCP Server with API Integrations
A minimalistic Model Context Protocol (MCP) Server that provides integrations with Supabase, Cal.com, Gmail, and Twilio APIs.
Features
- Supabase Integration: Database operations (CRUD) via REST API
- Cal.com Integration: Event scheduling and management
- Gmail Integration: Send emails and fetch messages
- Twilio Integration: Send SMS, WhatsApp messages, and make calls
- MCP Protocol Support: Standardized tool definitions and endpoints
- Security: Rate limiting, CORS, and Helmet security headers
- Logging: Winston-based logging with file and console output
Prerequisites
- Node.js 18.0.0 or higher
- npm or yarn package manager
- Accounts and API keys for:
- Supabase
- Cal.com
- Gmail/Google Cloud Console
- Twilio
Installation
-
Clone the repository
git clone <your-repo-url> cd mcp-server-integrations -
Install dependencies
npm install -
Set up environment variables
cp env.example .envEdit
.envwith your actual API credentials (see Configuration section below). -
Create logs directory
mkdir logs
Configuration
Environment Variables
Copy env.example to .env and configure the following:
Server Configuration
PORT: Server port (default: 3000)NODE_ENV: Environment (development/production)LOG_LEVEL: Logging level (error/warn/info/debug)ALLOWED_ORIGINS: Comma-separated list of allowed CORS origins
Supabase
- Go to Supabase and create a new project
- Get your project URL and anon key from Settings > API
- Set
SUPABASE_URLandSUPABASE_ANON_KEY
Cal.com
- Go to Cal.com and create an account
- Generate an API key from Settings > Developer
- Set
CAL_API_KEY
Gmail/Google
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Gmail API
- Create OAuth 2.0 credentials
- Set
GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET, andGOOGLE_REDIRECT_URI - Get refresh token using OAuth flow (see Gmail Setup section)
Twilio
- Go to Twilio Console
- Get Account SID and Auth Token from Dashboard
- Purchase a phone number
- Set
TWILIO_ACCOUNT_SID,TWILIO_AUTH_TOKEN, andTWILIO_PHONE_NUMBER
Gmail OAuth Setup
To use Gmail API, you need to complete the OAuth flow:
-
Start the server
npm run dev -
Get authorization URL
curl http://localhost:3000/api/gmail/auth-url -
Visit the URL and authorize the application
-
Exchange code for tokens
curl -X POST http://localhost:3000/api/gmail/token \ -H "Content-Type: application/json" \ -d '{"code": "YOUR_AUTHORIZATION_CODE"}' -
Update
.envwith the refresh token
Usage
Start the Server
# Development mode with auto-reload
npm run dev
# Production mode
npm start
Health Check
curl http://localhost:3000/health
MCP Tools
Get available tools:
curl http://localhost:3000/api/mcp/tools
API Endpoints
Supabase
# Query database
curl -X POST http://localhost:3000/api/supabase/query \
-H "Content-Type: application/json" \
-d '{
"table": "users",
"operation": "select",
"filters": {"active": true}
}'
Cal.com
# Schedule event
curl -X POST http://localhost:3000/api/cal/schedule \
-H "Content-Type: application/json" \
-d '{
"title": "Meeting",
"startTime": "2024-01-15T10:00:00Z",
"endTime": "2024-01-15T11:00:00Z",
"attendees": ["user@example.com"]
}'
# Get events
curl http://localhost:3000/api/cal/events
Gmail
# Send email
curl -X POST http://localhost:3000/api/gmail/send \
-H "Content-Type: application/json" \
-d '{
"to": "recipient@example.com",
"subject": "Test Email",
"body": "<h1>Hello World</h1>"
}'
# Get messages
curl http://localhost:3000/api/gmail/messages
Twilio
# Send SMS
curl -X POST http://localhost:3000/api/twilio/sms \
-H "Content-Type: application/json" \
-d '{
"to": "+1234567890",
"message": "Hello from MCP Server!"
}'
Development
Project Structure
src/
├── server.js # Main server file
├── services/ # API service integrations
│ ├── supabase.js # Supabase service
│ ├── cal.js # Cal.com service
│ ├── gmail.js # Gmail service
│ └── twilio.js # Twilio service
└── utils/
└── logger.js # Winston logger configuration
Adding New Services
- Create a new service file in
src/services/ - Implement the service class with required methods
- Add endpoints to
src/server.js - Update MCP tools definition
- Add environment variables to
env.example
Testing
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
Deployment
Docker
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN mkdir logs
EXPOSE 3000
CMD ["npm", "start"]
Environment Variables for Production
Make sure to set all required environment variables in your production environment:
- Use strong, unique values for all API keys
- Set
NODE_ENV=production - Configure proper
ALLOWED_ORIGINS - Set up proper logging and monitoring
GitHub Repository Setup
-
Initialize Git repository
git init git add . git commit -m "Initial commit: MCP Server with API integrations" -
Create GitHub repository
- Go to GitHub and create a new repository
- Don't initialize with README (we already have one)
-
Connect local repository to GitHub
git remote add origin https://github.com/yourusername/your-repo-name.git git branch -M main git push -u origin main -
Set up GitHub Actions (optional) Create
.github/workflows/ci.yml:name: CI on: [push, pull_request] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: '18' - run: npm ci - run: npm test
Security Considerations
- Never commit
.envfiles to version control - Use environment-specific API keys
- Implement proper rate limiting
- Validate all input data
- Use HTTPS in production
- Regularly rotate API keys
Troubleshooting
Common Issues
-
Port already in use
# Change PORT in .env or kill existing process lsof -ti:3000 | xargs kill -9 -
API authentication errors
- Verify API keys are correct
- Check API quotas and limits
- Ensure proper OAuth flow for Gmail
-
CORS errors
- Add your frontend URL to
ALLOWED_ORIGINS - Check browser developer tools for specific errors
- Add your frontend URL to
Logs
Check logs in the logs/ directory:
combined.log: All logserror.log: Error logs only
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details.
Support
For issues and questions:
- Check the troubleshooting section
- Review API documentation for each service
- Open an issue on GitHub