agentsclimarketplace

My web search kagi

Skill alexleekt/agents/skills/my-web-search-kagi

AI agent skills and configurations managed by Saddle. Centralized behavioral rules for Claude, OpenCode, Codex, Cursor, Copilot, Gemini, and Pi.

Install
npx -y skills add alexleekt/agents --skill my-web-search-kagi

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

**ALWAYS use when user asks for:** searching the web, looking up information online, finding docs, checking prices, researching a topic, verifying facts. Also use when no dedicated web search MCP server is available. Triggers on phrases like "search the web", "look up", "find online", "google", "kagi search", "web search", "search for", or when current/real-time information is needed. **DO NOT use for:** questions answerable from training data alone, tasks where the user explicitly says "don't search", or when a dedicated MCP search server is available and preferred.

SKILL.md

10.6 KB, as published. Nobody here has run it

Web Search via agent-browser

Perform web searches using browser automation. Kagi is preferred if available, Bing is the fallback that works without authentication.

⚡ Quick Start

Pick the fastest path for your setup:

PathWhen to useOne-time setupSearch command
API (fastest)You have a Kagi API tokenGet token at kagi.com/settings?p=apicurl -H "Authorization: Bot $KAGI_API_KEY" "https://kagi.com/api/v1/search?q=<query>"
Firefox/Zen/LibreWolfBrowser automation, already logged inpython3 ~/.pi/agent/skills/my-web-search-kagi/scripts/sync-kagi-cookies.py --browser zenagent-browser open "https://kagi.com/search?q=<query>" && agent-browser get text
Chromium/Chrome/Arc/Brave/EdgeBrowser automation, already logged inagent-browser open "https://kagi.com" (reuse profile)Same as above
Any (no Kagi login)No auth neededNoneagent-browser open "https://www.bing.com/search?q=<query>" && agent-browser get text

⚠️ Important: CAPTCHA / Login Requirement

Kagi search via browser automation is blocked by Cloudflare Turnstile CAPTCHA unless the browser session has authenticated Kagi cookies.

The API path avoids this entirely. This skill provides four viable paths:


Path 0: API Direct (Fastest — Recommended for Programmatic Use)

If you have a Kagi API token, use the official API directly. It's ~10-50x faster (~100-500ms) than browser automation and returns structured JSON.

Prerequisites

  • Kagi API token from kagi.com/settings?p=api
  • Kagi Search API is now in public preview — all subscribers get $5 free API credits

Quick search with curl

# Set your token
export KAGI_API_KEY="your_token_here"

# Search
curl -H "Authorization: Bot $KAGI_API_KEY" \
  "https://kagi.com/api/v1/search?q=rust+tokio+async+runtime"

Python (official kagiapi package)

pip install kagiapi
from kagiapi import KagiClient
import os

kagi = KagiClient(os.environ["KAGI_API_KEY"])
results = kagi.search("rust tokio async runtime", limit=10)

for result in results["data"]:
    if result['t'] == 0:  # t=0 is search result, t=1 is related searches
        print(f"{result['title']}\n{result['url']}\n")

MCP Server (official kagimcp)

For Claude Desktop, Codex CLI, Cline, or any MCP client:

# Install uv first (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Add to Codex CLI
codex mcp add kagi --env KAGI_API_KEY=<YOUR_API_KEY> -- uvx kagimcp

# Or add to Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json)
{
  "mcpServers": {
    "kagi": {
      "command": "uvx",
      "args": ["kagimcp"],
      "env": {
        "KAGI_API_KEY": "your_token_here"
      }
    }
  }
}

Tools exposed: kagi_search_fetch (web/news/videos/podcasts/images), kagi_extract (page as markdown)

API vs Browser Automation

FactorAPIBrowser Automation
Speed~100-500ms~2-5s
FormatStructured JSONRaw text
AuthAPI tokenBrowser cookies
Cost$25/1,000 queries (2.5¢ each)Free (uses subscription)
Rate limitsYes (see docs)No hard limit
Best for10+ searches/hour, structured dataOccasional searches, no setup

Path 1: Firefox / Zen / LibreWolf / Waterfox users (Recommended for Browser Automation)

If the user uses a Firefox-variant browser and is already logged into Kagi, cookies can be synced into agent-browser automatically.

One-time setup

# Sync Kagi cookies from Zen (or firefox, librewolf, waterfox, floorp)
python3 ~/.pi/agent/skills/my-web-search-kagi/scripts/sync-kagi-cookies.py --browser zen

The script:

  1. Finds the browser's default profile
  2. Extracts Kagi cookies from cookies.sqlite
  3. Injects them into the running agent-browser session via CDP

Search after cookie sync

agent-browser open "https://kagi.com/search?q=rust+tokio+async+runtime" && agent-browser get text

Path 2: Chromium / Chrome / Arc / Brave / Edge users

If the user uses a Chromium-based browser and is logged into Kagi there, reuse that profile directly.

One-time setup

# List available Chrome profiles
agent-browser profiles

# Use the profile that has Kagi logged in (e.g. "Default", "Profile 2", etc.)
agent-browser --profile "Profile 2" open "https://kagi.com"
# If Kagi shows you as logged in, you're done. Otherwise log in once.

Search with persistent profile

Always use --profile so the login state is preserved:

agent-browser --profile "Profile 2" open "https://kagi.com/search?q=QUERY" && agent-browser --profile "Profile 2" get text

To avoid typing --profile every time, set the env var:

export AGENT_BROWSER_PROFILE="Profile 2"
agent-browser open "https://kagi.com/search?q=QUERY" && agent-browser get text

Or set it in ~/.agent-browser/config.json:

{"profile": "Profile 2"}

Path 3: No Kagi login available → Bing fallback

If neither path 1 nor 2 is viable, use Bing as the search engine. Bing does not block automation and requires no authentication:

agent-browser open "https://www.bing.com/search?q=QUERY" && agent-browser get text

How to Search (General)

One-shot search + extract

# Kagi (after cookies synced or profile set)
agent-browser open "https://kagi.com/search?q=URL_ENCODED_QUERY" && agent-browser get text

# Bing (no setup needed)
agent-browser open "https://www.bing.com/search?q=URL_ENCODED_QUERY" && agent-browser get text

Interactive search

agent-browser open "https://kagi.com"
agent-browser type "input[placeholder*='Search']" "your query"
agent-browser press Enter
agent-browser wait 2000
agent-browser get text

Navigate to a specific result

agent-browser open "URL_FROM_RESULTS" && agent-browser get text

Best Practices

  1. Use API first — if you have a token, it's 10-50x faster and more reliable
  2. Try Kagi browser automation — better results, ad-free, respects user's subscription
  3. Sync cookies for Firefox-variant users via the included script
  4. Reuse Chrome profile for Chromium users via --profile
  5. Fallback to Bing if Kagi auth is unavailable
  6. Encode queries: Replace spaces with +, special chars with percent-encoding
  7. Use get text: Clean innerText, no HTML clutter
  8. Use snapshot: When you need to interact with specific elements
  9. Chain searches: Search broad → extract URL → deep-dive

Limitations

  • API requires token: Must get API key from Kagi settings
  • Browser Kagi requires auth: Cloudflare Turnstile blocks unauthenticated automation
  • Browser speed: ~2-5s per page (slower than API's ~100-500ms)
  • Browser format: Raw text, not structured JSON
  • Browser fragility: May break if search UI changes
  • Cookie expiry: If Kagi sessions expire, re-run the sync script or re-login

Alternative: Kagi Search API (Now in Public Preview)

For high-volume or structured programmatic search, the Kagi Search API is now publicly available (no invite needed):

See Path 0 above for setup instructions.


Troubleshooting

IssueSolution
API returns 401 UnauthorizedCheck KAGI_API_KEY is set and token is valid at kagi.com/settings?p=api
API returns 429 Rate LimitedSlow down requests or check Kagi API rate limits
Kagi returns CAPTCHA pageCookies expired → re-run sync script or use Bing fallback
agent-browser not foundInstall pi extension: pi extensions install agent-browser
Cookie sync script failsCheck browser is installed: which zen or which firefox
Results are stale/oldCheck URL includes current year or recent terms
Blank page after navigateWait for JS to load: add sleep 2 or use wait_for_selector
Search results truncatedUse get text for full page; snapshot for structured DOM

Common Agent Mistakes

Wrong: Searching for information already in training data alone ✅ Right: Use search only for current/real-time info or specific facts not in training data

Wrong: Using browser automation when you have an API token ✅ Right: Use the API (Path 0) for speed and reliability; save browser automation for when you don't have a token

Wrong: Using Kagi browser automation without checking cookies first ✅ Right: Verify cookie sync worked before relying on Kagi results; fall back to Bing if needed

Wrong: Falling back to Bing when Kagi API or browser automation works fine ✅ Right: Only use Bing fallback when Kagi is unavailable or unauthenticated

Wrong: Using web search for tasks better suited to API calls ✅ Right: Use httpie/curl for known endpoints; web search is for discovery, not repeated API work

Related Skills & Tools

  • @skills/my-crawl4ai — For crawling entire sites, not single search queries
  • @skills/my-tech-stack — For tool recommendations (httpie vs curl, etc.)
  • @skills/cua-computer-use — For GUI interactions when browser automation isn't sufficient
  • Official Kagi MCP Serveruvx kagimcp for Claude Desktop, Codex CLI, Cline (github.com/kagisearch/kagimcp)
  • Official Kagi Python Packagepip install kagiapi (github.com/kagisearch/kagiapi)

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.