๐ kagi-ken-mcp
A lightweight Node MCP server around the kagi-ken package, enabling access to Kagi.com services via Kagi session tokens.
This server offers seamless access to Kagi.com services using your Kagi session tokens. It provides two core functions:
- Search: Conduct searches on Kagi.
- Summarizer: Utilize Kagi's Summarizer to generate summaries from URLs or text content.
Unlike the official Kagi API that demands API access, this MCP server leverages your existing Kagi session to access both search and summarization features.
The term "Kagi-ken" is a blend of "Kagi" (the service) and "token".
๐ Quick Start
Pose queries that require the use of a tool. For example, ask "Who was time's 2024 person of the year?" for a search, or "summarize this video: https://www.youtube.com/watch?v=sczwaYyaevY" for the summarizer.
โจ Features
- Search: Retrieve web results through Kagi Search with concurrent query processing.
- Summarization: Summarize content from URLs, with customizable output types and languages.
The server supports two ways to use your Kagi session token (see Installation), in the following order:
KAGI_SESSION_TOKEN environment variable.
~/.kagi_session_token file containing the token string.
It also includes comprehensive error handling:
- Connection timeouts (10 seconds per search).
- Invalid input validation.
- Environment variable validation.
- Graceful error formatting.
๐ฆ Installation
Node.js 22+ is required.
1. Get Kagi Session Token
- Visit Kagi Settings in your browser.
- Copy the Session Link.
- Extract the
token value from the link.
- Use that value as your session token: save it to
~/.kagi_session_token (recommended), or pass it as the KAGI_SESSION_TOKEN environment variable.
The server will first attempt to use the environment variable and then fall back to the token file.
โ ๏ธ Important Note
Keep your session token private as it provides access to your Kagi account.
2.a. Add MCP server to Claude Desktop
Add kagi-ken-mcp to your claude_desktop_config.json, which you can open from the Claude Desktop app via Settings โ Developer โ Local MCP Servers โ Edit Config.
Option 1: Using token file (recommended)
{
"mcpServers": {
"kagi-ken-mcp": {
"command": "npx",
"args": ["-y", "github:czottmann/kagi-ken-mcp"]
}
}
}
Option 2: Using environment variable
{
"mcpServers": {
"kagi-ken-mcp": {
"command": "npx",
"args": ["-y", "github:czottmann/kagi-ken-mcp"],
"env": {
"KAGI_SESSION_TOKEN": "YOUR_SESSION_TOKEN_HERE"
}
}
}
}
Post-install
Disable Claude Desktop's built-in websearch so that it uses this MCP server. You may also add the following to your "Personal preferences" (i.e., system prompt) in Settings:
For web searches, use kagi-ken-mcp MCP server's `kagi_search_fetch` tool.
For summarizing a URL, use the kagi-ken-mcp MCP server's `kagi_summarizer` tool.
2.b. Add MCP server to Claude Code
Option 1: Using token file (recommended)
claude mcp add kagi-ken-mcp --scope user -- npx -y github:czottmann/kagi-ken-mcp
Option 2: Using environment variable
claude mcp add kagi-ken-mcp \
--scope user \
--env KAGI_SESSION_TOKEN="YOUR_SESSION_TOKEN_HERE" -- \
npx -y github:czottmann/kagi-ken-mcp
Post-install
Disable Claude Code's built-in web search (optional) by setting the permission in the relevant .claude/settings*.json file:
{
"permissions": {
"deny": [
"WebSearch"
],
"allow": [
"mcp__kagi-ken-mcp__kagi_search_fetch",
"mcp__kagi-ken-mcp__kagi_summarizer"
]
}
}
๐ป Usage Examples
Basic Usage
Pose queries to the server, such as "Who was time's 2024 person of the year?" for search or "summarize this video: https://www.youtube.com/watch?v=sczwaYyaevY" for the summarizer.
๐ Documentation
Tools
kagi_search_fetch
Fetch web results based on one or more queries using the Kagi Search API. Results are numbered continuously for easy reference.
Parameters:
queries (array of strings): One or more search queries.
kagi_summarizer
Summarize content from URLs using the Kagi Summarizer API. Supports various document types including webpages, videos, and audio.
Parameters:
url (string): URL to summarize.
summary_type (enum): "summary" for paragraph prose or "takeaway" for bullet points (default: "summary").
target_language (string, optional): Language code (e.g., "EN" for English, default: "EN").
๐ง Technical Details
Project Structure
kagi-ken-mcp/
โโโ src/
โ โโโ index.js # Main server entry point
โ โโโ tools/
โ โ โโโ search.js # Search tool implementation
โ โ โโโ summarizer.js # Summarizer tool implementation
โ โโโ utils/
โ โโโ formatting.js # Utility functions
โโโ package.json
โโโ README.md
Installation
-
Clone the repository:
git clone <repository-url>
cd kagi-ken-mcp
-
Install dependencies:
npm install
Running in Development Mode
npm run dev
Debugging
Use the MCP Inspector to debug:
npx @modelcontextprotocol/inspector node ./src/index.js
Then access the inspector at http://localhost:5173. If using environment variables, add your KAGI_SESSION_TOKEN in the environment variables section of the inspector.
Contributing
- Fork the repository.
- Create a feature branch.
- Make your changes.
- Test with the MCP Inspector.
- Submit a pull request.
๐ License
This project is neither affiliated with nor endorsed by Kagi.
Author
Carlo Zottmann, carlo@zottmann.dev, https://c.zottmann.dev, https://github.com/czottmann.
๐ก Usage Tip
I develop Shortcuts-related macOS & iOS productivity apps like Actions For Obsidian, Browser Actions (which adds Shortcuts support for several major browsers), and BarCuts (a surprisingly useful contextual Shortcuts launcher). Check them out!
Related Projects