A command-line client for X (formerly Twitter)
-
Install golang environment.
-
get twty
$ go install github.com/mattn/twty@latest
Thanks all!
% brew install twty
You would not need to install the golang compiler with this method.
twty uses X API v2 with OAuth 2.0 authentication.
- Create an app at the X Developer Portal
- Set the callback URL to
http://localhost:8989/callbackin your app settings - Run twty — a browser window will open for authorization
Configuration file is stored in: ~/.config/twty/settings.json
For windows user: %APPDATA%/twty/settings.json
$ twty -h
$ twty Hello World
$ twty
$ twty -u USERNAME
$ twty -s KEYWORD
$ twty -r
$ twty -f TWEET_ID
$ twty -i TWEET_ID
$ twty -i TWEET_ID Your reply here
$ twty -m image.png Hello with image
$ twty -l LIST_ID
$ twty -l USERNAME/LIST_NAME
$ twty -S 60s
twty can run as an MCP (Model Context Protocol) server, allowing AI assistants like Claude to interact with X directly.
$ twty -mcp
To use with Claude Code, add the following to your MCP settings:
{
"mcpServers": {
"twty": {
"command": "twty",
"args": ["-mcp"]
}
}
}Available tools:
| Tool | Description |
|---|---|
get_timeline |
Get your home timeline |
search_tweets |
Search recent tweets |
get_mentions |
Get your mentions and replies |
get_user_tweets |
Get tweets from a specific user |
get_list_tweets |
Get tweets from a list |
post_tweet |
Post a new tweet (with optional reply) |
like_tweet |
Like a tweet |
retweet |
Retweet a tweet |
Note: You must run twty at least once without -mcp first to complete OAuth authorization.
-a PROFILE: switch profile to load configuration file.
-f ID: specify favorite ID
-i ID: specify in-reply ID, if not specify text, it will be RT.
-l LIST: show list's timeline (list ID or user/list-name)
-m FILE: upload media
-u USER: show user's timeline
-s WORD: search timeline
-S DELAY: tweets after DELAY
-mcp: run as MCP server
-json: as JSON
-r: show replies
-v: detail display
-ff FILENAME: post utf-8 string from a file("-" means STDIN)
-count NUMBER: show NUMBER tweets at timeline.
-since DATE: show tweets created after the DATE (ex. 2017-05-01)
-until DATE: show tweets created before the DATE (ex. 2017-05-31)
-since_id NUMBER: show tweets that have ids greater than NUMBER.
-max_id NUMBER: show tweets that have ids lower than NUMBER.
Do you use proxy? then set environment variable HTTP_PROXY like below.
HTTP_PROXY=http://myproxy.example.com:8080
under the MIT License: http://mattn.mit-license.org/2017
Yasuhiro Matsumoto mattn.jp@gmail.com
Have Fun!