agent-twitter-client-mcp
About
A Model Context Protocol (MCP) server that integrates with X using the @elizaOS `agent-twitter-client` package, allowing AI models to interact with Twitter without direct API access.
Details
- License
- MIT
Explore
- Authentication Options:
- Cookie-based authentication (recommended)
- Username/password authentication
- Twitter API v2 credentials
- Tweet Operations:
- Fetch tweets from users
- Get specific tweets by ID
- Search tweets
- Send tweets with text and media
- Create polls
- Like, retweet, and quote tweets
- User Operations:
- Get user profiles
- Follow users
- Get followers and following lists
- Grok Integration:
- Chat with Grok via Twitter's interface
- Continue conversations with conversation IDs
- Get web search results and citations
- Access Twitter's real-time data through Grok
- Note: Grok functionality requires agent-twitter-client v0.0.19 or higher
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
agent-twitter-client-mcpCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
npm install -g agent-twitter-client-mcp
npm install agent-twitter-client-mcp
1. Create a .env file with your Twitter credentials (see Authentication Methods)
2. Run the MCP server:
agent-twitter-client-mcp
npx agent-twitter-client-mcp
By default, the MCP server runs on port 3000. If you need to change this (for example, if you already have an application running on port 3000), you have several options:
Set the PORT environment variable:
PORT=3001 npx agent-twitter-client-mcp
1. Configure Claude Desktop to use this MCP by adding to your config file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"agent-twitter-client-mcp": {
"command": "npx",
"args": ["-y", "agent-twitter-client-mcp"],
"env": {
"AUTH_METHOD": "cookies",
"TWITTER_COOKIES": "[\"auth_token=YOUR_AUTH_TOKEN; Domain=.twitter.com\", \"ct0=YOUR_CT0_VALUE; Domain=.twitter.com\", \"twid=u%3DYOUR_USER_ID; Domain=.twitter.com\"]"
}
}
}
}
2. Restart Claude Desktop
{
"AUTH_METHOD": "cookies",
"TWITTER_COOKIES": "[\"auth_token=YOUR_AUTH_TOKEN; Domain=.twitter.com\", \"ct0=YOUR_CT0_VALUE; Domain=.twitter.com\", \"twid=u%3DYOUR_USER_ID; Domain=.twitter.com\"]"
}
To obtain cookies:
1. Log in to Twitter in your browser
2. Open Developer Tools (F12)
3. Go to the Application tab > Cookies
4. Copy the values of auth_token, ct0, and twid cookies
5. Make sure to include the Domain=.twitter.com part for each cookie
{
"AUTH_METHOD": "credentials",
"TWITTER_USERNAME": "your_username",
"TWITTER_PASSWORD": "your_password",
"TWITTER_EMAIL": "[email protected]", // Optional
"TWITTER_2FA_SECRET": "your_2fa_secret" // Optional, required if 2FA is enabled
}
{
"AUTH_METHOD": "api",
"TWITTER_API_KEY": "your_api_key",
"TWITTER_API_SECRET_KEY": "your_api_secret_key",
"TWITTER_ACCESS_TOKEN": "your_access_token",
"TWITTER_ACCESS_TOKEN_SECRET": "your_access_token_secret"
}
npm run test:interface
This launches a REPL where you can test various MCP functions:
agent-twitter-client-mcp> help
Available commands:
health Run a health check
profile <username> Get a user profile
tweets <username> [count] Get tweets from a user
tweet <id> Get a specific tweet by ID
search <query> [count] Search for tweets
post <text> Post a new tweet
like <id> Like a tweet
retweet <id> Retweet a tweet
quote <id> <text> Quote a tweet
follow <username> Follow a user
followers <userId> [count] Get a user's followers
following <userId> [count] Get users a user is following
grok <message> Chat with Grok
help Show available commands
exit Exit the test interface
Ask Claude to:
- "Search Twitter for tweets about AI"
- "Post a tweet saying 'Hello from Claude!'"
- "Get the latest tweets from @OpenAI"
- "Chat with Grok about quantum computing"
Grok functionality requires proper authentication. The MCP supports two methods:
1. Cookie Authentication (Recommended):
- Cookies must be in JSON array format
- Example: TWITTER_COOKIES=["auth_token=YOUR_AUTH_TOKEN; Domain=.twitter.com", "ct0=YOUR_CT0_VALUE; Domain=.twitter.com", "twid=u%3DYOUR_USER_ID; Domain=.twitter.com"]
- Essential cookies are auth_token, ct0, and twid
2. Username/Password Authentication:
- Set TWITTER_USERNAME and TWITTER_PASSWORD in your environment
- May encounter Cloudflare protection in some cases
If you're experiencing issues with cookie authentication:
1. Cookie Expiration: Twitter cookies typically expire after a certain period. Try refreshing your cookies by logging out and back into Twitter.
2. Cookie Format: Ensure your cookies are properly formatted as a JSON array of strings with the correct domain.
3. Required Cookies: Make sure you've included the essential cookies: auth_token, ct0, and twid.
Example of properly formatted cookies:
json"TWITTER_COOKIES": "[\"auth_token=1234567890abcdef; Domain=.twitter.com\", \"ct0=abcdef1234567890; Domain=.twitter.com\", \"twid=u%3D1234567890; Domain=.twitter.com\"]"
If you're having trouble with username/password authentication:
1. Two-Factor Authentication: If your account has 2FA enabled, you'll need to provide the TWITTER_2FA_SECRET.
2. Account Lockouts: Too many failed login attempts may lock your account. Check your email for account verification requests.
3. Captcha Challenges: Twitter may present captcha challenges that the client can't handle automatically.
For API authentication issues:
1. API Key Permissions: Ensure your API keys have the necessary permissions for the actions you're trying to perform.
2. Rate Limiting: Twitter API has rate limits that may cause failures if exceeded.
3. API Changes: Twitter occasionally changes its API, which may cause compatibility issues.
In addition to the authentication variables, you can set:
- LOG_LEVEL: Set logging level (error, warn, info, debug)
- NODE_ENV: Set environment (development, production)
docker run -p 3000:3000 \
-e AUTH_METHOD=cookies \
-e TWITTER_COOKIES='["auth_token=YOUR_AUTH_TOKEN; Domain=.twitter.com", "ct0=YOUR_CT0_VALUE; Domain=.twitter.com"]' \
agent-twitter-client-mcp
You can pass environment variables to the Docker container in several ways:
1. In the docker-compose.yml file (already configured)
2. Through a .env file (recommended for docker-compose)
3. Directly in the docker run command (as shown above)
get_user_tweets
Fetch tweets from a specific user
get_tweet_by_id
Fetch a specific tweet by ID
search_tweets
Search for tweets
send_tweet
Post a new tweet
send_tweet_with_poll
Post a tweet with a poll
like_tweet
Like a tweet
retweet
Retweet a tweet
quote_tweet
Quote a tweet
get_user_profile
Get a user's profile
follow_user
Follow a user
get_followers
Get a user's followers
get_following
Get users a user is following
grok_chat
Chat with Grok via Twitter
health_check
Check the health of the Twitter MCP server
- get_user_tweets: Fetch tweets from a specific user
- get_tweet_by_id: Fetch a specific tweet by ID
- search_tweets: Search for tweets
- send_tweet: Post a new tweet
- send_tweet_with_poll: Post a tweet with a poll
- like_tweet: Like a tweet
- retweet: Retweet a tweet
- quote_tweet: Quote a tweet
- get_user_profile: Get a user's profile
- follow_user: Follow a user
- get_followers: Get a user's followers
- get_following: Get users a user is following
- grok_chat: Chat with Grok via Twitter
- health_check: Check the health of the Twitter MCP server
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"agent-twitter-client-mcp": {
"agent-twitter-client-mcp": {
"command": "npx",
"args": [
"agent-twitter-client-mcp"
]
}
}
}
}
McpServers
{
"agent-twitter-client-mcp": {
"command": "npx",
"args": [
"agent-twitter-client-mcp"
]
}
}
A Model Context Protocol (MCP) server that integrates with Twitter using the agent-twitter-client package, allowing AI models to interact with Twitter without direct API access.
Features
- Authentication Options:
- Cookie-based authentication (recommended)
- Username/password authentication
- Twitter API v2 credentials
- Tweet Operations:
- Fetch tweets from users
- Get specific tweets by ID
- Search tweets
- Send tweets with text and media
- Create polls
- Like, retweet, and quote tweets
- User Operations:
- Get user profiles
- Follow users
- Get followers and following lists
- Grok Integration:
- Chat with Grok via Twitter's interface
- Continue conversations with conversation IDs
- Get web search results and citations
- Access Twitter's real-time data through Grok
- Note: Grok functionality requires agent-twitter-client v0.0.19 or higher
Documentation
- Developer Guide - Comprehensive guide for developers
- Testing Guide - Instructions for testing the MCP
- Agent Guide - Guide for AI agents on how to use the Twitter MCP
- Contributing Guide - Guidelines for contributing to this project
- Changelog - History of changes to this project
- Demo README - Guide for running the demo scripts
- Grok Examples - Documentation for the Grok AI integration examples
Quick Start
Installation
```bash
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



