MCP server exposing twikit's Twitter/X capabilities to AI assistants — no official API key required.
Project description
twikit-x-mcp
An MCP (Model Context Protocol) server that lets an AI assistant — Claude Desktop, Claude Code, Cursor, or any MCP client — read and act on Twitter / X through a single authenticated session. No official X API key required.
Built on twikit
All the real work — the actual Twitter/X client — is twikit by d60. Full credit and rights to the original library belong to its author. This project is only a thin MCP wrapper around it. ⭐ Please star the original repo.
It exposes twikit's capabilities as clean, model-friendly MCP tools.
⚠️ This repo bundles a lightly patched copy of twikit (under
twikit/, MIT — seelicenses/twikit-LICENSE.txt), because the published twikit is currently broken on X (theCouldn't get KEY_BYTE indiceslogin bug). The patch only fixes login. When upstream ships a fix, the bundled copy can be dropped in favour of the PyPItwikitpackage.
Full reference: Documentation · Setup: INSTALL.md · Changelog: CHANGELOG.md · Versioning & releases: docs/RELEASES.md
Features
- 27 tools covering users, tweets (read + write), timelines, trends and DMs.
- No X API key — authenticates as a normal account via cookies or login.
- Built-in rate limiting, on by default, to help avoid suspension (configurable).
- One-line run with
uvx(no manual install), orpip.
| Area | Tools |
|---|---|
| Session | whoami, rate_limit_status |
| Users | get_user, get_user_by_id, search_users, get_user_tweets, get_user_followers, get_user_following, follow_user, unfollow_user, block_user, mute_user |
| Tweets (read) | get_tweet, search_tweets, get_home_timeline, get_retweeters, get_favoriters |
| Tweets (write) | post_tweet, delete_tweet, like_tweet, unlike_tweet, retweet, undo_retweet, bookmark_tweet |
| Trends | get_trends |
| Direct messages | send_direct_message, get_dm_history |
Paginating tools return { "items": [...], "count": N, "next_cursor": "..." };
pass next_cursor back in to page.
Tool annotations
Per the MCP annotations spec — side effects at a glance. Write tools act on your real account.
| Tools | Read-only | Idempotent | Destructive |
|---|---|---|---|
whoami, rate_limit_status, get_user, get_user_by_id, search_users, get_user_tweets, get_user_followers, get_user_following, get_tweet, search_tweets, get_home_timeline, get_retweeters, get_favoriters, get_trends, get_dm_history |
✓ | ✓ | – |
follow_user / unfollow_user, block_user, mute_user, like_tweet / unlike_tweet, retweet / undo_retweet, bookmark_tweet |
– | ✓ | – |
post_tweet, send_direct_message |
– | – | – |
delete_tweet |
– | ✓ | ✓ |
Install
Install and run with uvx:
uvx twikit-x-mcp
Note: the Python import module is
twikit_x_mcp(underscore), per Python convention. The distribution is self-contained — twikit is bundled in, so there are no external Git dependencies to resolve.
Connect your MCP client
Per-client, copy-paste setup for Claude Code, Claude Desktop, Cursor, Windsurf, VS Code and more is in INSTALL.md.
Using a client that isn't documented there? Point its AI at llms-install.md — a machine-readable install spec an agent can follow to wire this server into any MCP client.
Authenticate
X's automated login regularly trips a Cloudflare / "verify you're human"
challenge, so the reliable way to authenticate is to copy two cookies from a
browser where you're already logged in to x.com: auth_token and ct0.
1. Grab the cookies
- Log in to https://x.com in your browser.
- Open DevTools → Application (Chrome/Edge) or Storage (Firefox) →
Cookies →
https://x.com. - Copy the Value of
auth_tokenand ofct0.
2. Set them as environment variables
| Variable | Required | Notes |
|---|---|---|
TWIKIT_AUTH_TOKEN |
✅ | the auth_token cookie value |
TWIKIT_CT0 |
✅ | the ct0 cookie value |
TWIKIT_LANGUAGE |
default en-US |
|
TWIKIT_PROXY |
e.g. http://user:pass@host:port |
🔐 Treat these like a password — they grant access to your account. Don't commit them anywhere. They rotate when you log out of that browser session, so refresh them if requests start failing.
See INSTALL.md for exactly where these go in each client's config.
Rate limiting
To reduce the risk of rate-limit errors or account suspension, the server throttles tool calls by default (token bucket, 30 calls/minute).
| Variable | Default | Notes |
|---|---|---|
TWIKIT_MCP_RATE_LIMIT |
on |
Set to off (or 0/false) to disable throttling entirely |
TWIKIT_MCP_RATE_LIMIT_PER_MINUTE |
30 |
Max tool calls per minute |
Call the rate_limit_status tool to see the active configuration.
Run manually
python -m twikit_x_mcp # or: twikit-x-mcp
You normally won't run it by hand — your MCP client launches it. See INSTALL.md for client setup.
Troubleshooting
| Symptom | Likely cause / fix |
|---|---|
Couldn't get KEY_BYTE indices on login |
The published twikit's login bug — this repo bundles a patched copy under twikit/, so make sure you're running this package, not a separate twikit install. |
Auth errors / 401 / empty whoami |
TWIKIT_AUTH_TOKEN or TWIKIT_CT0 is missing, wrong, or expired. Re-copy both cookies from a logged-in x.com browser session. |
| Frequent rate-limit errors | Throttling is on by default (30/min). Check rate_limit_status; lower TWIKIT_MCP_RATE_LIMIT_PER_MINUTE, or slow down. Aggressive use can get an account suspended. |
| A "verify you're human" / Cloudflare challenge | Use the cookie method (above) rather than username/password login. |
| Server not found by the client | Verify the command/args (uvx/pipx/pip) and that TWIKIT_* env vars are in the client's env block — see INSTALL.md. |
Responsible use
Automating X may violate its Terms of Service and can get accounts rate-limited or suspended. Use a purpose-made account, keep volume low, and respect twikit's rate-limit notes. Don't use this for spam, harassment, or mass automation.
Contributing
Contributions welcome! This project uses Conventional Commits for commits, PR titles and issue titles — see CONTRIBUTING.md.
Security & conduct: SECURITY.md · Code of Conduct
Credits
- twikit by d60 — the underlying X
client that does all the heavy lifting (MIT). A patched copy is bundled here
under
twikit/; its license is preserved atlicenses/twikit-LICENSE.txt. ⭐ Please star the original repo. - This project (
twikit-x-mcp) is MIT-licensed. SeeLICENSE.
Disclaimer
This is an unofficial project. It is not affiliated with, authorized, maintained, sponsored, or endorsed by X Corp. (Twitter).
It authenticates as your own account using session cookies and drives X through twikit — an unofficial client — so a tool can break when X changes its site. Automating X may violate its Terms of Service and can get accounts rate-limited or suspended.
You are responsible for using this software in compliance with X's Terms of Service and applicable law. Use a purpose-made account, keep volume low, and don't use it for spam, harassment, or mass automation. All product names, logos, and brands are property of their respective owners.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file twikit_x_mcp-0.1.0.tar.gz.
File metadata
- Download URL: twikit_x_mcp-0.1.0.tar.gz
- Upload date:
- Size: 86.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cc953de085cc6d82d7a0bc57bbc0f55b55d303a52375d4a4fde927345330e04
|
|
| MD5 |
b21669fd5fec20e198a51d812be41c0f
|
|
| BLAKE2b-256 |
e5b490e75b34e73a0ee6b3afbea6a8d8b0c8446ad0dd91b33f9d58b2c9a07798
|
Provenance
The following attestation bundles were made for twikit_x_mcp-0.1.0.tar.gz:
Publisher:
release.yml on bintangtimurlangit/twikit-x-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
twikit_x_mcp-0.1.0.tar.gz -
Subject digest:
1cc953de085cc6d82d7a0bc57bbc0f55b55d303a52375d4a4fde927345330e04 - Sigstore transparency entry: 2211066115
- Sigstore integration time:
-
Permalink:
bintangtimurlangit/twikit-x-mcp@d6f7f192c08e6443ea13ca2b28d2ab7688eb581a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bintangtimurlangit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d6f7f192c08e6443ea13ca2b28d2ab7688eb581a -
Trigger Event:
push
-
Statement type:
File details
Details for the file twikit_x_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: twikit_x_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 95.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c62f98dc23331b0a4ec7444ab66636fd89c2ae0204df1d707ff2486f66b0ead
|
|
| MD5 |
5eee6595b05a5eebeda22d5bfbd9ffde
|
|
| BLAKE2b-256 |
309ac82b097be2dd629a09cf766ec17d96bb29ecb39ed83d3fe655d37c1a23a8
|
Provenance
The following attestation bundles were made for twikit_x_mcp-0.1.0-py3-none-any.whl:
Publisher:
release.yml on bintangtimurlangit/twikit-x-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
twikit_x_mcp-0.1.0-py3-none-any.whl -
Subject digest:
1c62f98dc23331b0a4ec7444ab66636fd89c2ae0204df1d707ff2486f66b0ead - Sigstore transparency entry: 2211066168
- Sigstore integration time:
-
Permalink:
bintangtimurlangit/twikit-x-mcp@d6f7f192c08e6443ea13ca2b28d2ab7688eb581a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bintangtimurlangit
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d6f7f192c08e6443ea13ca2b28d2ab7688eb581a -
Trigger Event:
push
-
Statement type: