Twilio SMS MCP server

Integrates with Twilio to enable sending SMS messages and retrieving message logs through a FastMCP framework with phone validation and authentication.
Back to servers
Setup instructions
Provider
Gabriel Paulos
Release date
Mar 19, 2025
Language
Python

This Python-based MCP server integrates with Twilio to provide messaging capabilities through a simple API. It currently offers tools for sending messages and retrieving message logs, with plans for future expansion to include prompts and call features.

Installation

To set up the Twilio MCP server on your system, follow these steps:

Prerequisites

Make sure you have Python 3.8+ installed on your system.

Step 1: Clone the Repository

git clone https://github.com/yourusername/twilio-mcp-python.git
cd twilio-mcp-python

Step 2: Install Dependencies

pip install -r requirements.txt

Step 3: Configure Environment Variables

Create a .env file in the root directory with your Twilio credentials:

TWILIO_ACCOUNT_SID=your_account_sid
TWILIO_AUTH_TOKEN=your_auth_token
TWILIO_PHONE_NUMBER=your_twilio_phone_number

Usage

The MCP server provides two main functions: sending messages and retrieving message logs.

Sending Messages

To send a message using the MCP server:

from twilio_mcp import send_message

# Send a simple text message
response = send_message(
    to="+1234567890",
    body="Hello from MCP server!",
    media_url=None  # Optional: URL to media to include with message
)

# Check the response
print(f"Message SID: {response.sid}")
print(f"Status: {response.status}")

Retrieving Message Logs

To retrieve logs of messages sent through your Twilio account:

from twilio_mcp import get_message_logs

# Get all message logs
logs = get_message_logs()

# Get logs with filters
filtered_logs = get_message_logs(
    from_number="+1234567890",  # Optional: filter by sender
    to_number="+10987654321",   # Optional: filter by recipient
    date_sent="2023-06-01",     # Optional: filter by date
    limit=100                   # Optional: limit number of results
)

# Process the logs
for message in filtered_logs:
    print(f"From: {message.from_}")
    print(f"To: {message.to}")
    print(f"Body: {message.body}")
    print(f"Date Sent: {message.date_sent}")
    print("---")

Configuration Options

The MCP server can be configured with additional options for greater flexibility:

Custom Webhook URL

Set a custom webhook URL to receive status updates:

from twilio_mcp import send_message

response = send_message(
    to="+1234567890",
    body="Message with status updates",
    status_callback="https://your-webhook-url.com/updates"
)

Media Messages

Send MMS messages by including media URLs:

from twilio_mcp import send_message

response = send_message(
    to="+1234567890",
    body="Check out this image!",
    media_url=["https://example.com/image.jpg"]
)

Multiple media URLs can be included as a list.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "twilio-mcp-python" '{"command":"python","args":["-m","twilio-mcp-python"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "twilio-mcp-python": {
            "command": "python",
            "args": [
                "-m",
                "twilio-mcp-python"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "twilio-mcp-python": {
            "command": "python",
            "args": [
                "-m",
                "twilio-mcp-python"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later