Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build and Test

on:
pull_request:
types: [opened, synchronize]
paths-ignore:
- '**.md'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Dependencies
run: npm install

- name: Build Project
run: npm run build

- name: Run Tests
run: npm test
41 changes: 41 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish to npm

on:
push:
branches:
- main
paths-ignore:
- '**.md'

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org/'
scope: '@missionsquad'

- name: Install Dependencies
run: npm install

- name: Build Project
run: npm run build

- name: Run Tests
run: npm test

- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
47 changes: 6 additions & 41 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,33 +1,10 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Virtual environments
.venv/
venv/
ENV/
env/
# Dependencies
node_modules/

# UV
.uv/
# Build output
dist/
coverage/
*.tsbuildinfo

# IDE
.idea/
Expand All @@ -36,18 +13,6 @@ env/
*.swo
*~

# Testing
.pytest_cache/
.coverage
htmlcov/
.tox/
.nox/

# Type checking
.mypy_cache/
.dmypy.json
dmypy.json

# Environment
.env
.env.local
Expand Down
1 change: 0 additions & 1 deletion .python-version

This file was deleted.

11 changes: 0 additions & 11 deletions CLAUDE.md

This file was deleted.

169 changes: 49 additions & 120 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,157 +1,86 @@
# Grok MCP Server
# MissionSquad Grok MCP Server

> Search X.com in real-time with xAI's Grok API - directly from Claude
TypeScript MCP server for searching X.com with xAI Grok. This runtime is MissionSquad hidden-secret compatible and uses `@missionsquad/fastmcp`.

[![PyPI version](https://img.shields.io/pypi/v/grok-mcp.svg)](https://pypi.org/project/grok-mcp/)
[![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![MCP](https://img.shields.io/badge/MCP-Compatible-purple.svg)](https://modelcontextprotocol.io/)
## Runtime Contract

<!-- MCP Registry verification: mcp-name: io.github.guzus/grok-mcp -->
- Public tool schemas do not expose authentication fields.
- MissionSquad injects the hidden `xaiApiKey` per tool call.
- The server reads hidden values from `context.extraArgs`.
- `XAI_API_KEY` remains available only as a local standalone fallback.

A [Model Context Protocol](https://modelcontextprotocol.io/) 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.
## Tools

<img width="955" height="588" alt="Screenshot 2026-01-26 at 12 20 59 AM" src="https://github.com/user-attachments/assets/b2cc89a4-4ee3-42ca-a788-ad5921f3e811" />
- `search_posts`
- `search_users`
- `search_threads`
- `get_trends`
- `health_check`

## Why Grok MCP?
## Resources

- **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
- `grok://config`
- `grok://health`

## Quick Start
`grok://health` can only use the local env fallback. Per-call MissionSquad hidden secrets are not available to MCP resources, so use the `health_check` tool to validate the active request configuration.

### 1. Get an xAI API Key

Get your API key from [console.x.ai](https://console.x.ai)

### 2. Install
## Local Development

```bash
uvx grok-mcp
npm install
npm run build
npm test
XAI_API_KEY=your-api-key npm start
```

### 3. Configure Claude
## Claude Desktop Example

**For Claude Code** - Add to `.mcp.json` in your project:
Use env fallback outside MissionSquad:

```json
{
"mcpServers": {
"grok": {
"command": "uvx",
"args": ["grok-mcp"],
"command": "npx",
"args": ["-y", "@missionsquad/mcp-grok"],
"env": {
"XAI_API_KEY": "your-api-key"
"XAI_API_KEY": "your-xai-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`
## MissionSquad Registration

Recommended MissionSquad server registration:

```json
{
"mcpServers": {
"grok": {
"command": "uvx",
"args": ["grok-mcp"],
"env": {
"XAI_API_KEY": "your-api-key"
}
"name": "mcp-grok",
"transportType": "stdio",
"command": "node",
"args": ["/absolute/path/to/dist/server.js"],
"secretNames": ["xaiApiKey"],
"secretFields": [
{
"name": "xaiApiKey",
"label": "xAI API key",
"description": "xAI API key used to authenticate Grok API requests.",
"required": true,
"inputType": "password"
}
}
],
"enabled": true
}
```

### 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

```bash
# Clone
git clone https://github.com/guzus/grok-mcp.git
cd grok-mcp
## Package Scripts

# 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.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
- `npm run build`
- `npm test`
- `npm run dev`

## License

MIT License - see [LICENSE](LICENSE) for details.

## Links

- [PyPI Package](https://pypi.org/project/grok-mcp/)
- [xAI API Docs](https://docs.x.ai/)
- [MCP Protocol](https://modelcontextprotocol.io/)
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code)

---

Built with [xAI Grok](https://x.ai/) and [Model Context Protocol](https://modelcontextprotocol.io/)
MIT. See [LICENSE](LICENSE).
11 changes: 11 additions & 0 deletions claude_desktop_config.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"mcpServers": {
"grok": {
"command": "npx",
"args": ["-y", "@missionsquad/mcp-grok"],
"env": {
"XAI_API_KEY": "your-xai-api-key"
}
}
}
}
14 changes: 0 additions & 14 deletions main.py

This file was deleted.

Loading
Loading