### Local Development Setup Source: https://context7.com/kagisearch/kagimcp/llms.txt Commands for cloning the repository, setting up a virtual environment, installing dependencies, and launching the Kagi MCP server for local development and debugging. ```bash # Clone and install git clone https://github.com/kagisearch/kagimcp.git && cd kagimcp uv venv && source .venv/bin/activate uv sync # Install into Claude Desktop via MCP CLI mcp install src/kagimcp/server.py -v "KAGI_API_KEY=YOUR_KEY_HERE" # Launch the MCP Inspector UI at http://localhost:5173 mcp dev src/kagimcp/server.py # OR without mcp[cli]: npx @modelcontextprotocol/inspector uv --directory . run kagimcp ``` -------------------------------- ### Debug Local Kagi MCP Server with MCP CLI Source: https://github.com/kagisearch/kagimcp/blob/main/README.md Starts the Kagi MCP server in development mode using the MCP CLI for debugging. This command requires the MCP CLI to be installed (`pip install mcp[cli]`) and the path to your `server.py` file. ```bash # If mcp cli installed (`pip install mcp[cli]`) mcp dev /ABSOLUTE/PATH/TO/PARENT/FOLDER/kagimcp/src/kagimcp/server.py ``` -------------------------------- ### Smithery CLI Install Source: https://context7.com/kagisearch/kagimcp/llms.txt Installs the Kagi MCP server for Claude Desktop using the Smithery CLI. ```bash npx -y @smithery/cli install kagimcp --client claude ``` -------------------------------- ### Install Kagi MCP Server via MCP CLI SDK Source: https://github.com/kagisearch/kagimcp/blob/main/README.md Installs the Kagi MCP server using the MCP CLI SDK. Ensure you have installed the SDK (`pip install mcp[cli]`) and replace `API_KEY_HERE` with your actual Kagi API key. The path should point to the `server.py` file within your cloned repository. ```bash # `pip install mcp[cli]` if you haven't mcp install /ABSOLUTE/PATH/TO/PARENT/FOLDER/kagimcp/src/kagimcp/server.py -v "KAGI_API_KEY=API_KEY_HERE" ``` -------------------------------- ### Install uv on Windows Source: https://github.com/kagisearch/kagimcp/blob/main/README.md Installs the uv package manager on Windows systems using PowerShell. This is a prerequisite for installing Kagi MCP server dependencies. ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Install MCP Server Dependencies Source: https://github.com/kagisearch/kagimcp/blob/main/README.md Installs all necessary Python dependencies for the Kagi MCP server using `uv sync` after activating the virtual environment. ```bash uv sync ``` -------------------------------- ### Install uv on MacOS/Linux Source: https://github.com/kagisearch/kagimcp/blob/main/README.md Installs the uv package manager on MacOS and Linux systems. This is a prerequisite for installing Kagi MCP server dependencies. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Programmatic Server Start Source: https://context7.com/kagisearch/kagimcp/llms.txt Starts the FastMCP server programmatically using Python. Ensure sys.argv is set before calling main(). ```python from kagimcp.server import main import sys sys.argv = ["kagimcp", "--http", "--host", "127.0.0.1", "--port", "9000"] main() # Starts FastMCP server on http://127.0.0.1:9000 with streamable HTTP transport ``` -------------------------------- ### Debug Local Kagi MCP Server with Inspector (No MCP CLI) Source: https://github.com/kagisearch/kagimcp/blob/main/README.md Starts the Kagi MCP server for debugging using the Model Context Protocol Inspector when the MCP CLI is not installed. This command requires specifying the directory and the `run` command for `kagimcp`. ```bash # If not npx @modelcontextprotocol/inspector \ uv \ --directory /ABSOLUTE/PATH/TO/PARENT/FOLDER/kagimcp \ run \ kagimcp ``` -------------------------------- ### Kagi MCP Server Entry Point: main() Source: https://context7.com/kagisearch/kagimcp/llms.txt Shows how to launch the Kagi MCP Server. It supports both default stdio mode for desktop clients and streamable HTTP mode for containerized or remote deployments, with configurable host and port for HTTP. ```python # stdio mode (default — used by Claude Desktop, Claude Code, Codex CLI) # Launched automatically when the package is run: # uvx kagimcp # uv run kagimcp # Streamable HTTP mode (for Docker / remote access) # kagimcp --http --host 0.0.0.0 --port 8000 ``` -------------------------------- ### Manual Claude Desktop MCP Server Configuration (Local Dev) Source: https://github.com/kagisearch/kagimcp/blob/main/README.md Manual JSON configuration for Claude Desktop to use a locally developed Kagi MCP server. This requires specifying the absolute path to your cloned repository and replacing placeholders with your actual API key and desired engine. The location of this file can be found in Claude Desktop's settings. ```json # claude_desktop_config.json # Can find location through: # Hamburger Menu -> File -> Settings -> Developer -> Edit Config { "mcpServers": { "kagi": { "command": "uv", "args": [ "--directory", "/ABSOLUTE/PATH/TO/PARENT/FOLDER/kagimcp", "run", "kagimcp" ], "env": { "KAGI_API_KEY": "YOUR_API_KEY_HERE", "KAGI_SUMMARIZER_ENGINE": "YOUR_ENGINE_CHOICE_HERE" // Defaults to "cecil" engine if env var not present } } } } ``` -------------------------------- ### MCP Tool Usage: kagi_search_fetch Source: https://context7.com/kagisearch/kagimcp/llms.txt Illustrates how the `kagi_search_fetch` MCP tool is invoked by an AI assistant for parallel web searches. Shows the expected tool call format and a sample of the formatted output. ```text # Via the MCP tool (as invoked by an AI assistant) # The tool accepts a list of queries and fans them out concurrently: # # Tool call: # kagi_search_fetch(queries=["time person of the year 2024", "kagi search api docs"]) # # Example formatted output: # ----- # Results for search query "time person of the year 2024": # ----- # 1: TIME Person of the Year 2024 # https://time.com/person-of-the-year/2024/ # Published Date: 2024-12-11 # TIME has named Elon Musk as its 2024 Person of the Year... # # ----- # Results for search query "kagi search api docs": # ----- # 2: Kagi Search API – Kagi Help Center # https://help.kagi.com/kagi/api/search.html # Published Date: Not Available # Documentation for the Kagi Search API... ``` -------------------------------- ### MCP Tool Usage: kagi_summarizer Source: https://context7.com/kagisearch/kagimcp/llms.txt Demonstrates the invocation of the `kagi_summarizer` MCP tool by an AI assistant. Shows the tool call format for summarizing a URL and specifies the desired output type and language. ```text # Via the MCP tool (as invoked by an AI assistant) # # Tool call: # kagi_summarizer( # url="https://arxiv.org/abs/2303.08774", # summary_type="summary", # target_language="EN" # ) # # Returns a prose paragraph summary of the GPT-4 technical report. ``` -------------------------------- ### Direct Python Usage: Kagi Search API Source: https://context7.com/kagisearch/kagimcp/llms.txt Demonstrates how to use the KagiClient to perform web searches directly in Python. Requires setting the KAGI_API_KEY environment variable. Handles single queries and processes results to extract relevant information. ```python # Direct Python usage (e.g., in a test or custom MCP client) import os from kagiapi import KagiClient os.environ["KAGI_API_KEY"] = "your_api_key_here" client = KagiClient() # Single query response = client.search("Python async best practices 2024") results = [r for r in response["data"] if r["t"] == 0] for i, r in enumerate(results, 1): print(f"{i}: {r.get('title')}") print(f" {r.get('url')}") print(f" {r.get('snippet', '')[:120]}") ``` -------------------------------- ### Docker Deployment Source: https://context7.com/kagisearch/kagimcp/llms.txt Dockerfile for building and running the Kagi MCP server with streamable HTTP transport. Exposes port 8000 and sets necessary environment variables. ```dockerfile # Build and run the server on port 8000 # docker build -t kagimcp . # docker run -e KAGI_API_KEY=your_key -p 8000:8000 kagimcp --http FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim WORKDIR /app COPY . /app RUN uv sync --frozen --no-dev --no-editable ENV PATH="/app/.venv/bin:$PATH" ENV KAGI_API_KEY=YOUR_API_KEY_HERE ENTRYPOINT ["uv", "run", "kagimcp", "--http", "--host", "0.0.0.0", "--port", "8000"] ``` -------------------------------- ### Claude Desktop Configuration Source: https://context7.com/kagisearch/kagimcp/llms.txt JSON configuration for Claude Desktop to connect to the Kagi MCP server. Set KAGI_API_KEY and other environment variables as needed. ```json { "mcpServers": { "kagi": { "command": "uvx", "args": ["kagimcp"], "env": { "KAGI_API_KEY": "YOUR_API_KEY_HERE", "KAGI_SUMMARIZER_ENGINE": "daphne", "FASTMCP_LOG_LEVEL": "ERROR" } } } } ``` -------------------------------- ### Direct Python Usage: Kagi Summarizer API Source: https://context7.com/kagisearch/kagimcp/llms.txt Shows how to use the KagiClient for summarizing URLs directly in Python. Requires KAGI_API_KEY and allows configuration of the summarization engine, output type, and target language. ```python # Direct Python usage import os from kagiapi import KagiClient os.environ["KAGI_API_KEY"] = "your_api_key_here" client = KagiClient() # Summarize a YouTube video as a bullet-point takeaway list in English response = client.summarize( "https://www.youtube.com/watch?v=jNQXAC9IVRw", engine="cecil", # options: "cecil" | "agnes" | "daphne" | "muriel" summary_type="takeaway", # options: "summary" | "takeaway" target_language="EN", # optional ISO language code; omit for auto-detect ) if error := response.get("error"): raise ValueError(f"Summarizer error: {error}") print(response["data"]["output"]) # • Me at the zoo is the first video uploaded to YouTube (April 23, 2005). # • It features co-founder Jawed Karim at the San Diego Zoo. # • The clip is 18 seconds long and has over 300 million views. ``` -------------------------------- ### Activate Python Virtual Environment (Linux/macOS) Source: https://github.com/kagisearch/kagimcp/blob/main/README.md Activates the Python virtual environment created using `uv venv`. This command should be run after navigating to the project directory. ```bash source .venv/bin/activate ``` -------------------------------- ### OpenAI Codex CLI Integration Source: https://context7.com/kagisearch/kagimcp/llms.txt Command to add the Kagi MCP server to the OpenAI Codex CLI. Configuration is saved to ~/.codex/config.toml. ```bash codex mcp add kagi --env KAGI_API_KEY=YOUR_API_KEY_HERE -- uvx kagimcp ``` -------------------------------- ### Activate Python Virtual Environment (Windows) Source: https://github.com/kagisearch/kagimcp/blob/main/README.md Activates the Python virtual environment created using `uv venv` on Windows. This command should be run after navigating to the project directory. ```bash .venv/Scripts/activate ``` -------------------------------- ### Add Kagi MCP to Codex CLI Source: https://github.com/kagisearch/kagimcp/blob/main/README.md Configures the Codex CLI to use the Kagi MCP server. Replace `` with your actual Kagi API key. This command modifies `~/.codex/config.toml`. ```bash codex mcp add kagi --env KAGI_API_KEY= -- uvx kagimcp ``` -------------------------------- ### Claude Desktop MCP Server Configuration Source: https://github.com/kagisearch/kagimcp/blob/main/README.md JSON configuration for Claude Desktop to recognize and use the Kagi MCP server. Replace placeholders with your actual API key and desired engine. The location of this file can be found in Claude Desktop's settings. ```json // claude_desktop_config.json // Can find location through: // Hamburger Menu -> File -> Settings -> Developer -> Edit Config { "mcpServers": { "kagi": { "command": "uvx", "args": ["kagimcp"], "env": { "KAGI_API_KEY": "YOUR_API_KEY_HERE", "KAGI_SUMMARIZER_ENGINE": "YOUR_ENGINE_CHOICE_HERE" // Defaults to "cecil" engine if env var not present } } } } ``` -------------------------------- ### Debug Kagi MCP Server with Inspector Source: https://github.com/kagisearch/kagimcp/blob/main/README.md Runs the Model Context Protocol (MCP) Inspector to debug the Kagi MCP server. This command helps in diagnosing issues with the server's operation. ```bash npx @modelcontextprotocol/inspector uvx kagimcp ``` -------------------------------- ### Add Kagi MCP to Claude Code Source: https://github.com/kagisearch/kagimcp/blob/main/README.md Adds the Kagi MCP server to Claude Code. The `KAGI_SUMMARIZER_ENGINE` is optional. Replace placeholders with your actual API key and desired engine. ```bash claude mcp add kagi -e KAGI_API_KEY="YOUR_API_KEY_HERE" KAGI_SUMMARIZER_ENGINE="YOUR_ENGINE_CHOICE_HERE" -- uvx kagimcp ``` -------------------------------- ### Clone Kagi MCP Repository Source: https://github.com/kagisearch/kagimcp/blob/main/README.md Clones the Kagi MCP project repository from GitHub to your local machine for development or inspection. ```git git clone https://github.com/kagisearch/kagimcp.git ``` -------------------------------- ### Claude Code CLI Integration Source: https://context7.com/kagisearch/kagimcp/llms.txt Command to add the Kagi MCP server to Claude Code via CLI. Optionally, disable Claude Code's web search to prevent conflicts. ```bash # Add Kagi MCP server to Claude Code claude mcp add kagi \ -e KAGI_API_KEY="YOUR_API_KEY_HERE" \ -e KAGI_SUMMARIZER_ENGINE="daphne" \ -- uvx kagimcp # Disable Claude Code's built-in web search to avoid conflicts # Add to ~/.claude/settings.json: # { "permissions": { "deny": ["WebSearch"] } } ``` -------------------------------- ### Disable Claude Code Web Search Source: https://github.com/kagisearch/kagimcp/blob/main/README.md JSON configuration to disable Claude Code's default web search functionality, preventing conflicts with Kagi's search capabilities. This should be added to your `~/.claude/settings.json` file. ```json { "permissions": { "deny": [ "WebSearch" ] } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.