feat: add kiro_web_search tool#110
Open
RvVeen wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Expose Kiro's server-side web search as an OpenCode custom tool named
kiro_web_search. This is the sameweb_searchtool the Kiro CLI uses — Kiroruns 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
generateAssistantResponseandnever wired up the search tool, so users had to rely on external search MCP
servers.
Solution
Register a custom tool via the OpenCode
toolhelper. ItsexecutecallsKiro's
InvokeMCPendpoint (JSON-RPCtools/callwithname: "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-tokenInvokeMCPcall with a 30s timeout;formatWebSearchResults()rendersresults as markdown (title link, domain · date, snippet).
src/plugin.ts— registerkiro_web_searchvia thetoolhelper.src/plugin/config/schema.ts— add theweb_search_enabledconfig flag.Design notes
InvokeMCPrequires aprofileArnand 400s withoutone, so the tool is only registered when the active account has one. On free
Builder ID accounts it is not advertised to the model.
kiro_web_search: thekiro_prefix avoids collisions with otherweb_searchtools/MCP servers and makes it clear this variant costs Kirocredits. The name sent to Kiro is still the server-side
web_search.web_fetchintentionally omitted: Kiro does not exposeweb_fetchas aserver-side tool (the CLI fetches URLs client-side), and OpenCode already ships
a built-in fetch tool, so this PR leaves fetching to OpenCode.
"web_search_enabled": falseinkiro.jsonto disableand avoid overlap with an existing search MCP.
web_searchspec, guiding themodel on when to search vs. use the codebase, the 200-character query cap, and
inline source attribution.
Configuration
Testing
bun test— all pass (adds unit tests for result formatting)bun run typecheck— cleanbun run build— cleankiro_web_search, resultsreturn with correct URLs, and answers include inline source links.