Switch to simplified Twilio MCP integration using @yiyang.1i/sms-mcp-server
- Replace API Key/Secret auth with Account SID/Auth Token - Configure MCP during Docker build instead of runtime - Remove mcp-config.json and config directory - Simplify startup script by removing MCP configuration logic - Update documentation and test scripts for new auth method The MCP server is now configured directly in the Dockerfile using 'claude mcp add-json' command, making the setup more reliable and eliminating runtime configuration complexity.
This commit is contained in:
parent
6cb57c9dc6
commit
d9bf0f4b53
@ -6,7 +6,6 @@ ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
|||||||
|
|
||||||
# Optional: Twilio credentials for SMS notifications
|
# Optional: Twilio credentials for SMS notifications
|
||||||
TWILIO_ACCOUNT_SID=your_twilio_account_sid
|
TWILIO_ACCOUNT_SID=your_twilio_account_sid
|
||||||
TWILIO_API_KEY=your_twilio_api_key
|
TWILIO_AUTH_TOKEN=your_twilio_auth_token
|
||||||
TWILIO_API_SECRET=your_twilio_api_secret
|
|
||||||
TWILIO_FROM_NUMBER=+1234567890
|
TWILIO_FROM_NUMBER=+1234567890
|
||||||
TWILIO_TO_NUMBER=+0987654321
|
TWILIO_TO_NUMBER=+0987654321
|
18
Dockerfile
18
Dockerfile
@ -28,14 +28,8 @@ RUN npm install -g @anthropic-ai/claude-code
|
|||||||
# Ensure npm global bin is in PATH
|
# Ensure npm global bin is in PATH
|
||||||
ENV PATH="/usr/local/bin:${PATH}"
|
ENV PATH="/usr/local/bin:${PATH}"
|
||||||
|
|
||||||
# Install Twilio MCP server
|
|
||||||
RUN npm install -g @twilio-alpha/mcp
|
|
||||||
|
|
||||||
# Create directories for configuration
|
# Create directories for configuration
|
||||||
RUN mkdir -p /app/config /app/.claude /home/claude-user/.claude
|
RUN mkdir -p /app/.claude /home/claude-user/.claude
|
||||||
|
|
||||||
# Copy MCP configuration
|
|
||||||
COPY config/mcp-config.json /app/config/
|
|
||||||
|
|
||||||
# Copy startup script
|
# Copy startup script
|
||||||
COPY scripts/startup.sh /app/
|
COPY scripts/startup.sh /app/
|
||||||
@ -51,6 +45,16 @@ RUN chown -R claude-user:claude-user /app /home/claude-user
|
|||||||
# Switch to non-root user
|
# Switch to non-root user
|
||||||
USER claude-user
|
USER claude-user
|
||||||
|
|
||||||
|
# Configure MCP server during build if Twilio credentials are provided
|
||||||
|
RUN bash -c 'source /app/.env && \
|
||||||
|
if [ -n "$TWILIO_ACCOUNT_SID" ] && [ -n "$TWILIO_AUTH_TOKEN" ]; then \
|
||||||
|
echo "Configuring Twilio MCP server..." && \
|
||||||
|
/usr/local/bin/claude mcp add-json twilio \
|
||||||
|
"{\"command\":\"npx\",\"args\":[\"-y\",\"@yiyang.1i/sms-mcp-server\"],\"env\":{\"ACCOUNT_SID\":\"$TWILIO_ACCOUNT_SID\",\"AUTH_TOKEN\":\"$TWILIO_AUTH_TOKEN\",\"FROM_NUMBER\":\"$TWILIO_FROM_NUMBER\"}}"; \
|
||||||
|
else \
|
||||||
|
echo "No Twilio credentials found, skipping MCP configuration"; \
|
||||||
|
fi'
|
||||||
|
|
||||||
# Set working directory to mounted volume
|
# Set working directory to mounted volume
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
|
|
||||||
|
@ -33,8 +33,7 @@ A Docker container setup for running Claude Code with full autonomous permission
|
|||||||
|
|
||||||
# For Twilio MCP integration (optional):
|
# For Twilio MCP integration (optional):
|
||||||
TWILIO_ACCOUNT_SID=your_twilio_sid
|
TWILIO_ACCOUNT_SID=your_twilio_sid
|
||||||
TWILIO_API_KEY=your_twilio_api_key
|
TWILIO_AUTH_TOKEN=your_twilio_auth_token
|
||||||
TWILIO_API_SECRET=your_twilio_api_secret
|
|
||||||
TWILIO_FROM_NUMBER=your_twilio_number
|
TWILIO_FROM_NUMBER=your_twilio_number
|
||||||
TWILIO_TO_NUMBER=your_phone_number
|
TWILIO_TO_NUMBER=your_phone_number
|
||||||
```
|
```
|
||||||
@ -44,7 +43,7 @@ A Docker container setup for running Claude Code with full autonomous permission
|
|||||||
> - You can use the image from any directory without needing the .env file
|
> - You can use the image from any directory without needing the .env file
|
||||||
> - Keep your image secure since it contains your credentials
|
> - Keep your image secure since it contains your credentials
|
||||||
|
|
||||||
> **Note**: Twilio MCP requires API Key/Secret instead of Auth Token. Create API keys in your Twilio Console under Account → API keys & tokens.
|
> **Note**: Twilio MCP uses Account SID and Auth Token. You can find these in your Twilio Console.
|
||||||
|
|
||||||
3. **Build and install:**
|
3. **Build and install:**
|
||||||
```bash
|
```bash
|
||||||
@ -138,8 +137,6 @@ claude-docker/
|
|||||||
│ ├── claude-docker.sh # Wrapper script for container
|
│ ├── claude-docker.sh # Wrapper script for container
|
||||||
│ ├── install.sh # Installation script
|
│ ├── install.sh # Installation script
|
||||||
│ └── startup.sh # Container startup script
|
│ └── startup.sh # Container startup script
|
||||||
├── config/
|
|
||||||
│ └── mcp-config.json # MCP server configuration
|
|
||||||
└── templates/
|
└── templates/
|
||||||
└── scratchpad.md # Template for project context
|
└── scratchpad.md # Template for project context
|
||||||
```
|
```
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"mcpServers": {
|
|
||||||
"twilio": {
|
|
||||||
"type": "stdio",
|
|
||||||
"command": "npx",
|
|
||||||
"args": [
|
|
||||||
"-y",
|
|
||||||
"@twilio-alpha/mcp",
|
|
||||||
"${TWILIO_ACCOUNT_SID}/${TWILIO_API_KEY}:${TWILIO_API_SECRET}",
|
|
||||||
"--services",
|
|
||||||
"twilio_api_v2010",
|
|
||||||
"--tags",
|
|
||||||
"Api20100401Message"
|
|
||||||
],
|
|
||||||
"env": {
|
|
||||||
"TWILIO_ACCOUNT_SID": "${TWILIO_ACCOUNT_SID}",
|
|
||||||
"TWILIO_API_KEY": "${TWILIO_API_KEY}",
|
|
||||||
"TWILIO_API_SECRET": "${TWILIO_API_SECRET}",
|
|
||||||
"TWILIO_FROM_NUMBER": "${TWILIO_FROM_NUMBER}",
|
|
||||||
"TWILIO_TO_NUMBER": "${TWILIO_TO_NUMBER}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -128,6 +128,41 @@ Building a Docker container that runs Claude Code with full autonomous permissio
|
|||||||
- Tokens stored in temp locations that get cleared
|
- Tokens stored in temp locations that get cleared
|
||||||
- Need to find exact token storage location and persist it
|
- Need to find exact token storage location and persist it
|
||||||
|
|
||||||
|
## MCP Integration Update (2024-12-17)
|
||||||
|
|
||||||
|
### ✅ COMPLETED: Simplified Twilio MCP Integration
|
||||||
|
|
||||||
|
**What Changed:**
|
||||||
|
1. **Switched MCP Server:** From `@twilio-alpha/mcp` (API Key/Secret) to `@yiyang.1i/sms-mcp-server` (Auth Token)
|
||||||
|
2. **Simplified Configuration:** MCP setup now happens during Docker build instead of runtime
|
||||||
|
3. **Removed Complexity:** No more mcp-config.json or environment variable substitution
|
||||||
|
|
||||||
|
**Implementation Details:**
|
||||||
|
1. **Updated .env.example:**
|
||||||
|
- Removed: `TWILIO_API_KEY` and `TWILIO_API_SECRET`
|
||||||
|
- Added: `TWILIO_AUTH_TOKEN`
|
||||||
|
- Kept: `TWILIO_ACCOUNT_SID`, `TWILIO_FROM_NUMBER`, `TWILIO_TO_NUMBER`
|
||||||
|
|
||||||
|
2. **Updated Dockerfile:**
|
||||||
|
- Removed global installation of `@twilio-alpha/mcp`
|
||||||
|
- Added MCP configuration during build using `claude mcp add-json` command
|
||||||
|
- MCP server is configured if Twilio credentials are present in .env
|
||||||
|
|
||||||
|
3. **Simplified startup.sh:**
|
||||||
|
- Removed all MCP configuration logic
|
||||||
|
- Just loads environment variables and starts Claude
|
||||||
|
- Shows Twilio status on startup
|
||||||
|
|
||||||
|
4. **Removed Files:**
|
||||||
|
- `config/mcp-config.json` (no longer needed)
|
||||||
|
- `config/` directory (now empty)
|
||||||
|
|
||||||
|
**Result:**
|
||||||
|
- MCP configuration is baked into the Docker image at build time
|
||||||
|
- No runtime configuration needed
|
||||||
|
- Simpler, more reliable setup
|
||||||
|
- SMS capability available via `twilio__send_text` command
|
||||||
|
|
||||||
## Quick References
|
## Quick References
|
||||||
- Install: `./scripts/install.sh`
|
- Install: `./scripts/install.sh`
|
||||||
- Usage: `claude-docker` (from any project directory)
|
- Usage: `claude-docker` (from any project directory)
|
||||||
|
@ -24,8 +24,7 @@ echo
|
|||||||
|
|
||||||
# Collect Twilio credentials
|
# Collect Twilio credentials
|
||||||
read -p "Enter your Twilio Account SID: " TWILIO_ACCOUNT_SID
|
read -p "Enter your Twilio Account SID: " TWILIO_ACCOUNT_SID
|
||||||
read -p "Enter your Twilio API Key: " TWILIO_API_KEY
|
read -sp "Enter your Twilio Auth Token: " TWILIO_AUTH_TOKEN
|
||||||
read -sp "Enter your Twilio API Secret: " TWILIO_API_SECRET
|
|
||||||
echo
|
echo
|
||||||
read -p "Enter your Twilio phone number (with country code, e.g., +1234567890): " TWILIO_FROM_NUMBER
|
read -p "Enter your Twilio phone number (with country code, e.g., +1234567890): " TWILIO_FROM_NUMBER
|
||||||
read -p "Enter the phone number to receive SMS (with country code): " TWILIO_TO_NUMBER
|
read -p "Enter the phone number to receive SMS (with country code): " TWILIO_TO_NUMBER
|
||||||
@ -34,8 +33,7 @@ read -p "Enter the phone number to receive SMS (with country code): " TWILIO_TO_
|
|||||||
cat > "$ENV_FILE" << EOF
|
cat > "$ENV_FILE" << EOF
|
||||||
# Twilio credentials for Claude Docker
|
# Twilio credentials for Claude Docker
|
||||||
TWILIO_ACCOUNT_SID=$TWILIO_ACCOUNT_SID
|
TWILIO_ACCOUNT_SID=$TWILIO_ACCOUNT_SID
|
||||||
TWILIO_API_KEY=$TWILIO_API_KEY
|
TWILIO_AUTH_TOKEN=$TWILIO_AUTH_TOKEN
|
||||||
TWILIO_API_SECRET=$TWILIO_API_SECRET
|
|
||||||
TWILIO_FROM_NUMBER=$TWILIO_FROM_NUMBER
|
TWILIO_FROM_NUMBER=$TWILIO_FROM_NUMBER
|
||||||
TWILIO_TO_NUMBER=$TWILIO_TO_NUMBER
|
TWILIO_TO_NUMBER=$TWILIO_TO_NUMBER
|
||||||
EOF
|
EOF
|
||||||
|
@ -1,29 +1,24 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# ABOUTME: Startup script for Claude Code container with MCP server
|
# ABOUTME: Startup script for Claude Code container with MCP server
|
||||||
# ABOUTME: Configures environment and starts Claude Code with Twilio MCP integration
|
# ABOUTME: Loads environment and starts Claude Code with pre-configured Twilio MCP
|
||||||
|
|
||||||
# Load environment variables from .env if it exists
|
# Load environment variables from .env if it exists
|
||||||
# Use the .env file baked into the image at build time
|
# Use the .env file baked into the image at build time
|
||||||
if [ -f /app/.env ]; then
|
if [ -f /app/.env ]; then
|
||||||
echo "Loading credentials from baked-in .env file"
|
echo "Loading environment from baked-in .env file"
|
||||||
set -a
|
set -a
|
||||||
source /app/.env 2>/dev/null || true
|
source /app/.env 2>/dev/null || true
|
||||||
set +a
|
set +a
|
||||||
|
|
||||||
# Export Twilio variables for MCP server
|
# Export Twilio variables for runtime use
|
||||||
export TWILIO_ACCOUNT_SID
|
export TWILIO_ACCOUNT_SID
|
||||||
export TWILIO_API_KEY
|
export TWILIO_AUTH_TOKEN
|
||||||
export TWILIO_API_SECRET
|
|
||||||
export TWILIO_FROM_NUMBER
|
export TWILIO_FROM_NUMBER
|
||||||
export TWILIO_TO_NUMBER
|
export TWILIO_TO_NUMBER
|
||||||
else
|
else
|
||||||
echo "WARNING: No .env file found in image. Twilio features will be unavailable."
|
echo "WARNING: No .env file found in image."
|
||||||
echo "To enable Twilio: create .env in claude-docker directory before building the image."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Configure Claude Code to use the MCP server
|
|
||||||
export CLAUDE_MCP_CONFIG=/app/config/mcp-config.json
|
|
||||||
|
|
||||||
# Check for existing authentication
|
# Check for existing authentication
|
||||||
if [ -f "$HOME/.claude/.credentials.json" ]; then
|
if [ -f "$HOME/.claude/.credentials.json" ]; then
|
||||||
echo "Found existing Claude authentication"
|
echo "Found existing Claude authentication"
|
||||||
@ -33,14 +28,14 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify Twilio MCP configuration
|
# Verify Twilio MCP configuration
|
||||||
if [ -n "$TWILIO_ACCOUNT_SID" ] && [ -n "$TWILIO_API_KEY" ] && [ -n "$TWILIO_API_SECRET" ]; then
|
if [ -n "$TWILIO_ACCOUNT_SID" ] && [ -n "$TWILIO_AUTH_TOKEN" ]; then
|
||||||
echo "Twilio MCP pre-configured with:"
|
echo "Twilio MCP server configured with:"
|
||||||
echo " - Account SID: ${TWILIO_ACCOUNT_SID:0:10}..."
|
echo " - Account SID: ${TWILIO_ACCOUNT_SID:0:10}..."
|
||||||
echo " - From Number: $TWILIO_FROM_NUMBER"
|
echo " - From Number: $TWILIO_FROM_NUMBER"
|
||||||
echo " - To Number: $TWILIO_TO_NUMBER"
|
echo " - To Number: $TWILIO_TO_NUMBER"
|
||||||
echo " - MCP Config: $CLAUDE_MCP_CONFIG"
|
echo " - SMS capability ready via: twilio__send_text"
|
||||||
else
|
else
|
||||||
echo "No Twilio credentials found, MCP features will be unavailable"
|
echo "No Twilio credentials found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start Claude Code with permissions bypass
|
# Start Claude Code with permissions bypass
|
||||||
|
@ -2,21 +2,20 @@
|
|||||||
|
|
||||||
// Test script to verify Twilio SMS functionality
|
// Test script to verify Twilio SMS functionality
|
||||||
const accountSid = process.env.TWILIO_ACCOUNT_SID;
|
const accountSid = process.env.TWILIO_ACCOUNT_SID;
|
||||||
const authToken = process.env.TWILIO_API_SECRET;
|
const authToken = process.env.TWILIO_AUTH_TOKEN;
|
||||||
const apiKey = process.env.TWILIO_API_KEY;
|
|
||||||
const fromNumber = process.env.TWILIO_FROM_NUMBER;
|
const fromNumber = process.env.TWILIO_FROM_NUMBER;
|
||||||
const toNumber = process.env.TWILIO_TO_NUMBER;
|
const toNumber = process.env.TWILIO_TO_NUMBER;
|
||||||
|
|
||||||
console.log('Twilio Test Configuration:');
|
console.log('Twilio Test Configuration:');
|
||||||
console.log(`Account SID: ${accountSid?.substring(0, 10)}...`);
|
console.log(`Account SID: ${accountSid?.substring(0, 10)}...`);
|
||||||
console.log(`API Key: ${apiKey?.substring(0, 10)}...`);
|
console.log(`Auth Token: ${authToken ? '***' + authToken.substring(authToken.length - 4) : 'Not set'}`);
|
||||||
console.log(`From: ${fromNumber}`);
|
console.log(`From: ${fromNumber}`);
|
||||||
console.log(`To: ${toNumber}`);
|
console.log(`To: ${toNumber}`);
|
||||||
|
|
||||||
// Using Twilio REST API directly
|
// Using Twilio REST API directly
|
||||||
const https = require('https');
|
const https = require('https');
|
||||||
|
|
||||||
const auth = Buffer.from(`${apiKey}:${authToken}`).toString('base64');
|
const auth = Buffer.from(`${accountSid}:${authToken}`).toString('base64');
|
||||||
const data = new URLSearchParams({
|
const data = new URLSearchParams({
|
||||||
To: toNumber,
|
To: toNumber,
|
||||||
From: fromNumber,
|
From: fromNumber,
|
||||||
|
Loading…
Reference in New Issue
Block a user