Skip to content

Add kagi_fastgpt tool - #23

Open
MarcelDuchamp wants to merge 1 commit into
kagisearch:mainfrom
MarcelDuchamp:add-fastgpt-tool
Open

MarcelDuchamp wants to merge 1 commit into
kagisearch:mainfrom
MarcelDuchamp:add-fastgpt-tool

Conversation

@MarcelDuchamp

Copy link
Copy Markdown

Adds a new kagi_fastgpt MCP tool that wraps the Kagi FastGPT API
(POST /api/v0/fastgpt). FastGPT answers natural-language questions with
a short synthesized response plus numbered web citations, and — unlike
kagi_search_fetch — works with any standard Kagi API key without
requiring Search API beta access.

What's new

  • kagi_fastgpt(query, cache=True) posts to /api/v0/fastgpt and returns
    the answer text followed by a numbered reference list for any cited
    sources. Schema-compatible with the existing FastMCP tool style.
  • README: new Tools section listing all three tools and calling out
    which require Search API beta access.

Implementation note

kagiapi 0.2.1 has a bug in its KagiClient.fastgpt() helper: it
serializes the cache param as the JSON string "true" / "false",
which the FastGPT endpoint rejects with
{"code": 1, "msg": "Unexpected JSON value for parameter \"cache\""}.
Sending a real boolean works. This PR bypasses the helper and posts
through the client's authenticated session directly with a real boolean,
so the tool works today against the live API without needing an upstream
kagiapi release. Happy to open a separate PR on
kagisearch/kagiapi if you'd like.

Testing

Against a standard key, kagi_fastgpt(query="What is the capital of Iceland?")
returns a cited answer; kagi_fastgpt(query=..., cache=False) forces a
fresh search. Existing kagi_summarizer remains unchanged and verified
working alongside the new tool.

FastGPT combines live web search with an LLM to return a concise, cited
answer to a natural-language query. Complements the existing search and
summarizer tools and, unlike kagi_search_fetch, works with any standard
Kagi API key (no Search-API beta required).

- New tool kagi_fastgpt(query, cache=True) calling POST /api/v0/fastgpt.
- Output formats the answer followed by a numbered reference list.
- Bypasses kagiapi 0.2.1's .fastgpt() helper, which serializes `cache` as
  a JSON string that the endpoint rejects; posts through the authenticated
  session directly with a real boolean.
- README: new "Tools" section documenting all three tools and which ones
  require the Search-API beta.
@rehanzo

rehanzo commented May 27, 2026

Copy link
Copy Markdown
Contributor

Going to leave this PR open for now. We use different API keys for the v0 fastgpt and the v1 search API. These will be merged soon, so I'll build off this and merge once we do that, to keep things simple. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants