A complete autonomous agent system for Twitter/X interactions using a decoupled architecture with MCP (Model Context Protocol), ElizaOS, and a React Dashboard.
- Architecture Overview - System design, components, and data flow
- API Reference - Complete REST API documentation
- Deployment Guide - Step-by-step production setup
- User Manual - Dashboard usage and workflows
- Production Deployment - Implementation details
Monorepo Structure:
βββ packages/
β βββ mcp-server/ # Twitter API integration layer
β βββ eliza-agent/ # AI agent controller
β βββ ui/ # React dashboard for monitoring
βββ data/postgres/ # Persistent database storage
βββ scripts/ # Utility scripts (backup, etc.)
βββ docker-compose*.yaml # Development and production orchestration
Full Stack Architecture:
βββββββββββββββββββ REST API βββββββββββββββββββ
β React UI βββββββββββββββββββΊβ ElizaOS Agent β
β Dashboard β β (The Brain) β
β (The Face) β β β
βββββββββββββββββββ β - Personality β
β β - Decision β
β β - API Server β
β βββββββββββββββββββ
β β
β MCP Protocol
β β
β βββββββββββββββββββ
β β MCP Server β
β β (The Hands) β
βββββββββββββββββββββββββββΊβ β
β - Twitter API β
β - Read/Write β
β - Safety β
βββββββββββββββββββ
β
β
βΌ
Twitter/X
- Node.js 22+
- pnpm (package manager)
- Rettiwt API key (for Twitter access)
- OpenAI API key (for AI reasoning)
git clone <repository-url>
cd x-bot
pnpm install# Copy environment templates
cp packages/mcp-server/.env.example packages/mcp-server/.env
cp packages/eliza-agent/.env.example packages/eliza-agent/.env
# Edit .env files with your API keys:
# - RETTIWT_API_KEY
# - OPENAI_API_KEY# Build all packages
pnpm build
# Development mode (starts both services)
pnpm dev
# Production deployment
pnpm deployMCP Server - Twitter API integration layer
- β 6 Twitter Operations: Search, profile lookup, timeline, posting, liking, retweeting
- β Safety Features: Dry-run mode, rate limit handling, input validation
- β Error Handling: Distinct error messages for ElizaOS decision-making
ElizaOS Agent - AI controller and personality layer
- β Twitter Curator Persona: Content analysis, sentiment monitoring, quality engagement
- β MCP Integration: Stdio protocol connection to MCP server
- β Process Management: PM2 configuration with auto-restart and logging
# Install all dependencies
pnpm install
# Build all packages
pnpm build
# Clean all builds
pnpm clean
# Development servers
pnpm dev:mcp # Start MCP server only
pnpm dev:eliza # Start Eliza agent only
pnpm dev # Start both services
# Production
pnpm start # Start Eliza agent (connects to MCP server)
pnpm deploy # PM2 production deployment
pnpm logs # View PM2 logsCreate .env files in each package:
MCP Server (packages/mcp-server/.env):
RETTIWT_API_KEY=your_rettiwt_api_key_here
DRY_RUN=true # Optional: Enable dry-run modeEliza Agent (packages/eliza-agent/.env):
OPENAI_API_KEY=your_openai_api_key_here
RETTIWT_API_KEY=your_rettiwt_api_key_hereThe bot's personality is defined in packages/eliza-agent/characters/rettiwt-bot.json:
- Bio & Lore: Personality and background
- Topics: Focus areas (AI, technology, social issues)
- Style: Communication guidelines
- MCP Servers: Connection configuration
- π§ͺ Dry Run Mode:
DRY_RUN=truelogs all actions without API calls - π Input Validation: 280-character limit enforcement
- β±οΈ Rate Limit Handling: Automatic detection with distinct error messages
- π Process Monitoring: PM2 auto-restart on failures
- π Comprehensive Logging: File-based logging with rotation
search_tweets- Search Twitter with keywordsget_user_profile- Get user profile informationget_user_timeline- Get user's recent tweets
post_tweet- Post new tweets (with replies)like_tweet- Like tweetsretweet- Retweet tweets
# View PM2 process status
pm2 monit
# View logs
pm2 logs eliza-twitter-bot
# Restart services
pm2 restart eliza-twitter-botpnpm deploy# Start all services: PostgreSQL database, ElizaOS agent, and React dashboard
docker compose up
# Access the dashboard
open http://localhost:5175
# Stop all services
docker compose downServices:
- Database: PostgreSQL with pgvector on
localhost:5434 - Agent API: ElizaOS agent on
localhost:5566 - Dashboard: React UI on
localhost:5175
One-click deployment via the included Railway configuration.
-
API Key Errors
# Verify keys are set echo $RETTIWT_API_KEY echo $OPENAI_API_KEY
-
Connection Issues
# Check MCP server is running ps aux | grep tsx
-
Rate Limits
- The system automatically handles rate limits
- Enable dry-run mode for testing:
DRY_RUN=true
DEBUG=* pnpm start --characters="packages/eliza-agent/characters/rettiwt-bot.json"- Development: Use
pnpm devfor simultaneous development - Testing: Enable
DRY_RUN=trueto test without API calls - Deployment: Test with PM2 before production deployment
ISC License
Built with β€οΈ using ElizaOS and MCP Protocol