X (Twitter) MCP Server
Enables interaction with X (formerly Twitter), allowing for posting tweets, searching content, managing accounts, and organizing lists.
README
<img src="https://www.x.com/favicon.ico" alt="X Logo" width="32" height="32"> X (Twitter) MCP Server
This MCP server allows Clients to interact with X (formerly Twitter), enabling comprehensive platform operations including posting tweets, searching content, managing accounts, and organizing lists.
Quick Start
- Create an X Developer account and get your API keys from X Developer Portal
- Set all required API keys in the environment variables
- Clone this repository:
git clone https://github.com/Dishant27/twitter-mcp.git - Install dependencies:
npm install - Run the server:
- With environment variables:
TWITTER_API_KEY=your_api_key \
TWITTER_API_SECRET=your_api_secret \
TWITTER_ACCESS_TOKEN=your_access_token \
TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret \
npm start
- Using a
.envfile:
# Create a .env file with your X API keys
echo "TWITTER_API_KEY=your_api_key
TWITTER_API_SECRET=your_api_secret
TWITTER_ACCESS_TOKEN=your_access_token
TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret" > .env
# Start the server
npm start
- Use with a MCP client, such as Claude.
Claude Configuration
To use this server with Claude, you'll need to set up the MCP configuration. Here's an example of how the configuration structure should look:
{
"name": "x",
"display_name": "X",
"description": "X MCP allows Claude to interact with X (formerly Twitter)",
"path": "path/to/twitter-mcp/dist/index.js",
"startup": {
"env": {
"TWITTER_API_KEY": "your_api_key",
"TWITTER_API_SECRET": "your_api_secret",
"TWITTER_ACCESS_TOKEN": "your_access_token",
"TWITTER_ACCESS_TOKEN_SECRET": "your_access_token_secret"
}
},
"transport": "stdio"
}
Save this configuration in your Claude MCP config directory, typically located at:
- Windows:
%APPDATA%\AnthropicClaude\mcp-servers - macOS:
~/Library/Application Support/AnthropicClaude/mcp-servers - Linux:
~/.config/AnthropicClaude/mcp-servers
Features
Post Operations
- Post content (up to 280 characters)
- Search for posts by query with customizable result count
Account Management
- Get profile information for any user or the authenticated account
- Update profile details (name, bio, location, website URL)
- Follow and unfollow users
- List followers for any user or the authenticated account
- List accounts that a user is following
List Management
- Create new lists (public or private)
- Get information about specific lists
- Retrieve all lists owned by the authenticated user
Available MCP Tools
| Tool Name | Description |
|---|---|
post_tweet |
Post new content to X |
search_tweets |
Search for content on X |
get_profile |
Get profile information for a user or the authenticated account |
update_profile |
Update the authenticated user's profile |
follow_user |
Follow a user |
unfollow_user |
Unfollow a user |
list_followers |
List followers of a user or the authenticated account |
list_following |
List accounts that a user or the authenticated account is following |
create_list |
Create a new list |
get_list_info |
Get information about a list |
get_user_lists |
Get all lists owned by the authenticated user |
Requirements
- Node.js 18.x or higher
- X Developer account with API keys
- API v1 and v2 access
Environment Variables
| Variable | Description |
|---|---|
TWITTER_API_KEY |
Your API key |
TWITTER_API_SECRET |
Your API secret |
TWITTER_ACCESS_TOKEN |
Your access token |
TWITTER_ACCESS_TOKEN_SECRET |
Your access token secret |
Repository Structure
twitter-mcp/
├── .github/
│ └── workflows/
│ ├── publish.yml
│ └── release.yml
├── code/
│ ├── account_management.py # Sample Python code for account management
│ ├── post_tweet.py # Sample Python code for posting content
│ └── retrieve_tweets.py # Sample Python code for retrieving content
├── src/
│ ├── index.ts # Main entry point
│ ├── twitter-api.ts # X API client
│ ├── formatter.ts # Response formatter
│ └── types.ts # Type definitions
├── .env.example
├── .gitignore
├── Dockerfile
├── LICENSE
├── package.json
├── README.md
└── tsconfig.json
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.