Skip to main content

MCP server for the official Grok CLI (OAuth, no API key)

Project description

English | Русский

grok-cli-mcp

MCP server for the official Grok CLI — works over OAuth, no API key.

Exposes the grok_query, grok_continue, grok_models and grok_sessions tools to any MCP client (Claude Code, Cline, Cursor, etc.) using your already logged-in Grok account.


Requirements

  • Python ≥ 3.8
  • The grok CLI installed and logged in (grok login, verify with grok models)

Installation

cd ~/grok-cli-mcp
pipx install -e . --force

After installation the grok-cli-mcp binary appears on your PATH.


Connecting to Claude Code

~/.claude/mcp.json is not read by Claude Code. Register the server via the CLI:

claude mcp add grok --scope user -- grok-cli-mcp

With logging to a file:

claude mcp add grok --scope user -- grok-cli-mcp --log-file ~/grok-mcp.log

Check:

claude mcp list        # grok: grok-cli-mcp - ✔ Connected

Then restart Claude Code so the tools are picked up.


Tools

grok_query

Parameter Type Description
prompt (required) string The prompt text
model string Model, e.g. grok-composer-2.5-fast
effort string low | medium | high | xhigh | max
reasoning_effort string Reasoning effort level
agent string Agent name or path to a definition file
permission_mode string Permission mode
resume string Resume a specific session by ID (see grok_sessions)
max_turns integer Maximum number of agent turns
output_format string plain | json | streaming-json (default plain)
best_of_n integer Run the task N ways in parallel and pick the best (headless)
check boolean Append a self-verification loop to the prompt (headless)
sandbox string FS/network sandbox profile (from ~/.grok/sandbox.toml)
rules string Extra rules to append to the system prompt
allow string/array Permission allow rule(s), e.g. Bash(git:*); string or list
deny string/array Permission deny rule(s); string or list
tools string Built-in tools to allow (comma-separated)
disallowed_tools string Built-in tools to remove (comma-separated)
system_prompt_override string Override the agent's system prompt
no_plan boolean Disable the planning step
no_subagents boolean Disable subagents
always_approve boolean Auto-approve all tool executions
disable_web_search boolean Disable web search / web fetch
cwd string Working directory for the session
worktree string/boolean New git worktree: a name (string) or true (unnamed)
timeout number Max seconds to wait for a response (default 600)

grok_continue

Continues the most recent Grok session for the current working directory with a new prompt (the --continue flag). Same parameters as grok_query, except agent, worktree and resume.

grok_models

No parameters. Returns the list of available models (grok models).

grok_sessions

List or search past Grok sessions. Returns session IDs (for the resume parameter of grok_query) and short summaries.

Parameter Type Description
query string Search keyword; omit it to list the most recent sessions
limit integer Maximum number of sessions to show (default 20)

Usage (from Claude Code)

@grok Write a typed function that sums a list

With parameters the tool is called like this:

{
  "prompt": "Write hello world in Python with comments",
  "no_plan": true,
  "output_format": "json"
}

⚠️ Model compatibility. The default model grok-composer-2.5-fast does not support effort / reasoning_effort — a request with them returns an API 400 error. Use them only with reasoning models (grok-build, etc.).


Debugging and tests

# Offline tests (unit + protocol, no network and no grok login needed)
python3 -m unittest test_mcp

# + live smoke (actually calls the grok CLI, requires grok login)
GROK_LIVE=1 python3 -m unittest test_mcp

# Run the server manually (talks over stdio, JSON-RPC)
grok-cli-mcp

# With logging
grok-cli-mcp --log-file ~/grok-mcp.log

License

MIT © Evgenii Nekrasov

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

grok_cli_mcp_server-1.0.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grok_cli_mcp_server-1.0.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file grok_cli_mcp_server-1.0.0.tar.gz.

File metadata

  • Download URL: grok_cli_mcp_server-1.0.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for grok_cli_mcp_server-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e53bdb1825fb222bd0c73a2f782d7883eea7bbb233f78c296dd3ab1aa34e3ccc
MD5 38c3b13f77b49e35dcd7a08fc14cf737
BLAKE2b-256 1f48485fd2b5791340ef96d1c4d59d155f060acff9bdddd7cef925a8a1d9ba49

See more details on using hashes here.

File details

Details for the file grok_cli_mcp_server-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for grok_cli_mcp_server-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fbb0b3f09acbb93822e64d684ce3ba364cbe9288712d4fd25107828c78082d2b
MD5 6659de6d9d2edd19f42c70fcd6657a85
BLAKE2b-256 6da9cb6805526a926d968c05b0996d3a2bcb90bda542d86a0161d2d5e1ed6a9f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page