MCP server for Grok X.com search integration using xAI API
Project description
Grok MCP Server
Search X.com in real-time with xAI's Grok API - directly from Claude
A Model Context Protocol server that brings real-time X/Twitter search to Claude. Powered by xAI's Live Search API, it provides instant access to posts, users, threads, and trending topics.
Why Grok MCP?
- Real-time data - Access live X.com content, not cached or outdated information
- Native Claude integration - Works seamlessly with Claude Desktop and Claude Code
- Simple setup - One command to install, one config to add
- Open source - MIT licensed, community-driven
Quick Start
1. Get an xAI API Key
Get your API key from console.x.ai
2. Install
uvx grok-mcp
3. Configure Claude
For Claude Code - Add to .mcp.json in your project:
{
"mcpServers": {
"grok": {
"command": "uvx",
"args": ["grok-mcp"],
"env": {
"XAI_API_KEY": "your-api-key"
}
}
}
}
For Claude Desktop - Add to your config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"grok": {
"command": "uvx",
"args": ["grok-mcp"],
"env": {
"XAI_API_KEY": "your-api-key"
}
}
}
}
4. Use It
Ask Claude things like:
- "Search X for posts about AI"
- "What's trending on X right now?"
- "Find tweets from @elonmusk about Tesla"
Available Tools
| Tool | Description |
|---|---|
search_posts |
Search posts with filters (handles, date range, analysis mode) |
search_users |
Find user profiles |
search_threads |
Discover conversation threads |
get_trends |
Get trending topics by location |
health_check |
Verify API connection |
Examples
Search Posts
Search X for posts about "AI safety" from the last week
Filter by User
Find recent posts from @anthropic about Claude
Get Trends
What are the trending topics in tech right now?
Development
# Clone
git clone https://github.com/guzus/grok-mcp.git
cd grok-mcp
# Install dependencies
uv sync --dev
# Run tests
uv run pytest
# Run locally
XAI_API_KEY=your-key uv run python -m grok_mcp
Architecture
src/grok_mcp/
├── server.py # MCP server implementation
├── grok_client.py # xAI Live Search API client
├── search_tools.py # Tool implementations
├── response_formatter.py
├── config.py
└── exceptions.py
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT License - see LICENSE for details.
Links
Built with xAI Grok and Model Context Protocol
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grok_mcp-0.2.1.tar.gz.
File metadata
- Download URL: grok_mcp-0.2.1.tar.gz
- Upload date:
- Size: 69.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
232e8296757230a018b996243bb13ec3ee889f2cd336e404379cdbcabd3dd925
|
|
| MD5 |
84a654645ff8fd6f7e4bb58b64c05af6
|
|
| BLAKE2b-256 |
87628895d8ff7a9ed90c12ade4b35d3d521ca4e79fa39e172729c498163d6a57
|
File details
Details for the file grok_mcp-0.2.1-py3-none-any.whl.
File metadata
- Download URL: grok_mcp-0.2.1-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bb420ce3ea0e70e8c03860c5f3ba4a73f0e8d6601e246811f2b4294cc50ed84
|
|
| MD5 |
e9f0b9193b2ea1ea95482eee61090577
|
|
| BLAKE2b-256 |
8d3947a2b4dc940c397c374d02ce572e2de18a8934b44c0e4e875815f312b897
|