Repository navigation
Closed
Labels
enhancementNew feature or request
Description
Context
mecatl currently has a WebFetch core tool, but it is an intentional v1 stub: it performs no network I/O and returns WebFetch is not implemented in v1; web fetching is unavailable (internal/adapter/tools/webfetch.go).
For many agent workflows, a search tool is more useful than direct fetch:
- finding current documentation or release notes when the URL is unknown
- locating issues/PRs/blog posts by topic
- researching errors by message text
- discovering candidate sources before deciding which pages to fetch/read
Claude Code and other harnesses expose both web search and web fetch style tools; mecatl should consider adding WebSearch as a first-class read-only tool rather than overloading WebFetch.
Goal
Design and implement a WebSearch tool that returns compact, source-attributed search results suitable for agent use.
Proposed tool shape
WebSearch arguments:
{
"query": "string, required",
"limit": 5,
"site": "optional domain/site filter",
"freshness": "optional enum or date range, if provider supports it"
}Result shape should be compact and bounded, e.g. markdown/plain text lines:
1. Title — https://example.com/page
snippet text...
2. ...
Possible richer JSON-ish result if useful later:
- title
- url
- snippet
- published/updated date when available
- source/domain
Provider/design questions
- Which backend should v1 use?
- provider-native search if/when available
- external search API (requires key/config)
- MCP search server integration
- no-default stub until configured
- Should
WebSearchbe a core built-in like Read/Grep/Glob, or an optional adapter registered only when a search provider is configured? - How does this interact with existing
WebFetch?WebSearchdiscovers candidate URLsWebFetchretrieves/extracts one URL
- Should web tools be disabled by default in untrusted workspaces / require explicit enablement?
- How should permission rules work? Existing permission-import code already treats Claude
WebFetch(domain:...)allow rules conservatively;WebSearchshould get similarly careful defaults.
Security and privacy constraints
- Treat search results as untrusted external content; never as instructions.
- Do not send secrets, local file contents, or proprietary code in search queries unless explicitly authorized.
- Keep queries and results bounded; avoid dumping whole pages in search results.
- Respect operator/network policy: searches are outward-facing network calls and should be configurable/disableable.
- Consider default permission posture: likely Ask or explicit enablement until a safe provider story is settled.
Acceptance criteria
WebSearchhas a cleartool.Toolimplementation or explicitly documented stub/config-gated implementation.- Tool spec explains when to use search vs fetch.
- Results are deterministic enough for tests via a fake provider; offline tests only.
- Result output is capped and terminal/model-friendly.
- Permission defaults and settings/import behavior are reviewed.
- mecatui renders the tool call/result acceptably (especially with mecatui: compact, human-friendly tool-call cards for MCP and long JSON args #24's compact tool-card UX).
References
- Existing stub:
internal/adapter/tools/webfetch.go. - Core catalog registration:
internal/adapter/tools/tools.go. - Permission config import:
internal/adapter/permconfig/claudeimport.go(WebFetch(domain:...)demotion). - Tool design guidance in corpus:
docs/harnesses/06-architecture-patterns.md§6,docs/harnesses/07-context-and-mcp.md§9–10.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
JAORMX commentedon Jun 9, 2026
Planning/evaluation summary -- resolutions from the design discussion (research: harness prior art, search-backend landscape, provider-native search APIs, plus live probing of endpoints).
Resolved: architecture
Client-side tool with a pluggable
Searcherbackend interface. The tool implementstool.Tool(ReadOnly() = true, so plan-mode and read-only-subagent available), executes through the normal dispatch/permission seam, and delegates to a configured backend.Provider-native search (Anthropic
web_search, OpenAI Responsesweb_search) is rejected for v1: those execute server-side during the model turn, bypassing ourExecute()/permission/dispatch seam entirely; OpenAI'sweb_search_callitems have a confirmed 404-on-replay bug withstore:false, incompatible with our stateless full-replay adapters; and the result blocks are provider-private (Anthropic'sencrypted_content), breaking history portability. Neither provider exposes a standalone raw-search endpoint.Resolved: backend tiers
Searcherbackend speaks plain JSON-RPC over HTTP tohttps://mcp.exa.ai/mcp(tools/call web_search_exa), the same way opencode does. Verified empirically: anonymousinitialize/tools/list/tools/callall return 200 with no credentials; the endpoint publishes OAuth metadata (/.well-known/oauth-protected-resource->auth.exa.ai) but does not enforce it -- so the backend must NOT do proactive OAuth discovery (ToolHive does, and parks on a browser flow).EXA_API_KEYoptionally appended (?exaApiKey=) for the paid tier.BRAVE_API_KEY(~$0.25/1k effective, independent index, clean ToS).SEARXNG_URLenv or config file -- self-hosted instances only (public instances bot-blockformat=jsonby design).websearch.provider: none/ flag, for operators who don't want default outbound calls.Precedence proposal: explicit config setting wins; among env vars,
SEARXNG_URL>BRAVE_API_KEY> Exa-anonymous fallback.Mandatory degradation behavior: when the Exa anonymous tier closes (the auth scaffolding is already live) or rate-limits, the tool must return a model-visible error naming the upgrade path ("search backend unavailable; configure BRAVE_API_KEY or SEARXNG_URL") -- never a silent empty result or a hang.
Rejected alternatives (and why)
Security posture
<<<UNTRUSTEDfence discipline (withneutraliseFramingso results can't forge a fence), plus a system-prompt anchor clause. Explicitly documented as hygiene, not a boundary -- delimiter defenses are ignored by models at a material rate. The deny-dominant permission layer remains the boundary for side effects.modelhookHookRunner, coversWebSearch/WebFetch/mcp__*, advisory/enforce, configurable model + prompt). Exec hooks (PreToolUse/PostToolUse+Mutated) already work for WebSearch today and should be mentioned in the tool docs.Implementation seams (recon'd)
buildCatalogininternal/app/build.go; config + env wiring incmd/mecated.ScopeBuiltinDefaultrule forWebSearch; add"query"tononBashPattern()'s probe list ininternal/governance/evaluator.goso arg-pattern rules match. Noclaudeimport.gochange needed (Claude'sWebSearchrules are blanket, unlikeWebFetch(domain:...)).internal/adapter/openrouter/lister.go(injected nil-able*http.Client, fixed base URL,io.LimitReaderbody cap); offline tests viaroundTripFunc+testdata/fixtures, plus a fakeSearcherfor tool-logic tests.writeUntrustedBlock/neutraliseFraming) currently live ininternal/agent(team supervisor) and need extraction to a shared spot adapters can import.Still open
Allow(read-only, query visible in the tool card, config-overridable), withAskin headless/non-interactive runs under consideration -- mirroring the subagent-shell posture split.sessionvsgovernance).WebFetchstays out of scope here but is the natural follow-up: same HTTP plumbing, same fencing, and Exa-anonymous also exposesweb_fetch_exa(verified working), so the default tier may cover both.fix(websearch): make the not-configured path actionable + document it…
JAORMX commentedon Jun 14, 2026
Reopening: I closed this prematurely. The HTTP-adapter work that shipped (b08645a/214c0e5) implemented tiers 2–3 of the resolved design (SearXNG via
SEARXNG_URL-equivalent--websearch-url, Brave via a keyed header) but MISSED tier 1 — the Exa-anonymous zero-config default (https://mcp.exa.ai/mcp→web_search_exa, no key, no proactive OAuth discovery) that the planning comment resolved as the headline behavior. Re-verified the Exa endpoint is still anonymously reachable (200,web_search_exaworks without credentials). Finishing per the resolved tier ladder + precedence (explicit config > SEARXNG_URL > BRAVE_API_KEY > Exa-anonymous) + kill switch + the mandatory degradation message.