Read-only Twitter/X API v2 — tweets, threads, timelines, user profiles. Published as both an npm library and an MCP server for Claude Code.
claude mcp add -e X_BEARER_TOKEN=your-token-here x-api -- bunx --bun @side-quest/x-apiThat's it. The MCP tools are now available in Claude Code.
- Go to the Twitter Developer Portal
- Create a project and app
- Generate a Bearer Token (read-only access is sufficient)
| Tool | Description |
|---|---|
x_get_tweet |
Get a single tweet by ID with author info and engagement metrics |
x_get_thread |
Get a full conversation thread from a tweet ID |
x_get_timeline |
Get a user's recent tweets by username |
x_get_user |
Get a user profile — bio, follower counts, tweet count |
x_get_replies |
Get replies to a specific tweet |
x_search |
Search recent tweets (7-day window) |
Download the latest x-api.mcpb from GitHub Releases and double-click to install. Claude Desktop will prompt you for your Bearer Token.
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
{
"mcpServers": {
"x-api": {
"command": "bunx",
"args": ["--bun", "@side-quest/x-api"],
"env": {
"X_BEARER_TOKEN": "your-token-here"
}
}
}
}Instead of hardcoding the token, set it in your shell:
export X_BEARER_TOKEN="your-token-here"Then use ${X_BEARER_TOKEN} in the config:
claude mcp add -e X_BEARER_TOKEN='${X_BEARER_TOKEN}' x-api -- bunx --bun @side-quest/x-apiimport { createXApiClient } from '@side-quest/x-api';
const client = createXApiClient({ bearerToken: process.env.X_BEARER_TOKEN });
const user = await client.getUser('elonmusk');
const tweets = await client.getTimeline('elonmusk', { maxResults: 10 });
const tweet = await client.getTweet('1234567890');MIT