Skip to content

feat: add kiro_web_search tool#110

Open
RvVeen wants to merge 1 commit into
tickernelz:masterfrom
Servoy:pr/kiro-web-search
Open

feat: add kiro_web_search tool#110
RvVeen wants to merge 1 commit into
tickernelz:masterfrom
Servoy:pr/kiro-web-search

Conversation

@RvVeen

@RvVeen RvVeen commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Expose Kiro's server-side web search as an OpenCode custom tool named
kiro_web_search. This is the same web_search tool the Kiro CLI uses — Kiro
runs the search on its own infrastructure and bills it as credits, returning
structured results (title, url, snippet, domain, publish date).

Problem

OpenCode users on this plugin have no access to Kiro's built-in web search. Kiro
CLI exposes it, but the plugin only implemented generateAssistantResponse and
never wired up the search tool, so users had to rely on external search MCP
servers.

Solution

Register a custom tool via the OpenCode tool helper. Its execute calls
Kiro's InvokeMCP endpoint (JSON-RPC tools/call with name: "web_search") —
the exact protocol observed from the Kiro CLI — reusing the plugin's existing
auth/token/endpoint infrastructure.

Changes

  • src/plugin/web-search.ts (new) — kiroWebSearch() performs a fresh-token
    InvokeMCP call with a 30s timeout; formatWebSearchResults() renders
    results as markdown (title link, domain · date, snippet).
  • src/plugin.ts — register kiro_web_search via the tool helper.
  • src/plugin/config/schema.ts — add the web_search_enabled config flag.

Design notes

  • Pro accounts only: InvokeMCP requires a profileArn and 400s without
    one, so the tool is only registered when the active account has one. On free
    Builder ID accounts it is not advertised to the model.
  • Named kiro_web_search: the kiro_ prefix avoids collisions with other
    web_search tools/MCP servers and makes it clear this variant costs Kiro
    credits. The name sent to Kiro is still the server-side web_search.
  • web_fetch intentionally omitted: Kiro does not expose web_fetch as a
    server-side tool (the CLI fetches URLs client-side), and OpenCode already ships
    a built-in fetch tool, so this PR leaves fetching to OpenCode.
  • Configurable: set "web_search_enabled": false in kiro.json to disable
    and avoid overlap with an existing search MCP.
  • The tool description is adapted from Kiro's own web_search spec, guiding the
    model on when to search vs. use the codebase, the 200-character query cap, and
    inline source attribution.

Configuration

// kiro.json
{
  "web_search_enabled": true
}

Testing

  • bun test — all pass (adds unit tests for result formatting)
  • bun run typecheck — clean
  • bun run build — clean
  • Live end-to-end verification: the model invokes kiro_web_search, results
    return with correct URLs, and answers include inline source links.

Expose Kiro's server-side web search (the same InvokeMCP web_search tool
kiro-cli uses) as an OpenCode custom tool named kiro_web_search. Kiro
runs the search on its own infrastructure and bills it as credits,
returning structured results (title, url, snippet, domain, date).

Only registered for Pro accounts (requires a profileArn; InvokeMCP 400s
without one) and gated behind the web_search_enabled config flag so it
can be disabled to avoid overlap with other search MCP servers. The tool
description guides the model on when to search vs. use the codebase, the
200-char query cap, and inline source attribution. A 30s request timeout
guards the network call. web_fetch is left to OpenCode's built-in tool.
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.

1 participant