A powerful AI agent that can interact with X (formerly Twitter) and perform various tasks using the Model Context Protocol (MCP). This project demonstrates the integration of AI capabilities with social media platforms.
- 🤖 AI-powered interactions using Gemini AI
- 🐦 X (Twitter) integration for posting content
- 😄 Dark humor joke generator
- 🔄 Real-time communication using Server-Sent Events (SSE)
- 🛠️ Extensible tool system for adding new capabilities
- Node.js (v16 or higher)
- npm or yarn
- Twitter Developer Account with API access
- Google Gemini API key
X_AI_Agent_MCP/
├── client/ # Client-side code
│ ├── index.js # Main client application
│ └── package.json # Client dependencies
├── server/ # Server-side code
│ ├── index.js # Main server application
│ ├── mcp.tool.js # Twitter integration tools
│ └── package.json # Server dependencies
└── .env # Environment variables
-
Clone the repository:
git clone <repository-url> cd X_AI_Agent_MCP
-
Install dependencies for both client and server:
# Install server dependencies cd server npm install # Install client dependencies cd ../client npm install
-
Configure environment variables:
- Copy
.env.sampleto.envin both client and server directories - Fill in your API keys and tokens:
# Server .env TWITTER_API_KEY=your_twitter_api_key TWITTER_API_SECRET=your_twitter_api_secret TWITTER_ACCESS_TOKEN=your_twitter_access_token TWITTER_ACCESS_TOKEN_SECRET=your_twitter_access_token_secret # Client .env GEMINI_API_KEY=your_gemini_api_key
- Copy
-
Start the server:
cd server npx nodemon -
Start the client:
cd client node index.js -
The application will connect to the MCP server and you can start interacting with the AI agent.
createPost: Create a new post on X (Twitter)- Parameters:
status: The content of the tweet (max 280 characters)
- Parameters:
darkHumorJoke: Generate a random dark humor joke- Parameters:
theme: (Optional) Theme for the joke
- Parameters:
The application includes comprehensive error handling for:
- Twitter API authentication issues
- Rate limiting
- Invalid tweet content
- Connection issues
- API key validation
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.