twitter-mcp

twitter-mcp

Enables AI assistants to interact with Twitter/X using session cookies. Supports posting, searching, managing tweets, viewing trends, and user profiles.

Category
Visit Server

README

Twitter MCP Server

MCP (Model Context Protocol) server to interact with Twitter/X directly from any MCP-compatible AI assistant (like opencode). Uses your Twitter session cookies for authentication — no API keys needed.

Features

  • Post, delete, like, and retweet tweets
  • Search tweets by keyword
  • View home timeline, user timeline, and tweet details
  • Get current trending topics
  • Look up user profiles
  • Follow/unfollow users
  • Authenticated user profile info

Quick Start

1. Get your Twitter cookies

  1. Open Twitter/X in your browser (logged in)
  2. Open DevTools (F12) → ApplicationCookieshttps://x.com
  3. Copy the values for auth_token and ct0

2. Configure

cp .env.example .env

Edit .env:

TWITTER_AUTH_TOKEN=seu_auth_token_aqui
TWITTER_CT0=seu_ct0_aqui

3. Install dependencies

pip install -r requirements.txt

4. Run

python server.py

The server will start and listen on stdio, ready for MCP connections.

Register with opencode

Add to ~/.config/opencode/opencode.jsonc:

{
  "mcpServers": {
    "twitter": {
      "command": "python3",
      "args": ["/path/to/twitter-mcp/server.py"],
      "env": {
        "TWITTER_AUTH_TOKEN": "seu_token",
        "TWITTER_CT0": "seu_ct0"
      }
    }
  }
}

Register with Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "twitter": {
      "command": "python3",
      "args": ["/caminho/para/twitter-mcp/server.py"],
      "env": {
        "TWITTER_AUTH_TOKEN": "seu_token",
        "TWITTER_CT0": "seu_ct0"
      }
    }
  }
}

Register with Codex (by Cursor)

Create/edit ~/.codex/config.json:

{
  "mcpServers": {
    "twitter": {
      "command": "python3",
      "args": ["/caminho/para/twitter-mcp/server.py"],
      "env": {
        "TWITTER_AUTH_TOKEN": "seu_token",
        "TWITTER_CT0": "seu_ct0"
      }
    }
  }
}

Tools

Tool Description Arguments
post_tweet Post a tweet text (string, required)
delete_tweet Delete a tweet tweet_id (string, required)
like_tweet Like a tweet tweet_id (string, required)
retweet Retweet a tweet tweet_id (string, required)
search_tweets Search tweets query (string, required), count (int, default 20, max 50)
get_home_timeline Your home timeline count (int, default 20, max 50)
get_user_timeline Tweets from a user user_id (string, required), count (int, default 20)
get_user_by_username User profile info username (string, required, without @)
get_tweet_detail Full tweet details tweet_id (string, required)
get_trends Current trending topics
get_authenticated_user Your own profile
follow_user Follow a user user_id (string, required)

How it works

The server authenticates via auth_token and ct0 session cookies, then makes requests directly to the Twitter/X internal GraphQL API. Query IDs are extracted from the official Twitter web client bundle, so no API keys or OAuth are needed.

Tests

python -m pytest test_twitter.py -v

CI

On every push to main, GitHub Actions runs all tests and automatically creates a tag (v1.YYYYMMDD.HHMM).

Project structure

├── server.py           # MCP server entry point (12 tools via FastMCP)
├── twitter_client.py   # HTTP client for Twitter GraphQL API
├── auth.py             # Authentication via session cookies
├── test_twitter.py     # Tests (16 tests, mocked API)
├── requirements.txt    # Python dependencies
├── .env.example        # Cookie config template
├── .github/workflows/  # CI pipeline
└── README.md

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured