| Crates.io | x-mcp-server |
| lib.rs | x-mcp-server |
| version | 0.1.0 |
| created_at | 2025-08-26 09:51:39.2141+00 |
| updated_at | 2025-08-26 09:51:39.2141+00 |
| description | A Model Context Protocol (MCP) server that wraps X (Twitter) API for basic utilities |
| homepage | https://github.com/yourusername/x-mcp-server |
| repository | https://github.com/yourusername/x-mcp-server |
| max_upload_size | |
| id | 1810929 |
| size | 107,592 |
A Model Context Protocol (MCP) server that provides access to X (formerly Twitter) API for basic utilities. This server allows AI assistants and other MCP clients to interact with X/Twitter through a standardized interface.
cargo install x-mcp-server
git clone https://github.com/yourusername/x-mcp-server
cd x-mcp-server
cargo build --release
Create a .env file or set environment variables:
export X_CONSUMER_KEY="your_consumer_key"
export X_CONSUMER_SECRET="your_consumer_secret"
export X_ACCESS_TOKEN="your_access_token"
export X_ACCESS_TOKEN_SECRET="your_access_token_secret"
Or copy .env.example to .env and fill in your credentials.
x-mcp-server
The server will start and listen for MCP requests on stdin/stdout.
The server can be configured using environment variables:
| Variable | Description | Required |
|---|---|---|
X_BEARER_TOKEN |
Your X API Bearer Token | Yes |
RUST_LOG |
Logging level (e.g., info, debug) |
No |
The server provides the following MCP tools:
get_userGet user information by username or user ID.
Parameters:
identifier (string): Username (without @) or user IDis_user_id (boolean, optional): Whether the identifier is a user ID (default: false)Example:
{
"identifier": "elonmusk",
"is_user_id": false
}
post_tweetPost a new tweet.
Parameters:
text (string): The text content of the tweetreply_to (string, optional): Tweet ID to reply toExample:
{
"text": "Hello, world! 🌍",
"reply_to": "1234567890"
}
search_tweetsSearch for tweets.
Parameters:
query (string): Search querymax_results (integer, optional): Maximum number of results (1-100, default: 10)include_users (boolean, optional): Include user information (default: false)include_metrics (boolean, optional): Include tweet metrics (default: false)Example:
{
"query": "MCP OR \"Model Context Protocol\"",
"max_results": 20,
"include_users": true,
"include_metrics": true
}
get_tweetGet a specific tweet by ID.
Parameters:
tweet_id (string): The tweet IDExample:
{
"tweet_id": "1234567890"
}
get_user_tweetsGet a user's recent tweets.
Parameters:
identifier (string): Username or user IDis_user_id (boolean, optional): Whether the identifier is a user ID (default: false)max_results (integer, optional): Maximum number of tweets (1-100, default: 10)Example:
{
"identifier": "elonmusk",
"max_results": 5
}
You can also use this as a Rust library:
[dependencies]
x-mcp-server = "0.1"
use x_mcp_server::{XClient, auth::OAuthCredentials};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create credentials
let credentials = OAuthCredentials::from_env()?;
let client = XClient::new(credentials);
// Get user info
let user = client.get_user_by_username("elonmusk").await?;
println!("{:#?}", user);
// Post a tweet
let tweet = client.post_tweet("Hello from Rust! 🦀", None).await?;
println!("Posted tweet: {}", tweet.id);
Ok(())
}
This server implements the Model Context Protocol specification. You can integrate it with any MCP-compatible client:
Add to your Claude Desktop configuration:
{
"mcpServers": {
"x-mcp-server": {
"command": "x-mcp-server",
"env": {
"X_CONSUMER_KEY": "your_key",
"X_CONSUMER_SECRET": "your_secret",
"X_ACCESS_TOKEN": "your_token",
"X_ACCESS_TOKEN_SECRET": "your_token_secret"
}
}
}
}
Any MCP client can connect to this server using stdio transport.
cargo build
cargo test
RUST_LOG=debug cargo run
Please be aware of X API rate limits:
The server does not implement rate limiting, so ensure your usage stays within these limits.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under either of
at your option.