Metadata-Version: 2.4
Name: mcp-grok-websearch
Version: 0.1.2
Summary: MCP server that exposes Grok Build CLI's built-in web_search as an MCP tool
Project-URL: Homepage, https://github.com/Epiphany_LX/mcp-grok-websearch
Project-URL: Repository, https://github.com/Epiphany_LX/mcp-grok-websearch
License: MIT
Keywords: grok,llm,mcp,model-context-protocol,web-search,xai
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: mcp[cli]>=1.9.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# mcp-grok-websearch

An MCP server that exposes [Grok Build CLI](https://x.ai/cli)'s built-in `web_search` as a standard MCP tool. Any MCP-compatible agent (Codex, Claude Desktop, Cursor, etc.) can use it for real-time web search.

## Prerequisites

1. **Grok Build CLI** installed and authenticated:
   ```bash
   curl -fsSL https://x.ai/cli/install.sh | bash
   grok login   # OAuth, or set GROK_CODE_XAI_API_KEY below
   ```
2. **uv** (for `uvx` usage): https://docs.astral.sh/uv/

## Usage

### Run directly with uvx (no install needed)

```bash
uvx mcp-grok-websearch
```

### Configure in an MCP-compatible agent

Add to your agent's MCP config (e.g. `~/.codex/config.json`, `claude_desktop_config.json`, etc.):

```json
{
  "mcpServers": {
    "websearch": {
      "command": "uvx",
      "args": ["mcp-grok-websearch"]
    }
  }
}
```

If you use an API key instead of `grok login`:

```json
{
  "mcpServers": {
    "websearch": {
      "command": "uvx",
      "args": ["mcp-grok-websearch"],
      "env": {
        "GROK_CODE_XAI_API_KEY": "xai-..."
      }
    }
  }
}
```

## MCP Tool

### `web_search`

Search the web in real time using Grok's built-in search capability.

| Parameter | Type | Default | Description |
|---|---|---|---|
| `query` | `str` | required | Search query |
| `max_results` | `int` | `5` | Number of results (1–20) |

**Returns:** Formatted results, each with `Title`, `URL`, and `Summary`, separated by `---`.

**Example result:**
```
Title: Model Context Protocol – Anthropic
URL: https://modelcontextprotocol.io
Summary: The official site for MCP, the open standard for connecting AI to external tools and data sources.
---
Title: MCP GitHub Repository
URL: https://github.com/modelcontextprotocol
Summary: Source code and SDKs for the Model Context Protocol.
---
```

## Authentication

The server supports two modes, tried in this order:

1. **API key** – set `GROK_CODE_XAI_API_KEY` (or `XAI_API_KEY`) in the environment.
2. **OAuth session** – if no key is present, the existing `grok login` session on the machine is used.

## License

MIT
