twitter-read
An MCP server for reading Twitter/X engagement data and metrics, enabling AI agents to measure tweet performance, track mentions, analyze replies, and search tweets with engagement metrics.
README
Twitter Read MCP Server
<!-- mcp-name: twitter-read -->
An MCP (Model Context Protocol) server for reading Twitter/X engagement data and metrics. Enables AI agents to measure tweet performance, track mentions, analyze replies, and search tweets with engagement metrics.
Features
- Get Tweet Metrics: Fetch likes, retweets, replies, quotes, bookmarks, and impressions for any tweet
- Get Mentions: Retrieve recent @mentions with engagement data
- Get Replies: Access all replies to a specific tweet with metrics
- Search Tweets: Search Twitter with engagement metrics included
- Built-in Rate Limiting: Enforces Twitter API limits (500 requests per 15 minutes)
- OAuth 2.0 Support: Compatible with Twitter API v2 authentication
Installation
Prerequisites
- Node.js 18 or higher
- Twitter API credentials (Bearer Token or API Key + Secret)
From Source
git clone <repository-url>
cd twitter-read-mcp
npm install
npm run build
From npm (future)
npm install -g @polsia/twitter-read-mcp
Configuration
Twitter API Credentials
You need Twitter API access. Get credentials from Twitter Developer Portal:
- Create a Twitter Developer account
- Create a new App
- Generate credentials
Environment Variables
Create a .env file or set environment variables:
# Option 1: Bearer Token (recommended for read-only access)
TWITTER_BEARER_TOKEN=your_bearer_token_here
# Option 2: API Key + Secret (for OAuth 2.0)
TWITTER_API_KEY=your_api_key_here
TWITTER_API_SECRET=your_api_secret_here
Note: Bearer token is simpler for read-only operations. API Key + Secret is required for user-context operations like getting your own mentions.
MCP Configuration
Add to your MCP settings file (e.g., Claude Desktop config):
{
"mcpServers": {
"twitter-read": {
"command": "twitter-read-mcp",
"env": {
"TWITTER_BEARER_TOKEN": "your_bearer_token_here"
}
}
}
}
Or if installed from source:
{
"mcpServers": {
"twitter-read": {
"command": "node",
"args": ["/path/to/twitter-read-mcp/build/index.js"],
"env": {
"TWITTER_BEARER_TOKEN": "your_bearer_token_here"
}
}
}
}
Usage
Available Tools
1. get_tweet_metrics
Get engagement metrics for a specific tweet.
Parameters:
tweet_id(required): The ID of the tweet
Returns:
{
"tweet_id": "1234567890",
"text": "Tweet content here",
"created_at": "2026-01-25T00:00:00.000Z",
"author_id": "1234567890",
"metrics": {
"likes": 42,
"retweets": 8,
"replies": 5,
"quotes": 2,
"bookmarks": 10,
"impressions": 5000
},
"requestsRemaining": 498
}
Example:
Get metrics for tweet 1882163408476512603
2. get_mentions
Get recent @mentions of your account.
Parameters:
since_date(optional): ISO 8601 date (e.g., "2026-01-20T00:00:00Z")max_results(optional): Number of mentions to return (5-100, default: 10)
Returns:
{
"mentions": [
{
"tweet_id": "1234567890",
"text": "@yourhandle great work!",
"created_at": "2026-01-25T00:00:00.000Z",
"author_id": "9876543210",
"metrics": {
"likes": 5,
"retweets": 1,
"replies": 0,
"quotes": 0
}
}
],
"count": 1,
"requestsRemaining": 497
}
Example:
Show me mentions from the last 24 hours
3. get_replies
Get all replies to a specific tweet.
Parameters:
tweet_id(required): The ID of the tweetmax_results(optional): Number of replies to return (5-100, default: 10)
Returns:
{
"replies": [
{
"tweet_id": "1234567891",
"text": "This is a reply",
"created_at": "2026-01-25T01:00:00.000Z",
"author_id": "9876543210",
"metrics": {
"likes": 2,
"retweets": 0,
"replies": 1,
"quotes": 0
}
}
],
"count": 1,
"requestsRemaining": 496
}
Example:
Get all replies to tweet 1882163408476512603
4. search_tweets
Search for tweets matching a query with engagement metrics.
Parameters:
query(required): Search query (supports Twitter search operators)max_results(optional): Number of tweets to return (10-100, default: 10)start_time(optional): ISO 8601 date for earliest tweet
Returns:
{
"tweets": [
{
"tweet_id": "1234567890",
"text": "Tweet matching your query",
"created_at": "2026-01-25T00:00:00.000Z",
"author_id": "1234567890",
"metrics": {
"likes": 100,
"retweets": 20,
"replies": 10,
"quotes": 5
}
}
],
"count": 1,
"query": "from:polsiaHQ",
"requestsRemaining": 495
}
Example:
Search for tweets from @polsiaHQ in the last week
Rate Limiting
The server enforces Twitter API v2 rate limits:
- 500 requests per 15-minute window
- Each tool response includes
requestsRemainingfield - Requests beyond the limit return a rate limit error
Development
Building
npm run build
Watch Mode
npm run watch
Testing Locally
Run the MCP server directly:
export TWITTER_BEARER_TOKEN=your_token
npm run dev
The server communicates via stdio, so you'll need an MCP client to interact with it.
Architecture
- Language: TypeScript
- MCP SDK:
@modelcontextprotocol/sdkv1.x - Twitter Client:
twitter-api-v2for Twitter API v2 - Transport: stdio (standard MCP transport)
- Authentication: Bearer Token or OAuth 2.0 PKCE
Error Handling
All tools return structured error responses:
{
"error": "Error message",
"code": "ERROR_CODE",
"requestsRemaining": 499
}
Common errors:
Rate limit exceeded: Too many requests in 15-minute windowMissing Twitter API credentials: Environment variables not setInvalid tweet ID: Tweet doesn't exist or is privateSearch query too complex: Simplify your search query
Contributing
This project is part of the Polsia ecosystem. Contributions are welcome!
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
Roadmap
- [ ] OAuth 2.0 PKCE flow for user authentication
- [ ] Caching layer for frequently accessed tweets
- [ ] Batch operations for multiple tweets
- [ ] Historical data fetching (7-day window)
- [ ] User profile metrics
- [ ] List management tools
License
MIT License - See LICENSE file for details
Support
- Documentation: Twitter API v2 Docs
- MCP Specification: Model Context Protocol
- Issues: Report bugs and feature requests on GitHub
Credits
Built by Polsia for measuring marketing performance on Twitter/X. Powered by the Model Context Protocol from Anthropic.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。