MCP Server - Twitter NoAuth
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
MCP Server - Twitter NoAuth
A MCP (Model Context Protocol) server that provides Twitter API access without local credential or token setup. Provides core Twitter operations like searching tweets, getting user tweets, posting tweets, and replying to tweets.
Demo Video
https://www.youtube.com/watch?v=LOxFqCTPedc
Why MCP Twitter NoAuth Server?
Critical Advantages
- Headless & Remote Operation: This server can run completely headless in remote environments with no browser and no local file access.
- Decoupled Architecture: Any client can complete the OAuth flow independently, then pass credentials as context to this MCP server, creating a complete separation between credential storage and server implementation.
Nice but not critical
- Focused Functionality: Provides core Twitter operations like searching tweets, getting user tweets, posting tweets, and replying to tweets.
- Docker-Ready: Designed with containerization in mind for a well-isolated, environment-independent, one-click setup.
- Reliable Dependencies: Built on standard Python requests library for Twitter API integration.
Features
- Search tweets using Twitter API
- Get recent tweets by a specific user
- Get recent replies by a specific user
- Post new tweets
- Reply to existing tweets
- Refresh access tokens separately
- Automatic refresh token handling
Prerequisites
- Python 3.10 or higher
- Twitter API credentials (client ID, client secret, access token, and refresh token)
Installation
Docker
Building the Docker Image
Usage with Claude Desktop
Docker Usage
You can configure Claude Desktop to use the Docker image by adding the following to your Claude configuration:
Note: With this configuration, you'll need to provide your Twitter API credentials in the tool calls as shown in the Using the Tools section. Twitter credentials are not passed as environment variables to maintain separation between credential storage and server implementation.
Cross-Platform Publishing
To publish the Docker image for multiple platforms, you can use the docker buildx
command. Follow these steps:
- Create a new builder instance (if you haven't already):Copy
- Build and push the image for multiple platforms:Copy
- Verify the image is available for the specified platforms:Copy
Usage
The server provides Twitter functionality through MCP tools. Authentication handling is simplified with a dedicated token refresh tool.
Starting the Server
Using the Tools
When using an MCP client like Claude, you have two main ways to handle authentication:
Refreshing Tokens (First Step or When Tokens Expire)
If you have both access and refresh tokens:
If your access token has expired, you can refresh with just the refresh token:
This will return a new access token and its expiration time, which you can use for subsequent calls.
Searching Tweets
Search for tweets using the Twitter API:
Response includes tweet data including text, creation time, and author information.
Getting User Tweets
Get recent tweets by a specific user:
Getting User Replies
Get recent replies by a specific user:
Posting a Tweet
Post a new tweet:
Replying to a Tweet
Reply to an existing tweet:
Token Refresh Workflow
- Start by calling the
twitter_refresh_token
tool with either:- Your full credentials (access token, refresh token, client ID, and client secret), or
- Just your refresh token, client ID, and client secret if the access token has expired
- Use the returned new access token for subsequent API calls.
- If you get a response indicating token expiration, call the
twitter_refresh_token
tool again to get a new token.
This approach simplifies most API calls by not requiring client credentials for every operation, while still enabling token refresh when needed.
Obtaining Twitter API Credentials
To obtain the required Twitter API credentials, follow these steps:
- Go to the Twitter Developer Portal
- Create a new project and app
- Set up OAuth 2.0 authentication
- Configure the OAuth settings for your app
- Generate client ID and client secret
- Complete the OAuth flow to obtain access and refresh tokens
Token Refreshing
This server implements automatic token refreshing. When your access token expires, the server will use the refresh token, client ID, and client secret to obtain a new access token without requiring user intervention.
Security Note
This server requires direct access to your Twitter API credentials. Always keep your tokens and credentials secure and never share them with untrusted parties.
License
See the LICENSE file for details.
This server cannot be installed
A headless MCP server that provides Twitter API access without requiring local credential setup, enabling core Twitter operations like searching tweets, getting user tweets, posting tweets, and replying to tweets.