grok-web-search-mcp
Sprache: Englisch | 中文
Über das Projekt
Agenten benötigen Live-Web- und X-Zugriff mit Quellenangaben, nicht nur eine Chat-Antwort. Dieses Projekt kapselt die serverseitigen Tools web_search und x_search von xAI als ein einziges MCP-Tool, sodass Hosts wie Grok, Cursor oder Claude Desktop sie aufrufen können, ohne xAI-Clientlogik einzubetten.
Repository: https://github.com/NakanoSanku/grok-web-search-mcp
Upstream-Aufruf (vereinfacht):
POST {base_url}/responses
Authorization: Bearer <api_key>
Content-Type: application/json
{
"model": "grok-4.5",
"input": [{"role": "user", "content": "<query>"}],
"tools": [
{"type": "web_search", "enable_image_understanding": true},
{
"type": "x_search",
"allowed_x_handles": ["xai"],
"from_date": "2025-10-01",
"to_date": "2025-10-10",
"enable_image_understanding": true,
"enable_video_understanding": true
}
]
}Designziele:
Ein MCP-Tool, ein Aufrufvertrag – Modelle dürfen nur
query/scope/recency/imagesübergeben.Schlanke Ergebnisse –
query/text/citations/sources_used(kein roher Upstream-Dump)Benutzerdefinierte Basis-URL – offizielle
https://api.x.ai/v1oder OpenAI-kompatible ProxysOptionale Bildeingabe – HTTPS-URLs oder Data-URIs anhängen (lokale Pfade nur auf Wunsch)
Kein PyPI erforderlich – direkt von GitHub mit
uvx --from git+...ausführen
Funktionen
Funktion | Hinweise |
Live-Websuche | Grok erstellt eine Antwort mit Quellen-URLs |
Live-X-Suche | Standardmäßig enthalten; mit |
X-Filter | Behandelt Erlaubnis-/Verbotslisten (max. 20, |
Domain-Filter | Erlaubnisliste oder Verbotsliste (max. 5, sich gegenseitig ausschließend; Schema/Pfad entfernt) |
Medienverständnis bei der Suche | Bilder auf Webseiten und X-Beiträgen; Videos auf X-Beiträgen |
Client-Bildeingabe | Optionale |
Schlanke JSON-Ausgabe | Kein |
Protokollfehler | Upstream-/Validierungsfehler setzen MCP |
Wiederholungen | 429 / 502 / 503 / 504 und Transport-Timeouts, mit Backoff |
Proxy-freundlich |
|
GitHub-Installation |
|
Nicht enthalten: enable_image_search (Einbettung von Web-Bildergalerien). Verwenden Sie images, wenn Sie ein Bild bereitstellen; verwenden Sie enable_image_understanding für Bilder auf durchsuchten Seiten und X-Beiträgen.
Erstellt mit
Related MCP server: WebQuest MCP
Erste Schritte
Voraussetzungen
Python 3.10+
Ein xAI-API-Schlüssel (oder ein Schlüssel für ein kompatibles Gateway)
uv (empfohlen für
uvxvon GitHub)
# optional: install uv
curl -LsSf https://astral.sh/uv/install.sh | shSchnellstart (uvx von GitHub)
Für den täglichen MCP-Einsatz ist kein lokaler Klon erforderlich:
export GROK_API_KEY=xai-...
uvx --from git+https://github.com/NakanoSanku/grok-web-search-mcp.git grok-web-search-mcpPinnen Sie einen Branch, Tag oder Commit, wenn Sie Reproduzierbarkeit benötigen:
uvx --from git+https://github.com/NakanoSanku/grok-web-search-mcp.git@main grok-web-search-mcp
# uvx --from git+https://github.com/NakanoSanku/grok-web-search-mcp.git@v0.3.0 grok-web-search-mcpLokale Entwicklungsinstallation
Klonen Sie das Repository:
git clone https://github.com/NakanoSanku/grok-web-search-mcp.git cd grok-web-search-mcpInstallieren Sie die Abhängigkeiten:
uv sync # or: pip install -e ".[dev]"Erstellen Sie eine lokale Env-Datei:
cp .env.example .envBearbeiten Sie
.envund setzen Sie mindestensGROK_API_KEY(siehe Konfiguration).
Konfiguration
Variable | Erforderlich | Standard | Beschreibung |
| Ja | — | Akzeptiert auch |
| Nein |
| Auch |
| Nein |
| Auch |
| Nein |
| Anfrage-Timeout in Sekunden (1–3600). Hohes Reasoning + Suche können Minuten dauern |
| Nein |
| TCP/TLS-Verbindungs-Timeout (durch |
| Nein |
| Bilder auf durchsuchten Seiten und X-Beiträgen analysieren |
| Nein |
| Standard-Denklänge: |
| Nein |
| Erlaubt |
| Nein | cwd | Verzeichnis-Einschränkung für lokale Bilder, wenn aktiviert |
| Nein |
| Wiederholungen bei 429/5xx/Timeouts (0–8) |
| Nein |
|
|
| Nein |
| Videos in X-Beiträgen analysieren (nur Operator; kein Tool-Argument) |
| Nein | — | Web-Erlaubnisliste des Operators (max. 5). Aufrufer können dies nicht festlegen |
| Nein | — | Web-Verbotsliste des Operators (max. 5) |
| Nein | — | X-Handle-Erlaubnisliste des Operators (max. 20) |
| Nein | — | X-Handle-Verbotsliste des Operators (max. 20) |
| Nein | — | Zusätzliche Regeln, die an den servereigenen System-Prompt angehängt werden |
Halten Sie Geheimnisse aus Git heraus. Bevorzugen Sie nach Möglichkeit vom Host injizierte Umgebungsvariablen für MCP-Konfigurationen.
Verwendung
Server ausführen
Empfohlen (von GitHub):
export GROK_API_KEY=xai-...
uvx --from git+https://github.com/NakanoSanku/grok-web-search-mcp.git grok-web-search-mcpAus einem lokalen Checkout:
export GROK_API_KEY=xai-...
# Windows PowerShell: $env:GROK_API_KEY="xai-..."
uv run grok-web-search-mcp
# or
uv run python -m grok_web_search_mcpBeispiel für einen kompatiblen Proxy:
export GROK_API_KEY=sk-xxx
export GROK_BASE_URL=http://127.0.0.1:8317/v1
export GROK_MODEL=grok-4.5
uvx --from git+https://github.com/NakanoSanku/grok-web-search-mcp.git grok-web-search-mcpMCP-Host-Konfiguration
Bevorzugt: von GitHub mit uvx ausführen (kein lokaler Pfad).
JSON-basierte Hosts (Cursor / Claude Desktop usw.):
{
"mcpServers": {
"grok-web-search": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/NakanoSanku/grok-web-search-mcp.git",
"grok-web-search-mcp"
],
"env": {
"GROK_API_KEY": "xai-your-key",
"GROK_BASE_URL": "https://api.x.ai/v1",
"GROK_MODEL": "grok-4.5"
}
}
}
}Grok-Benutzerkonfiguration (~/.grok/config.toml):
[mcp_servers.grok-web-search]
command = "uvx"
args = [
"--from",
"git+https://github.com/NakanoSanku/grok-web-search-mcp.git",
"grok-web-search-mcp",
]
enabled = true
[mcp_servers.grok-web-search.env]
GROK_API_KEY = "xai-your-key"
GROK_BASE_URL = "https://api.x.ai/v1"
GROK_MODEL = "grok-4.5"Einen Ref pinnen (Branch / Tag / Commit):
args = [
"--from",
"git+https://github.com/NakanoSanku/grok-web-search-mcp.git@main",
"grok-web-search-mcp",
]Nur für lokale Entwicklung (absoluter Pfad zu einem Checkout):
[mcp_servers.grok-web-search]
command = "uv"
args = [
"run",
"--directory",
"/absolute/path/to/grok-web-search-mcp",
"grok-web-search-mcp",
]
enabled = trueTool: web_search
Jedes Host-Modell muss denselben Vier-Schlüssel-Vertrag verwenden. Zusätzliche Argumente (model, reasoning_effort, system_prompt, Domain-/Handle-Filter) werden abgelehnt. Qualitätsregler liegen in Umgebungsvariablen, damit das Suchverhalten zwischen Modellen nicht abweicht.
Parameter | Typ | Beschreibung |
| string | Erforderlich. Eine Frage in natürlicher Sprache, 2–600 Zeichen. Keine Stichwortliste ( |
|
| Standard |
|
| Standard |
| string[]? | Optionale Bild-URLs (http(s) / Data-URI, max. 5). Nur wenn der Benutzer ein Bild bereitgestellt hat. |
Kanonisches Beispiel:
{ "query": "What is xAI's latest valuation?" }Der Server führt dann Folgendes aus: normalisiert query, fügt einen festen System-Prompt ein, wendet Operator-Filter aus der Umgebung an, bildet recency auf X-Datumsgrenzen ab und verwendet immer das konfigurierte Modell / Reasoning-Effort.
images sind input_image-Teile der Responses API. Lokale Dateisystempfade sind standardmäßig deaktiviert. Dies ist keine „Suche im Web nach Stockbildern“.
Antwortformat
Erfolg (MCP isError: false, strukturierter Inhalt):
{
"query": "What is xAI?",
"text": "...",
"citations": [{"url": "https://x.ai", "title": "xAI"}],
"sources_used": ["web", "x"],
"scope": "all",
"recency": "any"
}Ein Fehler ist ein Protokollfehler des Tools (isError: true) mit einer kurzen Meldung, zum Beispiel Grok API error (401): Invalid API key. Unvollständige oder leere Upstream-Antworten sind ebenfalls Fehler und kein stiller Erfolg.
Absichtlich nicht zurückgegeben: API-Schlüssel, model, base_url, rohes Upstream-JSON oder Annotations-Blobs (URLs werden ausschließlich in citations übernommen). Diagnostiziere die Konfiguration außerhalb des Tool-Ergebnisses (Env / Host-MCP-Einstellungen / stderr-Logs).
Python-Client-Beispiel
import asyncio
from grok_web_search_mcp.client import GrokWebSearchClient
from grok_web_search_mcp.config import Settings
async def main():
async with GrokWebSearchClient(Settings.from_env()) as client:
result = await client.web_search("What is xAI?")
print(result.to_dict())
asyncio.run(main())Echte Aufrufe verbrauchen Modell- und serverseitiges Suchkontingent. Unit-Tests verwenden Mocks und greifen nicht auf das Netzwerk zu.
Entwicklung
git clone https://github.com/NakanoSanku/grok-web-search-mcp.git
cd grok-web-search-mcp
uv sync --extra dev
uv run pytest
# live API (optional): GROK_LIVE=1 uv run pytest -m liveProjektstruktur:
src/grok_web_search_mcp/
server.py # MCP tool surface
client.py # Responses API client + image helpers
config.py # Environment settings
tests/Roadmap
Ein einziges schlankes
web_search-MCP-ToolUpstream-
web_searchundx_searchstandardmäßig aktivierenX-Handle-/Datumsfilter und Bild-/Video-Verständnis
Unterstützung für benutzerdefinierte
base_url/ ProxyDomain-Allow-/Deny-Filter
Optionale multimodale Bildeingabe
Installation / Ausführung von GitHub über
uvxProtokollfehler, Wiederholungen, Timeout-/Reasoning-Standardwerte
Lokales Image-Jail (standardmäßig deaktiviert)
Kanonischer MCP-Aufrufvertrag (
query/scope/recency/images)Optionale Streamable-HTTP-Transport-Dokumentation/-Beispiele
Golden-Set-Evaluations-Harness für die Suchqualität
Siehe die offenen Issues.
Mitwirken
Beiträge sind willkommen.
Forke das Projekt
Erstelle deinen Feature-Branch (
git checkout -b feature/AmazingFeature)Commite deine Änderungen (
git commit -m 'Add some AmazingFeature')Pushe den Branch (
git push origin feature/AmazingFeature)Öffne einen Pull Request
Bitte halte die Tool-Oberfläche schlank: Bevorzuge ein gut dokumentiertes Tool gegenüber vielen dünnen Wrappern.
Lizenz
Verteilt unter der MIT-Lizenz. Siehe LICENSE für weitere Informationen.
Danksagungen
Available Tools
1 toolweb_searchA
Live web and X search via Grok. Returns ok, text (answer), citations (URL list). Optional images: public URL, data:image/...;base64,..., or local file path (max 5) to ask about a picture while searching. Supports web domain filters, X handle/date filters, and reasoning_effort (low/medium/high). Image understanding applies to browsed pages and X posts; video understanding applies to X posts only.
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | Optional model override (default from GROK_MODEL / grok-4.5). | |
| query | Yes | Natural-language search question or topic. | |
| images | No | Optional image input(s) for visual questions: URL / data-URI / local path (comma or newline separated, max 5). Not an image-search API. | |
| to_date | No | Optional inclusive X search end date (YYYY-MM-DD). | |
| from_date | No | Optional inclusive X search start date (YYYY-MM-DD). | |
| image_detail | No | Vision detail for input images: low | high | auto (default high). | |
| system_prompt | No | Optional system instruction prepended to the request. | |
| allowed_domains | No | Optional comma-separated allowlist (max 5). Mutually exclusive with excluded_domains. | |
| excluded_domains | No | Optional comma-separated denylist (max 5). | |
| reasoning_effort | No | Optional thinking length for reasoning models: low | medium | high. | |
| allowed_x_handles | No | Optional comma-separated X handle allowlist (max 20). Mutually exclusive with excluded_x_handles. | |
| excluded_x_handles | No | Optional comma-separated X handle denylist (max 20). | |
| enable_image_understanding | No | Analyze images found on browsed pages and X posts (default on). | |
| enable_video_understanding | No | Analyze videos found in X posts (default off). |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries full burden. It discloses return format, image handling constraints (max 5, types), and scoping of image/video understanding. It lacks explicit mention of read-only nature but is otherwise transparent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise (6 sentences), front-loaded with core purpose, and every sentence adds meaningful information without redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (14 parameters, optional features) and the presence of an output schema, the description covers most behavioral aspects. Minor gaps exist (e.g., rate limits, indexing scope), but overall it is thorough.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, so baseline is 3. The description adds value by summarizing key parameters (domain filters, reasoning_effort) and clarifying behavior of image/video understanding fields, which are not detailed in schema descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it performs 'Live web and X search via Grok' and details return values. It uses a specific verb (search) and resource (web and X), and the purpose is unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
While no sibling tools exist for comparison, the description provides clear context on features and filters, sufficiently guiding usage. It could benefit from explicit when-not-to-use, but the absence of alternatives makes this less critical.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
1 tool update
v0.1.0- First observed
web_search
TDQS
Only one tool exists, so there is no possibility of confusion or overlap with other tools.
With a single tool, naming consistency is inherently perfect as there is no pattern to break.
A single tool is slightly minimal but reasonably scoped for a focused web search server, as the tool itself is comprehensive.
The tool covers web search, X search, image understanding, domain and date filters, and reasoning effort, leaving no obvious gaps for its stated purpose.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Live AI-native web search with citations. One tool for every MCP client. Flat per-request pricing.
Docs: https://docs.keenable.ai/mcp-server Keenable is a free, remote MCP server that gives agents access to the web index. Search the web with ranked results and date/site filters, then fetch any indexed page as clean markdown. Works out of the box with no account or API key.
Scrape, crawl and search the web for AI agents via MCP.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that provides real-time web search and X (Twitter) search capabilities via the xAI API.228MIT
- AlicenseNot gradedqualityCmaintenanceA Model Context Protocol server that exposes powerful web search and scraping tools to AI agents and MCP-compatible clients.Apache 2.0
- AlicenseAqualityBmaintenanceMCP server for live X/Twitter and web search, driven by your locally logged-in Grok CLI and leveraging your X Premium or SuperGrok subscription quota.31MIT
- FlicenseNot gradedqualityCmaintenanceMCP server providing web search, news search, and X/Twitter search capabilities via HTTP or stdio.-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/NakanoSanku/grok-web-search-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server