π¦
X AI Agent
MCP server: X AI Agent
0 installs
7 stars
Trust: 37 β Low
Devtools
Installation
npx x-ai-agentAsk AI about X AI Agent
Powered by Claude Β· Grounded in docs
I know everything about X AI Agent. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Loading tools...
Reviews
Documentation
AI Agent for X ( ex-Twitter )
A server application that integrates with Google's Generative AI and provides MCP (Model Context Protocol) functionality. Built with Node.js and Express.
Features
- π€ Integration with Google's Generative AI
- β‘ Fast and efficient message handling
- π Environment variable configuration for API keys
- π MCP (Model Context Protocol) server implementation
- π οΈ Custom tools for number addition and Twitter post creation
Prerequisites
- Node.js (v14 or higher)
- npm or yarn
- Google AI API key
Project Structure
βββ server/ # Node.js backend server
β βββ index.js # Express server setup
β βββ mcp.tool.js # MCP tool implementations
β βββ .env # Server environment variables
β βββ package.json # Backend dependencies
β
βββ client/ # Node.js client application
β βββ index.js # Client application entry point
β βββ .env # Client environment variables
β βββ package.json # Client dependencies
β
βββ node_modules/ # Project dependencies
βββ package.json # Root package.json
βββ package-lock.json # Dependency lock file
Setup Instructions
- Clone the repository:
git clone <repository-url>
cd <project-directory>
- Install dependencies:
npm install
- Create
.envfiles:
In the server directory (server/.env):
GEMINI_API_KEY=your_gemini_api_key_here
In the client directory (client/.env):
TWITTER_API_KEY=your_twitter_api_key_here
TWITTER_API_SECRET=your_twitter_api_secret_here
TWITTER_ACCESS_TOKEN=your_twitter_access_token_here
TWITTER_ACCESS_TOKEN_SECRET=your_twitter_access_token_secret_here
- Start the server:
cd server
node index.js
- In a new terminal, start the client:
cd client
node index.js
The server will be running at http://localhost:3001
Environment Variables
Server Environment Variables
Create a .env file in the server directory with:
GEMINI_API_KEY: Your Gemini API key
Client Environment Variables
Create a .env file in the client directory with:
TWITTER_API_KEY: Your Twitter API keyTWITTER_API_SECRET: Your Twitter API secret keyTWITTER_ACCESS_TOKEN: Your Twitter access tokenTWITTER_ACCESS_TOKEN_SECRET: Your Twitter access token secret
To get these Twitter API credentials:
- Go to the Twitter Developer Portal
- Create a new project and app
- Navigate to your app's settings
- Generate your API keys and tokens
- Make sure to enable the necessary permissions for your app
Technologies Used
- Backend:
- Node.js
- Express
- dotenv for environment variables
- @google/generative-ai for AI integration
- @modelcontextprotocol/sdk for MCP implementation
- Zod for schema validation
API Endpoints
GET /sse: Establishes an SSE connection for real-time communicationPOST /messages: Handles incoming messages with session management
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Acknowledgments
- Google Generative AI for providing the AI capabilities
- Model Context Protocol team for the MCP implementation
