Grok Cli Mcp — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Grok Cli Mcp (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
MCP server that wraps the Grok CLI, providing seamless access to Grok AI models through the Model Context Protocol.
grok-cli-mcp is a Model Context Protocol (MCP) server that acts as a bridge between MCP clients (like Claude Code, Cline, Cursor) and the Grok CLI. Instead of implementing direct API calls, it leverages the official Grok CLI tool, providing:
grok_query (general queries), grok_chat (multi-turn conversations), grok_code (code generation)✅ Leverage existing tooling: Uses the official Grok CLI, ensuring compatibility and stability
✅ Future OAuth support: When Grok CLI adds OAuth authentication, this wrapper will support it automatically without code changes
✅ Fixed pricing plans: Can benefit from fixed monthly pricing (like Codex/ChatGPT/Gemini) when Grok introduces CLI-specific plans, rather than paying per API token
✅ Organization-friendly: Many organizations prefer audited CLI tools over direct API integrations for security and compliance
✅ Simpler codebase: ~400 lines vs 1500+ for a full API client implementation
✅ Fewer dependencies: No HTTP client libraries, request/response handling, or complex networking code
✅ Automatic updates: CLI bug fixes and new features propagate without code changes
⚠️ Performance overhead: Extra process spawning adds ~50-200ms latency per request
⚠️ CLI dependency: Requires Grok CLI to be installed and in PATH
⚠️ Limited control: Can't access low-level API features not exposed by CLI
⚠️ Error handling: CLI error messages may be less structured than API responses
⚠️ No streaming: Limited to CLI streaming capabilities (if any)
Perfect for:
Consider direct API for:
Before installing grok-cli-mcp, ensure you have:
# Installation instructions vary by platform
# See https://docs.x.ai/docs for latest instructions python3 --versionpip install grok-cli-mcpuv pip install grok-cli-mcppipx install grok-cli-mcpgit clone https://github.com/BasisSetVentures/grok-cli-mcp.git
cd grok-cli-mcp
pip install -e .git clone https://github.com/BasisSetVentures/grok-cli-mcp.git
cd grok-cli-mcp
pip install -e ".[dev]"# Required: Set your Grok API key
export GROK_API_KEY="your-api-key-here"
# Optional: Specify custom Grok CLI path
export GROK_CLI_PATH="/custom/path/to/grok"For permanent setup, add to your shell profile (~/.bashrc, ~/.zshrc, etc.):
echo 'export GROK_API_KEY="your-api-key-here"' >> ~/.bashrc
source ~/.bashrc# Run the server directly
python -m grok_cli_mcp
# Or use the command
grok-mcp
# Should start and wait for stdin (Ctrl+C to exit)#### For Claude Code
Add to your .mcp.json:
{
"mcpServers": {
"grok": {
"type": "stdio",
"command": "python",
"args": ["-m", "grok_cli_mcp"],
"env": {
"GROK_API_KEY": "your-api-key-here"
}
}
}
}#### For Cline (VS Code)
Add to ~/.cline/mcp_settings.json:
{
"mcpServers": {
"grok": {
"command": "python",
"args": ["-m", "grok_cli_mcp"],
"env": {
"GROK_API_KEY": "your-api-key-here"
}
}
}
}#### For Cursor
Add to ~/.cursor/mcp.json:
{
"grok": {
"command": "python",
"args": ["-m", "grok_cli_mcp"],
"env": {
"GROK_API_KEY": "your-api-key-here"
}
}
}⚠️ Security Warning: Never commit API keys to version control. Use environment variables or a secrets manager.
Send a simple prompt to Grok:
{
"tool": "grok_query",
"arguments": {
"prompt": "Explain quantum computing in simple terms",
"model": "grok-code-fast-1",
"timeout_s": 120
}
}Response: Plain text answer from Grok
Multi-turn conversation with message history:
{
"tool": "grok_chat",
"arguments": {
"messages": [
{"role": "user", "content": "What is MCP?"},
{"role": "assistant", "content": "MCP is Model Context Protocol..."},
{"role": "user", "content": "How does it work?"}
],
"model": "grok-code-fast-1",
"timeout_s": 120
}
}Response: Grok's answer considering the conversation history
Code generation with language hints and context:
{
"tool": "grok_code",
"arguments": {
"task": "Create a Python function to parse JSON with error handling",
"language": "python",
"context": "Using standard library only, no external dependencies",
"timeout_s": 180
}
}Response: Complete, usable Python code with explanations
Get structured response with full details:
{
"tool": "grok_query",
"arguments": {
"prompt": "Explain async/await",
"raw_output": true
}
}Response:
{
"text": "Async/await is...",
"messages": [{"role": "assistant", "content": "..."}],
"raw": "...",
"model": "grok-code-fast-1"
}| Variable | Required | Default | Description |
|---|---|---|---|
GROK_API_KEY | Yes | - | Your Grok API key from X.AI console |
GROK_CLI_PATH | No | /opt/homebrew/bin/grok | Path to Grok CLI binary |
Available models (as of 2025-12):
grok-code-fast-1 - Fast model for code tasksgrok-2 - Main model for general tasksSpecify model in each tool call or omit for CLI default.
Default timeouts by tool:
grok_query: 120 secondsgrok_chat: 120 secondsgrok_code: 180 secondsAdjust via timeout_s parameter for complex tasks.
Problem: Server can't locate the Grok CLI binary
Solutions:
which grok export GROK_CLI_PATH="/path/to/grok" export PATH="$PATH:/opt/homebrew/bin"Problem: API key not in environment
Solutions:
export GROK_API_KEY="xai-...".bashrc, .zshrc): echo 'export GROK_API_KEY="xai-..."' >> ~/.zshrc
source ~/.zshrc.env file with python-dotenv (see examples/.env.example)Problem: Request took too long
Solutions:
{"timeout_s": 300}Problem: CLI output isn't valid JSON
Solutions:
# Update instructions vary by installation methodraw_output=true to see raw CLI response: {"raw_output": true}Problem: Can't execute Grok CLI
Solutions:
chmod +x /path/to/grok grok -p "test"For more solutions, see docs/troubleshooting.md.
❌ DO NOT:
.env files with real API keys.mcp.json tracked by git✅ DO:
export GROK_API_KEY="..."~/.bashrc, ~/.zshrcIf you accidentally expose your API key:
gitleaks to scan for secretsDo NOT open public issues for security vulnerabilities.
Please report security concerns responsibly through GitHub Security Advisories or by contacting the maintainers directly.
This project follows a CLI wrapper pattern rather than direct API integration. Key design decisions:
For detailed architecture discussion, see docs/architecture.md.
# Install dev dependencies
pip install -e ".[dev]"
# Run all tests
pytest
# Run with coverage
pytest --cov=grok_cli_mcp --cov-report=html
# Run specific test file
pytest tests/test_utils.py# Format code
black .
# Lint code
ruff check --fix .mypy src/Contributions are welcome! Please:
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)Please ensure:
pytest)black, ruff)mypy)This project is licensed under the MIT License - see the LICENSE file for details.
Made by [Basis Set Ventures](https://github.com/BasisSetVentures) with Claude Code and FastMCP
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.