X (Twitter) MCP Server
Supports environment variable configuration through .env files
Enables cloning the Twitter MCP repository from GitHub
Supported platform for running the Claude MCP configuration
Supported platform for running the Claude MCP configuration
Provides the runtime environment required for the MCP server (version 18.x or higher)
Used for package management and running the server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
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
Clone this repository:
git clone https://github.com/Dishant27/twitter-mcp.gitInstall dependencies and build:
npm install && npm run buildSet your API keys, either as environment variables or in a
.envfile (copy.env.exampleto.envand fill in your values;.envis git-ignored, so never commit it)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 startUsing a
.envfile:
cp .env.example .env
# edit .env with your own keys, then:
npm startUse with a MCP client, such as Claude.
Related MCP server: Twitter MCP Server
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-serversmacOS:
~/Library/Application Support/AnthropicClaude/mcp-serversLinux:
~/.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 new content to X |
| Search for content on X |
| Get profile information for a user or the authenticated account |
| Update the authenticated user's profile |
| Follow a user |
| Unfollow a user |
| List followers of a user or the authenticated account |
| List accounts that a user or the authenticated account is following |
| Create a new list |
| Get information about a list |
| 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
Built on @modelcontextprotocol/sdk 1.x (the McpServer / registerTool API with zod input schemas). It runs over stdio, so stdout is reserved for the MCP protocol and all logs go to stderr.
Environment Variables
Variable | Description |
| Your API key |
| Your API secret |
| Your access token |
| Your access token secret |
All four are required; the server exits at startup if any is missing. See .env.example.
Development
npm run build # compile TypeScript to dist/
npm run smoke # start the built server with placeholder keys and check it lists its 11 tools (no X API calls)CI (.github/workflows/ci.yml) runs npm ci, a type check, the build and the smoke test on pushes and pull requests to master.
Repository Structure
twitter-mcp/
├── .github/
│ └── workflows/
│ └── ci.yml # Build + smoke test
├── 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 (MCP server and tools)
│ ├── twitter-api.ts # X API client
│ ├── formatter.ts # Response formatter
│ └── types.ts # Type definitions
├── test/
│ └── smoke.mjs # Stdio smoke test
├── .env.example
├── .gitignore
├── LICENSE
├── package.json
├── package-lock.json
├── README.md
└── tsconfig.jsonLicense
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Publish and schedule tweets and threads on X (Twitter) from your AI assistant.
Search X (Twitter) posts and read profiles, followers, trends and X Articles. OAuth sign-in.
X/Twitter search, posts, comments, user profiles, user posts/replies and video transcripts.
X (formerly Twitter): X (formerly Twitter) public and private data API for search, posts (Tweets).
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables users to interact with X (Twitter) through the X API. Supports posting tweets, retrieving user timelines, searching tweets, and replying to tweets with comprehensive error handling.36 npmMIT
- FlicenseNot gradedqualityDmaintenanceEnables LLM agents to interact with Twitter (X) for searching tweets, posting content with images, analyzing engagement, and extracting topics using the Twitter API.-
- AlicenseNot gradedqualityDmaintenanceEnables interaction with X (Twitter) to post tweets, threads, and replies while retrieving tweet metrics and account information. It supports core management tasks like deleting tweets and verifying authentication through the Twitter API.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to interact with X (Twitter) API v2 for posting tweets, searching, liking, retweeting, and more through natural language.46 PyPIMIT
Appeared in Searches
- A search for the social media handle '@@x7ton'
- Search for posts related to X
- A search for strategies to promote a directory website and generate ideas for solopreneur SAAS businesses
- Managing Social Media Content Creation Using Monday
- A guide to researching LinkedIn profiles and personalizing outreach based on customer persona and company signals