Kagi MCP Server

repository·main·Indexed 19 days ago

https://github.com/kagisearch/kagimcp

A Model Context Protocol (MCP) server that provides search and web extraction capabilities to LLM clients via the Kagi API. It features two primary tools: kagi_search_fetch for performing web, news, video, podcast, and image searches, and kagi_extract for fetching full URL content as markdown. The server supports both local installation via uvx and hosted deployment via HTTP or Docker.

Tokens
5.6K
Snippets
24
Records
35
Agent score
65%

What's inside kagimcp

  1. What tools does the Kagi MCP Server provide?

    main

    The Kagi MCP Server exposes two primary tools to MCP-compatible clients via the Kagi API:

    • kagi_search_fetch: Performs web, news, videos, podcasts, and image searches. It supports optional page extracts, filters, and Kagi lenses.
    • kagi_extract: Fetches the full content of a specific URL and returns it as markdown.

    Note: kagi_fastgpt and kagi_summarizer tools have been removed and are planned for future releases.

  2. Install Kagi MCP Server via uvx (Local Setup)

    main

    For local installation, it is recommended to use uv. First, ensure uv is installed on your system:

    MacOS/Linux:

    curl -LsSf https://astral.sh/uv/install.sh | sh

    Windows:

    powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

    Once uv is installed, you can use uvx kagimcp as the command for various MCP clients.

  3. Use the Kagi Hosted MCP Server

    main

    You can use Kagi's hosted MCP server without installing anything locally. Point your HTTP-capable MCP client to https://mcp.kagi.com/mcp and authenticate using your Kagi API key via Bearer HTTP authentication.

    Example for Claude Code:

    claude mcp add kagi https://mcp.kagi.com/mcp --transport http --header "Authorization: Bearer $(read -sp 'API key: ' k; echo $k)" --scope user
  4. Self-Hosting the Kagi MCP Server via Docker

    main

    The server can be self-hosted in HTTP mode. In this mode, it is multi-tenant: each request must supply its API key via the Authorization: Bearer <key> header. The provided Dockerfile allows you to run a pinned version of kagimcp from PyPI. The container respects the $PORT environment variable.

    Build and run locally:

    docker build -t kagimcp-hosted .
    docker run --rm -p 8000:8000 kagimcp-hosted

    Smoke test the running server:

    curl -sL http://127.0.0.1:8000/mcp -X POST \
      -H "authorization: Bearer $KAGI_API_KEY" \
      -H "content-type: application/json" \
      -H "accept: application/json, text/event-stream" \
      -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
  5. Configure Kagi MCP for OpenCode

    main

    Edit your OpenCode configuration file at ~/.config/opencode/opencode.json and add the kagi entry:

    {
      "mcp": {
        "kagi": {
          "type": "local",
          "command": ["uvx", "kagimcp"],
          "enabled": true,
          "environment": {
            "KAGI_API_KEY": "<YOUR_API_KEY_HERE>"
          }
        }
      }
    }
  6. Configure Kagi MCP for Claude Desktop

    main

    To use Kagi with Claude Desktop, add the following configuration to your Claude Desktop config file (accessible via Settings -> Developer -> Edit Config):

    {
      "mcpServers": {
        "kagi": {
          "command": "uvx",
          "args": ["kagimcp"],
          "env": {
            "KAGI_API_KEY": "YOUR_API_KEY_HERE"
          }
        }
      }
    }
  7. Configure Kagi MCP for Kiro

    main

    Add Kagi to your Kiro MCP config file (~/.kiro/settings/mcp.json for global, or .kiro/settings/mcp.json for project-scoped). Use the same JSON structure as the Claude Desktop configuration:

    {
      "mcpServers": {
        "kagi": {
          "command": "uvx",
          "args": ["kagimcp"],
          "env": {
            "KAGI_API_KEY": "YOUR_API_KEY_HERE"
          }
        }
      }
    }
  8. Add Kagi MCP to Claude Code

    main

    You can integrate the hosted Kagi MCP server into Claude Code using the claude mcp add command. You will need an API key from your Kagi API Dashboard. The server uses Bearer HTTP authentication.

    Run the following command to set it up:

    claude mcp add kagi https://mcp.kagi.com/mcp --transport http --header "Authorization: Bearer $(read -sp 'API key: ' k; echo $k)" --scope user
  9. Debug Kagi MCP Server with MCP Inspector

    main

    You can inspect the server using the Model Context Protocol Inspector.

    To inspect the published package:

    npx @modelcontextprotocol/inspector uvx kagimcp

    To inspect a local checkout:

    npx @modelcontextprotocol/inspector uv --directory /ABSOLUTE/PATH/TO/kagimcp run kagimcp

    The inspector is typically available at http://localhost:5173.