websearch: add scope=code programming search + provider extract chain

- search(..., scope=code) restricts to 15 programming domains
  (official docs, GitHub, registries, Stack Overflow, CVE/NVD):
  native include_domains/search_domain_filter where supported
  (Tavily, Exa, Perplexity), post-filtering for all providers
  (Brave, SearXNG, DuckDuckGo have no native filter).
- web_fetch now uses fetch_best: Tavily extract, then Exa
  contents, then direct fetch; both-fail errors name both
  failures, direct-fetch 403 under the egress whitelist is
  fail-closed, not bypassed. Default general scope and direct
  fetch_url behaviour unchanged.
- MCP web_search gains scope enum (general/code); docs updated.
- Tests all mock HTTP, no real keys.
This commit is contained in:
host committed 2026-11-01 08:16:48 +00:00
1 parent 27f48fe1ed
commit 397a46f850
5 files changed
+803 -36

No files matched your search

+3 -2
View File
@@ -203,9 +203,10 @@ class McpFramingTestCase(unittest.TestCase):
names = [t["name"] for t in resp["result"]["tools"]]
self.assertEqual(names, ["web_search", "web_fetch"])
def fake_search(query, limit=5, provider="auto"):
def fake_search(query, limit=5, provider="auto",
scope="general"):
return {"provider": "fake", "results": [], "answer": None,
"attempted": []}
"attempted": [], "scope": scope}
resp = handle_request(
{"jsonrpc": "2.0", "id": 3, "method": "tools/call",