Grok Search MCP

repository·main·Indexed 21 days ago

https://github.com/gudastudio/groksearch

An MCP server built on FastMCP that provides LLM clients, such as Claude Code and Cherry Studio, with advanced web access. It uses a dual-engine architecture combining Grok for AI-driven search with Tavily and Firecrawl for high-fidelity web scraping and site mapping. Key tools include web_search for AI queries, get_sources for metadata retrieval, web_fetch for Markdown content extraction, and web_map for website structure traversal.

Tokens
6.3K
Snippets
5
Records
48
Agent score
83%

What's inside grok-search

  1. Install Grok Search MCP via Claude Code

    main

    To install the Grok Search MCP server, you must have Python 3.10+, uv installed, and Claude Code.

    First, if you have an older version installed, remove it using:

    claude mcp remove grok-search

    Then, add the MCP server using the claude mcp add-json command. You must replace the placeholder environment variables with your actual credentials. The Grok API must be in an OpenAI-compatible format. Tavily configuration is optional; if omitted, web_fetch and web_map tools will be unavailable.

    If you encounter SSL/certificate verification errors in enterprise or proxy environments, add the --native-tls flag to the args array in the JSON configuration.

    claude mcp add-json grok-search --scope user '{
      "type": "stdio",
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/GuDaStudio/GrokSearch@grok-with-tavily",
        "grok-search"
      ],
      "env": {
        "GROK_API_URL": "https://your-api-endpoint.com/v1",
        "GROK_API_KEY": "your-grok-api-key",
        "TAVILY_API_KEY": "tvly-your-tavily-key",
        "TAVILY_API_URL": "https://api.tavily.com"
      }
    }'
  2. Disable Claude Code's built-in WebSearch and WebFetch

    main

    To ensure Claude Code uses the Grok Search MCP instead of its own built-in web tools, you can use the toggle_builtin_tools tool. This modifies the project-level .claude/settings.json permissions.deny settings.

    In a Claude conversation, type: Call grok-search toggle_builtin_tools to disable Claude Code's built-in WebSearch and WebFetch tools

  3. Install Grok Search MCP via Claude CLI

    main

    To install Grok Search MCP, use the claude mcp add-json command. You can choose between a simplified setup using a GuDa API key or a custom configuration using your own API endpoints.

    Prerequisites:

    • Python 3.10+
    • uv (recommended)
    • Claude Code

    Note for Windows users: It is strongly recommended to run this project in WSL.

    #### GuDa Users (Recommended)
    ```bash
    claude mcp add-json grok-search --scope user '{
      "type": "stdio",
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/GuDaStudio/GrokSearch@grok-with-tavily",
        "grok-search"
      ],
      "env": {
        "GUDA_API_KEY": "your-guda-api-key"
      }
    }'

    Custom Configuration

    claude mcp add-json grok-search --scope user '{
      "type": "stdio",
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/GuDaStudio/GrokSearch@grok-with-tavily",
        "grok-search"
      ],
      "env": {
        "GROK_API_URL": "https://your-api-endpoint.com/v1",
        "GROK_API_KEY": "your-grok-api-key",
        "TAVILY_API_KEY": "tvly-your-tavily-key",
        "TAVILY_API_URL": "https://api.tavily.com"
      }
    }'
  4. Configure Grok Search MCP environment variables

    main

    The following environment variables can be used to configure the Grok Search MCP server:

    VariableRequiredDefaultDescription
    GROK_API_URL-Grok API address (OpenAI compatible format)
    GROK_API_KEY-Grok API key
    GROK_MODELgrok-4-fastDefault model (overrides ~/.config/grok-search/config.json)
    TAVILY_API_KEY-Tavily API key (used for web_fetch / web_map)
    TAVILY_API_URLhttps://api.tavily.comTavily API address
    TAVILY_ENABLEDtrueWhether to enable Tavily
    FIRECRAWL_API_KEY-Firecrawl API key (fallback for Tavily)
    FIRECRAWL_API_URLhttps://api.firecrawl.dev/v2Firecrawl API address
    GROK_DEBUGfalseDebug mode
    GROK_LOG_LEVELINFOLog level
    GROK_LOG_DIRlogsLog directory
    GROK_RETRY_MAX_ATTEMPTS3Maximum retry attempts
    GROK_RETRY_MULTIPLIER1Retry backoff multiplier
    GROK_RETRY_MAX_WAIT10Maximum retry wait in seconds
  5. How the search planning workflow works

    main

    Grok Search implements a multi-phase planning engine to handle complex queries. Instead of a single search, it breaks down intent into a structured execution plan.

    The Required Workflow:

    1. plan_intent: Analyze the core question and create a session_id.
    2. plan_complexity: Assess if the search is Level 1, 2, or 3 complexity.
    3. plan_sub_query: Decompose the main question into specific sub-goals.
    4. plan_search_term: Define specific search queries for each sub-query.
    5. plan_tool_mapping: Decide which tool (web_search, web_fetch, or web_map) to use for each sub-query.
    6. plan_execution: Define the order (parallel or sequential) in which tools are called.

    This structured approach ensures high-quality, deep research by managing dependencies and execution strategies.

  6. Configure GrokSearch via MCP (Claude Desktop)

    main

    To use GrokSearch as a Model Context Protocol (MCP) server in Claude Desktop, you must configure the required environment variables. Use the following command to add the server to your Claude configuration. Replace your-api-url and your-api-key with your actual Grok API credentials.

    Note: The GROK_API_URL and GROK_API_KEY environment variables are mandatory for the server to function.

  7. Other Grok Search MCP tools

    main

    In addition to search and extraction, the server provides several utility tools:

    • get_config_info: Displays configuration status, tests Grok API connection, and lists available models.
    • switch_model: Changes the active Grok model. Settings are persisted to ~/.config/grok-search/config.json.
    • toggle_builtin_tools: Controls whether Claude Code's native web tools are disabled or enabled via action ("on", "off", or "status").
    • search_planning: Generates a structured multi-phase plan for complex searches.
  8. Manage tool routing with `toggle_builtin_tools`

    main

    To prevent Claude Code from using its own built-in WebSearch and WebFetch tools (which might be less effective than Grok Search), use toggle_builtin_tools. This tool modifies the project-level .claude/settings.json file's permissions.deny section.

    Parameters:

    • action (string, Optional):
      • "on": Disable official Claude tools.
      • "off": Enable official Claude tools.
      • "status": Check current status. Default is "status".
  9. Retrieve search sources with `get_sources`

    main

    To view the specific URLs and metadata used in a previous search, use the get_sources tool. This requires the session_id returned by the web_search tool.

    Parameters:

    • session_id (string, Required): The session ID from the web_search response.
  10. Map website structure with `web_map`

    main

    The web_map tool uses the Tavily Map API to traverse a website's structure and generate a sitemap of discovered URLs.

    Parameters:

    • url (string, Required): The starting URL.
    • instructions (string, Optional): Natural language instructions to filter results.
    • max_depth (int, Optional): Maximum traversal depth (1-5). Default is 1.
    • max_breadth (int, Optional): Maximum links to follow per page (1-500). Default is 20.
    • limit (int, Optional): Total limit of links to process (1-500). Default is 50.
    • timeout (int, Optional): Timeout in seconds (10-150). Default is 150.
  11. Scrape web content with `web_fetch`

    main

    The web_fetch tool retrieves the full content of a webpage in Markdown format. It uses the Tavily Extract API by default. If Tavily fails, it automatically falls back to Firecrawl Scrape.

    Parameters:

    • url (string, Required): The target webpage URL.