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.

概覽

AI 產生的概覽

本機 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 的網路存取。
安裝前請注意
工作階段 Cookie 等同完整登入憑證,持有者即可代表你的帳號操作,應避免寫入日誌或程式碼儲存庫。說明中明確指出自動化網頁工作階段違反 X 的服務條款,可能導致限流、停權或帳號被封鎖。許多工具會在你的帳號上寫入、傳送或刪除資料,包括發文、刪推文、追蹤、封鎖與靜音,部分操作不易復原。X 會輪換內部查詢 ID,呼叫可能因此失效,需要更新後才能恢復。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Tweetkit X,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

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 like from:, 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

bash
pip install "tweetkit-x[mcp]"      # or: pip install tweetkit-x   (library + CLI only)
# 1. Import your session cookie (three ways — see the next section)tweetkit import --paste                       # paste the Cookie: header, Ctrl-D#   or:  tweetkit import --file x.com.har#   or:  tweetkit import --file storagedump_x.com.zip --keychain tweetkit
# 2. Verify (no network call)tweetkit whoami# {"ready": true, "user_id": "1986...", "ct0_len": 160}
# 3. Use ittweetkit post "hello world 👋"tweetkit search "xmr|monero" --regex          # your tweets that matchtweetkit delete 2063240404980445603

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:

CookieWhat it isRequiredHttpOnly?
auth_tokenyour login/session tokenyesyes (hidden from document.cookie)
ct0CSRF token (sent back as x-csrf-token)yesno
twidyour user id (u=<id>) — lets tweetkit read your timeline with no extra lookuprecommendedno
guest_id, kdt, att, personalization_idmisc session stateoptionalmixed

❗ auth_token is HttpOnly, so a document.cookie copy 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)

  1. Open x.com while logged in.
  2. Open DevTools (F12) → the Network tab.
  3. Click any request to x.com (e.g. HomeTimeline).
  4. Under Request Headers, find cookie: and copy the entire value.
  5. Feed it in:
bash
tweetkit import --paste# paste the cookie header, then press Ctrl-D

Method B — an F12 "Preserve log" HAR file

  1. Open x.com logged in → DevTools (F12) → Network.
  2. Tick "Preserve log", then reload / click around so requests are captured.
  3. Right-click any request → "Save all as HAR" (or use the ⬇ export icon).
  4. Import it:
bash
tweetkit import --file ~/Downloads/x.com.har

Modern Chrome can redact cookies from exported HARs. If tweetkit reports auth_token missing, 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:

bash
tweetkit import --file storagedump_x.com_2026-07-05.zip

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>:

bash
tweetkit import --paste --keychain tweetkitexport TWEETKIT_COOKIE_KEYCHAIN=tweetkit

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

python
from tweetkit_x import TweetKit
tk = TweetKit(keychain_slug="tweetkit")          # or cookie="auth_token=...; ct0=..."
tk.whoami()                                       # {'ready': True, 'user_id': '...', 'ct0_len': 160}
# posttk.post("hello world")tk.post("with a picture", image_path="chart.png")tk.post("a reply", reply_to="1800000000000000000")
# thread — strings or (text, image_path) tuples; each replies to the previoustk.post_thread(["1/ intro", ("2/ chart", "chart.png"), "3/ outro"])
# readmine = tk.get_tweets(limit=100)                   # your tweets, newest firsttheirs = tk.get_tweets(username="jack", limit=50) # anyone's
# search (local filter over the timeline — no paid search API)hits = tk.search("monero")                        # substringhits = tk.search(r"xmr|monero", regex=True)       # regex
# deletetk.delete("1800000000000000000")tk.delete_many([t["id"] for t in hits])
# quote-tweettk.quote("this is great", quote_tweet_id="1800000000000000000")
# engage (each has an undo)tk.like("1800000000000000000");     tk.unlike("1800000000000000000")tk.retweet("1800000000000000000");  tk.unretweet("1800000000000000000")tk.bookmark("1800000000000000000"); tk.unbookmark("1800000000000000000")
# read a single tweet, and search ALL of X (real search + operators)tk.get_tweet("1800000000000000000")tk.search_x("mcp server", latest=True, limit=40)tk.search_x("from:jack min_faves:1000")     # X search operators work

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

bash
tweetkit whoamitweetkit post "just some text"tweetkit post "text + media" --image pic.pngtweetkit post "a reply" --reply-to 1800000000000000000tweetkit thread thread.txt                 # tweets separated by blank linestweetkit delete 1800000000000000000 1800000000000000001tweetkit tweets --limit 100                # your tweetstweetkit tweets @jack --limit 50           # someone else'stweetkit search monero                     # your tweets containing "monero"tweetkit search "xmr|monero" --regextweetkit searchx "mcp server" --latest     # search ALL of X (real search + operators)tweetkit get 1800000000000000000           # one tweet by idtweetkit quote "great thread" 1800000000000000000tweetkit like 1800000000000000000          # also: unlike / retweet / unretweet / bookmark / unbookmark

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, …):

jsonc
{  "mcpServers": {    "tweetkit": {      "command": "uvx",      "args": ["--from", "tweetkit-x[mcp]", "tweetkit-mcp"],      "env": { "TWEETKIT_COOKIE_KEYCHAIN": "tweetkit" }    }  }}

Already pip installed? Use the console script directly:

jsonc
{ "mcpServers": { "tweetkit": { "command": "tweetkit-mcp",  "env": { "TWEETKIT_COOKIE_KEYCHAIN": "tweetkit" } } } }

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:

  1. The client calls auth_status → not authenticated.
  2. The server’s instructions tell the assistant to ask you for your cookie and explain what auth_token and ct0 are and how to copy them.
  3. You paste the Cookie: header once → set_session_cookie("<paste>") → stored (Keychain or file) and activated. Or point import_cookie_from_file("~/Downloads/x.com.har") at a HAR / storage-dump zip.

The raw cookie is never echoed back.

Tools

ToolWhat it does
auth_statusIs a valid session loaded? (call first)
set_session_cookie(cookie_header)Set auth from a pasted Cookie: header — explains exactly what to copy
import_cookie_from_file(path)Set auth from a HAR / storage-dump .zip / cookie JSON
post_tweet(text, image_path?, reply_to?)Post a tweet (optional image / reply)
post_thread(tweets[])Post a thread
quote_tweet(text, quote_tweet_id, image_path?)Quote-tweet an existing tweet
delete_tweet(tweet_id) / delete_tweets(ids[])Delete tweets
like_tweet / unlike_tweet / retweet / unretweet / bookmark_tweet / unbookmark_tweetEngage (each reversible)
get_my_tweets(limit?) / get_user_tweets(username, limit?)Read a timeline
get_tweet(tweet_id)Fetch one tweet by id
search_my_tweets(query, regex?, limit?)Find your own tweets (local filter — great for cleanup)
search_x(query, latest?, limit?)Search all of X (real search, supports operators)
post_note / schedule_tweet / unschedule_tweetLong-form note tweets; schedule / cancel
follow_user / unfollow_user / block_user / unblock_user / mute_user / unmute_userSocial-graph actions
pin_tweet / unpin_tweetPin / unpin to your profile
get_home_timeline / get_replies / get_notifications / get_bookmarksFeeds & conversations
get_user_profile / get_followers / get_following / get_likers / get_retweeters / get_user_likesPeople & profiles

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:

  1. x-client-transaction-id — X requires an anti-bot header derived from the page's ondemand.s JS and a home fetch. Generated with the standalone x-client-transaction-id package.
  2. Media upload (images) — POST upload.x.com/i/media/upload.json as INIT → APPEND → FINALIZE, yielding a media_id.
  3. Write / delete — POST /i/api/graphql/<queryId>/CreateTweet and .../DeleteTweet.
  4. Read — GET /i/api/graphql/<queryId>/UserTweets (paginated by cursor), plus UserByScreenName to 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.

your cookie ──► x-client-transaction-id ──► CreateTweet / DeleteTweet / UserTweets ──► result

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.txt or the macOS Keychain, and .gitignore blocks cookie.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
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.3.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分