Metadata-Version: 2.4
Name: kagimcp
Version: 1.0.0rc2
Summary: Kagi MCP server
Project-URL: Homepage, https://github.com/kagisearch/kagi-mcp
Project-URL: Issues, https://github.com/kagisearch/kagi-mcp/issues
Author-email: Rehan Ali Rana <rehan@kagi.com>
License-File: LICENSE
Requires-Python: ==3.12.*
Requires-Dist: fastmcp~=3.2
Requires-Dist: httpx~=0.28
Requires-Dist: pydantic~=2.12.5
Requires-Dist: python-dateutil>=2.8.2
Requires-Dist: tenacity~=9.0
Requires-Dist: typing-extensions>=4.7.1
Requires-Dist: urllib3<3.0.0,>=2.1.0
Description-Content-Type: text/markdown

# Kagi MCP server

<a href="https://glama.ai/mcp/servers/xabrrs4bka">
  <img width="380" height="200" src="https://glama.ai/mcp/servers/xabrrs4bka/badge" alt="Kagi Server MCP server" />
</a>

## Tools
The server exposes the following tools, backed by the [Kagi API](https://help.kagi.com/kagi/api/overview.html):

- **`kagi_search_fetch`** — general web search (workflows: `search`, `news`, `videos`, `podcasts`, `images`), with optional inline page extracts, domain include/exclude, date filters, and file-type filter.
- **`kagi_extract`** — fetch the full content of a page as markdown.
- **`kagi_summarizer`** — summarize any URL (text page, video, audio, etc.) as prose or key takeaways.
- **`kagi_fastgpt`** — answer a question with a live web search + LLM synthesis and numbered references.

## Setup Intructions
Install uv first.

MacOS/Linux:
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

Windows:
```
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
```
### Installing via Smithery

Alternatively, you can install Kagi for Claude Desktop via [Smithery](https://smithery.ai/server/kagimcp):

```bash
npx -y @smithery/cli install kagimcp --client claude
```

### Setup with OpenAI
#### Codex CLI
To add the Kagi mcp server to [codex cli](https://developers.openai.com/codex/cli/), you will need to use the following command:

```bash
codex mcp add kagi --env KAGI_API_KEY=<YOUR_API_KEY_HERE> -- uvx kagimcp
```

This will write out the configuration to `~/.codex/config.toml`, so if you need to update/rotate your API key, update your key there before running `codex` again.

Codex CLI comes with its own built-in search (via `--search` flag), but it is disabled by default. So to deconflict between search and Kagi, just don't enable it.

### Setup with Claude
#### Claude Desktop
```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
      }
    }
  }
}
```
#### Claude Code
Add the Kagi mcp server with the following command (setting summarizer engine optional):

```bash
claude mcp add kagi -e KAGI_API_KEY="YOUR_API_KEY_HERE" KAGI_SUMMARIZER_ENGINE="YOUR_ENGINE_CHOICE_HERE" -- uvx kagimcp
```

Now claude code can use the Kagi mcp server. However, claude code comes with its own web search functionality by default, which may conflict with Kagi. You can disable claude's web search functionality with the following in your claude code settings file (`~/.claude/settings.json`):

```json
{
  "permissions": {
    "deny": [
      "WebSearch"
    ]
  }
}
```

### Pose query that requires use of a tool
Examples:
- Search: *"Who was time's 2024 person of the year?"*
- Summarizer: *"summarize this video: https://www.youtube.com/watch?v=jNQXAC9IVRw"*
- Extract: *"extract the full content of https://en.wikipedia.org/wiki/Model_Context_Protocol"*
- FastGPT: *"what's the latest stable Postgres release and when was it cut?"* (returns an answer with citations)

### Debugging
Run:
```bash
npx @modelcontextprotocol/inspector uvx kagimcp
```

## Local/Dev Setup Instructions

### Clone repo
`git clone https://github.com/kagisearch/kagimcp.git`

### Install dependencies
Install uv first.

MacOS/Linux:
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

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

Then install MCP server dependencies:
```bash
cd kagimcp

# Create virtual environment and activate it
uv venv

source .venv/bin/activate # MacOS/Linux
# OR
.venv/Scripts/activate # Windows

# Install dependencies
uv sync
```
### Setup with Claude Desktop

#### Using FastMCP CLI
```bash
# `pip install fastmcp` if you haven't
fastmcp install claude-desktop /ABSOLUTE/PATH/TO/PARENT/FOLDER/kagimcp/src/kagimcp/server.py --env KAGI_API_KEY=API_KEY_HERE
```

#### Manually
```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
      }
    }
  }
}
```

### Pose query that requires use of a tool
Examples:
- Search: *"Who was time's 2024 person of the year?"*
- Summarizer: *"summarize this video: https://www.youtube.com/watch?v=jNQXAC9IVRw"*
- Extract: *"extract the full content of https://en.wikipedia.org/wiki/Model_Context_Protocol"*
- FastGPT: *"what's the latest stable Postgres release and when was it cut?"* (returns an answer with citations)

### Debugging
Run:
```bash
# If fastmcp installed (`pip install fastmcp`)
fastmcp dev inspector /ABSOLUTE/PATH/TO/PARENT/FOLDER/kagimcp/src/kagimcp/server.py

# If not
npx @modelcontextprotocol/inspector \
      uv \
      --directory /ABSOLUTE/PATH/TO/PARENT/FOLDER/kagimcp \
      run \
      kagimcp
```
Then access MCP Inspector at `http://localhost:5173`. You may need to add your Kagi API key in the environment variables in the inspector under `KAGI_API_KEY`.

# Advanced Configuration
- Level of logging is adjustable through the `FASTMCP_LOG_LEVEL` environment variable (e.g. `FASTMCP_LOG_LEVEL="ERROR"`)
  - Relevant issue: https://github.com/kagisearch/kagimcp/issues/4
- Summarizer engine can be customized using the `KAGI_SUMMARIZER_ENGINE` environment variable (e.g. `KAGI_SUMMARIZER_ENGINE="daphne"`)
  - Learn about the different summarization engines [here](https://help.kagi.com/kagi/api/summarizer.html#summarization-engines)
- Per-tool request timeouts (in seconds) can be set via environment variables. Defaults are tuned for typical latency of each endpoint:
  - `KAGI_SEARCH_TIMEOUT` — search requests (default: `10`)
  - `KAGI_EXTRACT_TIMEOUT` — page extraction (default: `30`)
  - `KAGI_SUMMARIZER_TIMEOUT` — summarization, which can be slow on long videos/docs (default: `30`)
  - `KAGI_FASTGPT_TIMEOUT` — FastGPT answers (default: `10`)
- Transient failures (HTTP 429/500/502/503/504, connection errors, timeouts) are retried with exponential backoff + jitter. Configure max retry attempts via `KAGI_MAX_RETRIES` (default: `2`, i.e. 3 total attempts). Set to `0` to disable retries.
- Tool parameters can be hidden from the LLM via the `KAGI_HIDDEN_PARAMS` environment variable (comma-separated list). Hidden params fall back to their defaults, reducing context-window noise when you don't need fine-grained control.
  - Hideable params: `workflow`, `extract_count`, `limit`, `include_domains`, `exclude_domains`, `time_relative`, `after`, `before`, `file_type` (search).
  - Example: `KAGI_HIDDEN_PARAMS="extract_count,after,before,time_relative,include_domains,exclude_domains"` trims the search tool down to `query`, `workflow`, `limit`.
- There may be more secure ways of plugging into the MCP. A user wrote down some details [here](https://github.com/lardinator/kagimcp/blob/main/docs/secure-api-key-storage.md)
- The `--http` cli option can be used to toggle streamable HTTP transport on. Can use along with `--port` and `--host` args.
