Get the FREE Ultimate OpenClaw Setup Guide →

twitter

A Unofficial Twitter MCP Server with cookie auth.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio gkydev-twitter-mcp-server python server.py

How to use

The Twitter MCP Server exposes a collection of tools built on top of the twikit library to interact with X/Twitter using cookie-based authentication. It supports a wide range of operations including timeline access, user information, tweet posting and management (like, retweet, bookmark), direct messaging, and trending topics. Authentication is performed by providing the ct0 and auth_token cookies with each tool call, enabling session caching and streamlined interactions. The available tools automate common Twitter actions and data retrieval, allowing an AI agent to perform tasks such as reading timelines, posting tweets, fetching user profiles, sending direct messages, and querying trends.

To use the server, run it locally using the Python entry point described in the installation section. Once the server is running, craft JSON payloads with the tool name and the required arguments (including ct0 and auth_token cookies) to invoke the corresponding Twitter actions. Each tool expects arguments defined in the README, for example tweeting, retrieving user info, or getting DM history. The server handles session management and cookies behind the scenes to simplify repeated operations across multiple requests.

How to install

Prerequisites:

  • Python 3.8+ installed on your system
  • Git installed to clone the repository
  • internet access to install dependencies

Installation steps:

  1. Clone the repository:
git clone <repository-url>
cd twitter-mcp
  1. Create and activate a virtual environment (optional but recommended):
python -m venv venv
# macOS/Linux
source venv/bin/activate
# Windows
venv\Scripts\activate.bat
  1. Install dependencies:
pip install -r requirements.txt
  1. Run the server:
python server.py
  1. The server should start and listen for requests. Use the documented tool calls to interact with Twitter via the MCP server.

Additional notes

Notes and tips:

  • Cookie handling: Each tool call must include the ct0 and auth_token cookies provided by the LLM. There is no separate pre-configuration step required.
  • Security: Treat cookies as sensitive data. Do not expose ct0/auth_token in logs or shared prompts.
  • Rate limits: Be mindful of Twitter/X rate limits; the wrapper may expose methods that can be throttled by Twitter if used aggressively.
  • Debugging: If a tool returns an error, ensure cookies are valid and that the target Twitter account has permission for the requested action (e.g., DM or follow actions may be restricted by account settings).
  • Environment: You can customize the server behavior via additional environment variables if the codebase supports them; refer to the codebase documentation for available options.

Related MCP Servers

Sponsor this space

Reach thousands of developers