Skip to main content
Glama
kagi-mcp

kagi-mcp

by real-jiakai

kagi-mcp

English | 简体中文

MCP server for Kagi Search that authenticates with your session token — no separate API subscription needed, it uses your existing Kagi plan via Kagi's lightweight HTML interface (kagi.com/html/search).

Tools

Tool

Purpose

Parameters

kagi_search

Web search

query (required), page, from_date, to_date, region, lens, limit

kagi_news

News search

query (required), limit

kagi_lenses

List available lenses

—

  • region: 2-letter country code (us, cn, jp, ...); maps to Kagi's r= parameter. Defaults to no_region (international/location-neutral) so the AI agent decides when a country-specific view is needed.

  • lens: a Kagi lens by name or numeric id (e.g. Forums, Fediverse Forums, Academic, Programming, PDFs). Names are resolved against the lens list on your account (cached per server process — restart the server after creating new lenses).

Queries support Kagi operators: "exact phrase", site:example.com, -exclude, OR. Output is compact plain text (title, URL, date, snippet, related searches). By default a call returns the full first results page — the same set a user sees on kagi.com (typically 20-40 results); pass limit to trim it. Snippets are Kagi's own SERP snippets; fetching full page content is left to the agent's page-fetch tool.

Related MCP server: Kagi MCP Server

1. Get your session token

  1. Open kagi.com/settings/user_details

  2. Find the Session Link section and copy the link.

  3. Use either the full link (https://kagi.com/search?token=...) or just the token part — both work as KAGI_SESSION_TOKEN.

Treat the session link like a password — anyone with it can use your Kagi account. If it leaks, generate a new one from the same settings page (this invalidates the old one).

2. Add it to your AI agent

All examples run the published npm package via npx — nothing to install up front (requires Node.js 18+; latest LTS recommended).

Claude Code

claude mcp add kagi -s user --env KAGI_SESSION_TOKEN=<token> -- npx -y kagi-mcp-claude-fable-5

(-s user makes the server available in all your projects; omit it for project-local.)

Codex CLI

codex mcp add kagi --env KAGI_SESSION_TOKEN=<token> -- npx -y kagi-mcp-claude-fable-5

Or add a table to ~/.codex/config.toml directly:

[mcp_servers.kagi]
command = "npx"
args = ["-y", "kagi-mcp-claude-fable-5"]
env = { "KAGI_SESSION_TOKEN" = "<token or session link>" }

(On Windows, if the server fails to spawn, set command to the full path of npx.cmd, e.g. 'C:\Program Files\nodejs\npx.cmd'.)

OpenClaw

openclaw mcp add kagi \
  --command npx \
  --arg -y \
  --arg kagi-mcp-claude-fable-5 \
  --env KAGI_SESSION_TOKEN=<token>

Verify with openclaw mcp doctor kagi --probe.

Hermes Agent

Add to ~/.hermes/config.yaml under mcp_servers:

mcp_servers:
  kagi:
    command: "npx"
    args: ["-y", "kagi-mcp-claude-fable-5"]
    env:
      KAGI_SESSION_TOKEN: "<token or session link>"

Any MCP client (Claude Desktop, ...) — JSON config

{
  "mcpServers": {
    "kagi": {
      "command": "npx",
      "args": ["-y", "kagi-mcp-claude-fable-5"],
      "env": { "KAGI_SESSION_TOKEN": "<token or session link>" }
    }
  }
}

Development

git clone https://github.com/real-jiakai/kagi-mcp-claude-fable-5.git kagi-mcp
cd kagi-mcp
npm install    # TypeScript build to dist/ runs automatically

# smoke test against your real Kagi account (append `news` for the news vertical)
KAGI_SESSION_TOKEN='<token or session link>' node test.js "capital of japan"

To point a client at your checkout instead of npm, use node /path/to/kagi-mcp/dist/index.js as the command; re-run npm run build after editing src/.

Notes

  • Auth failures: if the token is invalid/expired, Kagi 302-redirects to its landing page; the server detects this and returns a clear error telling you to refresh the token.

  • Parsing: results are extracted via Kagi's own machine-readable markers (._0_SRI, a._0_URL, ._0_TITLE, ._0_DESC), which are stable across the web and news verticals (verified July 2026). If Kagi ever changes its markup, update parseResultsPage() in src/kagi.ts.

  • This uses your normal Kagi account the same way a browser would — standard fair-use search volume from an agent is indistinguishable from regular usage. It is not the official Kagi Search API (which bills separately).

Acknowledgements

Designed, implemented, and tested end-to-end with Claude Fable 5 via Claude Code — including live analysis of Kagi's HTML interface, an adversarial multi-agent code review, and human-click vs. MCP parity testing in the browser.

Available Tools

3 tools
kagi_lensesList Kagi lensesA

List the Kagi lenses (curated search scopes such as Forums, Academic, Programming) available on this account, with their ids. Pass a lens name or id to kagi_search's lens parameter.

Inputs: no named parameters.

kagi_newsKagi news searchA

Search recent news with Kagi. Returns headlines with source, publication time and snippets. Best for current events; use kagi_search for general web results.

Inputs: query (required), limit.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: kagi_lenses lists curated search scopes, kagi_news searches recent news, and kagi_search performs general web searches. Descriptions explicitly differentiate use cases.

    Naming Consistency5/5

    All tools follow a consistent kagi_<service> pattern, using clear nouns/verbs that reflect the tool's function. No deviations or mixed conventions.

    Tool Count5/5

    Three tools is appropriate for a focused search server, covering lens listing, news search, and general search without unnecessary bloat or gaps.

    Completeness5/5

    The surface covers the core functionality of the Kagi search API: discovering lenses, searching news, and general web search. No obvious missing operations for the stated purpose.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Unofficial MCP server for working with Kagi without API access (you'll need to be a customer, tho). Searches and summarizes. Uses Kagi session token for easy authentication.
      2
      42
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables integration with Kagi search engine services including web search, content summarization from URLs, and AI assistant conversations. Uses session tokens to access Kagi's search API, summarizer, and AI models directly within MCP-compatible applications.
      14 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Free web search MCP server using SearXNG, supporting web search, news search, and search summaries.
      MIT