Twilio SMS Server
Enables AI assistants to send SMS messages via Twilio through the Model Context Protocol or a standalone REST API. It supports standard messaging, automated greetings, and creative content generation using natural language.
README
Twilio SMS Server
A versatile SMS service that can run as both a Model Context Protocol (MCP) server for Claude Desktop and as a standalone REST API for cloud deployment.
🚀 Two Deployment Modes
1. MCP Server Mode (Local with Claude Desktop)
Enables Claude and other AI assistants to send SMS messages through the Model Context Protocol.
2. Web API Mode (Cloud Deployment)
Standalone REST API that can be deployed to any cloud platform for web applications.
✨ Features
- 📱 Send SMS messages via Twilio
- 🌐 REST API endpoints for web integration
- 🔨 MCP server for Claude Desktop integration
- 📝 Pre-built prompts for common messaging scenarios
- 🔒 Secure handling of Twilio credentials
- 🐳 Docker support for easy deployment
- ☁️ Cloud deployment ready
📋 Requirements
- Node.js >= 18
- Twilio account with SMS capabilities
- Environment variables for Twilio credentials
⚙️ Environment Setup
Create a .env file in the project root:
# Twilio Configuration (Required)
ACCOUNT_SID=your_twilio_account_sid_here
AUTH_TOKEN=your_twilio_auth_token_here
FROM_NUMBER=+1234567890
# Server Configuration (Optional, defaults to 3000)
PORT=3000
🚀 Installation & Usage
Local Development
```bash
Install dependencies
npm install
Build the project
npm run build
Run as MCP server (for Claude Desktop)
npm run start:mcp
Run as Web API server
npm run start:web
Development mode (rebuilds and starts web server)
npm run dev:web ```
🌐 Web API Endpoints
When running in Web API mode, the following endpoints are available:
GET /
API documentation and usage examples
GET /health
Health check endpoint
POST /send-sms
Send an SMS message
Request Body:
{
"to": "+11234567890",
"message": "Your message here"
}
Response:
{
"success": true,
"message": "Message sent successfully",
"messageSid": "SM...",
"to": "+11234567890",
"from": "+1234567890"
}
POST /send-greeting
Send a greeting message for special occasions
Request Body:
{
"to": "+11234567890",
"occasion": "birthday",
"customMessage": "Optional custom message"
}
🖥️ Claude Desktop Configuration (MCP Mode)
To use this server with Claude Desktop, add the following to your configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"twilio": {
"command": "npx",
"args": [
"-y",
"@yiyang.1i/sms-mcp-server"
],
"env": {
"ACCOUNT_SID": "your_account_sid",
"AUTH_TOKEN": "your_auth_token",
"FROM_NUMBER": "your_twilio_number"
}
}
}
}
After updating the configuration, restart Claude Desktop. If connected successfully, you should see Twilio under the 🔨 menu.
☁️ Cloud Deployment
Option 1: Railway
- Connect your GitHub repository to Railway
- Set environment variables in Railway dashboard
- Deploy automatically
Option 2: Render
- Connect your repo to Render
- Create a new Web Service
- Build command:
npm install && npm run build - Start command:
npm run start:web - Add environment variables
Option 3: Heroku
heroku create your-app-name
heroku config:set ACCOUNT_SID=your_sid
heroku config:set AUTH_TOKEN=your_token
heroku config:set FROM_NUMBER=your_number
git push heroku main
Option 4: Docker
# Build Docker image
docker build -t twilio-sms-server .
# Run container
docker run -p 3000:3000 \
-e ACCOUNT_SID=your_sid \
-e AUTH_TOKEN=your_token \
-e FROM_NUMBER=your_number \
twilio-sms-server
🧪 Testing the API
Local Testing
# Start the server
npm run start:web
# Test health endpoint
curl http://localhost:3000/health
# Send a test SMS
curl -X POST http://localhost:3000/send-sms \
-H "Content-Type: application/json" \
-d '{"to": "+1234567890", "message": "Hello from the API!"}'
# Send a greeting
curl -X POST http://localhost:3000/send-greeting \
-H "Content-Type: application/json" \
-d '{"to": "+1234567890", "occasion": "birthday"}'
💬 Example Interactions with Claude (MCP Mode)
Here are some natural ways to interact with the server through Claude:
- Simple SMS:
Send a text message to +11234567890 saying "Don't forget about dinner tonight!"
- Creative SMS:
Write a haiku about autumn and send it to my number +11234567890
- Greeting Messages:
Send a birthday greeting to +11234567890
📝 Scripts Reference
npm run build- Build TypeScript to JavaScriptnpm run start:mcp- Start MCP server modenpm run start:web- Start web API server modenpm run dev:web- Development mode (rebuild + start web server)npm run watch- Watch TypeScript files for changes
⚠️ Important Notes
- Phone Number Format: All phone numbers must be in E.164 format (e.g., +11234567890)
- Twilio Trial Accounts: Can only send messages to verified phone numbers
- Rate Limits: Be aware of your Twilio account's rate limits and pricing
- Security: Keep your Twilio credentials secure and never commit them to version control
- Environment Variables: Use
.envfile for local development, set via platform for cloud deployment
🐛 Troubleshooting
Common Errors and Solutions:
-
"Phone number must be in E.164 format"
- Ensure phone number starts with "+" and includes country code
-
"Invalid credentials" / "accountSid must start with AC"
- Verify your ACCOUNT_SID and AUTH_TOKEN from Twilio Console
- Ensure environment variables are properly loaded
-
"Invalid 'To' Phone Number"
- For trial accounts: Verify the destination number in Twilio Console
- For paid accounts: Ensure the number format is correct
-
"Environment variable is required"
- Check that
.envfile exists and contains all required variables - For cloud deployment, ensure environment variables are set in platform settings
- Check that
🤝 Contributing
Contributions are welcome! Please read our contributing guidelines before submitting pull requests.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🔐 Security
Please do not include any sensitive information (like phone numbers or Twilio credentials) in GitHub issues or pull requests.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。