
Tweetkit X
io.github.nsozturk由 GitHub 账号 nsozturk 发布v0.3.0更新于 Oct 25, 2026
Post, delete & read on X (Twitter) using your own logged-in web session — no paid API.
概览
本地 MCP 服务器,让助手使用你自己已登录的浏览器会话 Cookie 在 X(Twitter)上发帖、删除、读取和搜索,而无需付费 API。
- 可以做什么
- 认证:粘贴 Cookie 请求头,或导入 HAR、storage-dump 压缩包、Cookie JSON 文件,并用 auth_status、set_session_cookie、import_cookie_from_file 检查与设置会话,工具会说明要复制什么且不回显 Cookie。发布内容:发推文(可带图片、回复)、发串推、引用推文、长文笔记,以及定时发布和取消定时。删除内容:删除单条或一批推文,并按子串或正则查找自己的推文用于清理。互动:点赞、转推、收藏、置顶、关注、屏蔽、静音,每项都有对应的撤销操作。读取信息:首页时间线、回复、通知、书签、个人资料、关注者、正在关注、点赞者、转推者,以及搜索整个 X 并支持搜索运算符。
- 适用场景
- 适合希望助手在不付费使用官方 API、也不注册开发者应用的情况下,发布、清理或浏览自己 X 账号的场景,例如定时发帖、起草串推,或按关键词查找并删除旧推文。
- 运行要求
- 作为本地进程运行,从 PyPI 安装 tweetkit-x 并带 mcp 附加组件(Python),通常通过 uvx 或 tweetkit-mcp 命令启动。需要包含 auth_token 和 ct0 的已登录 X 会话 Cookie,可通过 TWEETKIT_COOKIE、TWEETKIT_COOKIE_FILE、Cookie 文件或 macOS 钥匙串(TWEETKIT_COOKIE_KEYCHAIN)提供。需要访问 x.com 的网络连接。
安装
在 SourceWeft 中
- 打开 控制台中的 Tweetkit X,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
[tweetkit-x — post, delete and read on X (Twitter) from Python & MCP using your own web session]
tweetkit-x
Post, delete & read on X (Twitter) — from Python and as an MCP server — using your own logged-in browser session.
No paid API. No developer app. No OAuth dance. Just your session cookie.
[PyPI] [Python] [License] [MCP] [X API] [Runs with]
Quick start · Get your cookie · Python · CLI · MCP server · How it works · Disclaimer
Why
Since February 6, 2026, X's official API has no free tier for new developers — it's pay-per-use: ~$0.015 per post, ~$0.20 per post with a link, plus per-read charges. For publishing your own tweets (a bot posting your content, a scheduled thread, a cleanup script that deletes old posts), that's a recurring bill for something your browser already does for free.
tweetkit-x skips the API entirely. It replays the exact internal HTTP calls your browser makes when you click Post, Delete, or scroll your profile — authenticated with the session cookie you already have. Post, delete, and read the full timeline, at zero API cost.
⚠️ Automating your web session is against X's Terms of Service. This is a grey-area tool for personal automation. Account risk is entirely yours. See the Disclaimer.
Features
- ✅ Post — text, up to 4 images, GIF & video (with alt text), replies, threads, quote-tweets, long-form note tweets, and scheduled tweets
- 🗑️ Delete — one id, a list of ids, or "find matching & delete" cleanup loops
- ❤️ Engage — like, retweet, bookmark, follow, block, mute, pin — each with an undo
- 🌐 Search all of X — the real
SearchTimeline(operators likefrom:,min_faves:,filter:media), plus local regex over your own tweets - 📖 Read — your home feed, any timeline, a tweet's replies/conversation, followers/following, likers/retweeters, bookmarks, a user's likes, notifications, and full profiles
- 🔌 MCP server — 40 tools; drop into Claude Desktop / Claude Code / Cursor; tools that explain the cookie and set it up with one paste
- 🔑 Frictionless auth — paste a
Cookie:header, drop a HAR file, or a storage-dump zip; store in a file or the macOS Keychain - 🐍 Python API and a CLI (
tweetkit …) - 🪶 Tiny footprint — no headless browser, no Selenium
Quick start
Getting your session cookie
The only secret tweetkit needs is your X session cookie — the same Cookie: header your logged-in browser sends. It must contain at least two values:
❗
auth_tokenis HttpOnly, so adocument.cookiecopy in the JS console will NOT include it. Use one of the reliable methods below.
Method A — copy the Cookie: header (most reliable, one paste)
- Open x.com while logged in.
- Open DevTools (F12) → the Network tab.
- Click any request to
x.com(e.g.HomeTimeline). - Under Request Headers, find
cookie:and copy the entire value. - Feed it in:
Method B — an F12 "Preserve log" HAR file
- Open x.com logged in → DevTools (F12) → Network.
- Tick "Preserve log", then reload / click around so requests are captured.
- Right-click any request → "Save all as HAR" (or use the ⬇ export icon).
- Import it:
Modern Chrome can redact cookies from exported HARs. If tweetkit reports
auth_tokenmissing, either enable "Allow to generate HAR with sensitive data" in the Network settings, or fall back to Method A / Method C.
Method C — the storagedump browser extension (zip)
The easiest no-DevTools route. storagedump (a Chrome extension built by this project's author) exports a tab's browser storage — including the HttpOnly auth_token, which document.cookie can't reach — as a .zip containing cookies.json. On x.com (logged in), click the extension → export, then:
tweetkit reads the extension's native format, { "data": [ { "key": "...", "value": "..." }, ... ] }, and also accepts a plain list or a {name: value} map. Cookie-Editor / EditThisCookie JSON exports (--file export.json) work too.
Install: storagedump on the Chrome Web Store.
Where the cookie is stored
By default tweetkit import writes ~/.config/tweetkit/cookie.txt (chmod 600; also git-ignored). Prefer the macOS Keychain? Add --keychain <slug>:
Resolution order at runtime (first hit wins): explicit arg → TWEETKIT_COOKIE → TWEETKIT_COOKIE_FILE → ./cookie.txt → ~/.config/tweetkit/cookie.txt → Keychain (TWEETKIT_COOKIE_KEYCHAIN).
Python usage
Every write returns {'ok': True, 'id': '...', 'url': '...'} on success, or {'ok': False, 'status': ..., 'error': '...'} on failure — easy to log or retry.
See examples/ for a full "find my $XMR tweets and delete them" cleanup loop.
CLI usage
A thread.txt is just tweets separated by blank lines.
MCP server
tweetkit ships a first-class MCP server so an AI client can post/delete/read for you — and it walks the user through auth, explaining what the cookie is and setting it up with a single paste.
Configure your client
Claude Desktop / Claude Code / Cursor — add to your MCP config (claude_desktop_config.json, .mcp.json, …):
Already pip installed? Use the console script directly:
If you don't set any cookie env var, that's fine — the server starts unauthenticated and asks the user to set the cookie from inside the chat (below).
Frictionless auth, from inside the chat
The server describes each value and offers the lowest-effort path. A typical first run:
- The client calls
auth_status→ not authenticated. - The server’s instructions tell the assistant to ask you for your cookie and explain what
auth_tokenandct0are and how to copy them. - You paste the
Cookie:header once →set_session_cookie("<paste>")→ stored (Keychain or file) and activated. Or pointimport_cookie_from_file("~/Downloads/x.com.har")at a HAR / storage-dump zip.
The raw cookie is never echoed back.
Tools
Not (yet) supported: DMs, polls (create/vote), Lists, profile editing, Spaces, hide-reply. These need a captured HAR of that exact action to pin down the endpoint — easy to add on request.
How it works
When you act in the browser, x.com calls a handful of internal endpoints. tweetkit reproduces them 1:1:
x-client-transaction-id— X requires an anti-bot header derived from the page'sondemand.sJS and a home fetch. Generated with the standalonex-client-transaction-idpackage.- Media upload (images) —
POST upload.x.com/i/media/upload.jsonasINIT→APPEND→FINALIZE, yielding amedia_id. - Write / delete —
POST /i/api/graphql/<queryId>/CreateTweetand.../DeleteTweet. - Read —
GET /i/api/graphql/<queryId>/UserTweets(paginated by cursor), plusUserByScreenNameto resolve@handles.
Auth is just your cookie + the public web bearer token (the same non-secret bearer embedded in x.com for every visitor) + the ct0 CSRF value echoed as x-csrf-token.
The GraphQL query IDs live in
tweetkit_x/constants.py. X rotates them every few weeks; if a call starts failing, refresh them from a fresh HAR (the file has step-by-step notes).
Security
- The cookie is the only secret. It's stored chmod 600 in
~/.config/tweetkit/cookie.txtor the macOS Keychain, and.gitignoreblockscookie.txt,.env,*.har, and*.zip. - tweetkit never prints the cookie value — importers report only which cookies were found and their lengths.
- The bundled bearer is X's public web bearer, identical for every visitor — not a secret.
Disclaimer
This project automates your own X web session for personal use. Automating the web session is against X's Terms of Service, and using it may put your account at risk of rate-limiting, suspension, or ban. You are solely responsible for how you use it. Provided as-is, without warranty. Not affiliated with X Corp.
License
MIT © 2026 ns0bj
来源:README.md,提交 f7e7076
工具
0版本历史
1- v0.3.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分