Retrieve live web search results and show chat diagnostics

This commit is contained in:
Mark Gregory
2026-11-16 16:52:21 +00:00
parent 0f4b6b03e4
commit de18d95741
8 changed files with 181 additions and 52 deletions
+1 -4
View File
@@ -792,7 +792,7 @@ struct BuiltInWebTools: MCPToolClient {
[
MCPTool(name: "retrieve_page", description: "Retrieve readable text from an HTTP or HTTPS page.",
inputSchemaJSON: Data(#"{"type":"object","properties":{"url":{"type":"string","format":"uri"}},"required":["url"]}"#.utf8)),
MCPTool(name: "web_search", description: "Search via the SearXNG endpoint configured in Toolbox → Web.",
MCPTool(name: "web_search", description: "Search the web using the default provider or configured SearXNG endpoint.",
inputSchemaJSON: Data(#"{"type":"object","properties":{"query":{"type":"string"}},"required":["query"]}"#.utf8))
]
}
@@ -807,9 +807,6 @@ struct BuiltInWebTools: MCPToolClient {
options: [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes])
case "web_search":
guard let query = arguments["query"] as? String else { throw StudioError("Provide a search query in the query field.") }
guard !searchEndpoint.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
throw StudioError("Set a SearXNG search URL in Toolbox → Web before using web_search.")
}
let results = try await WebSearch.results(endpoint: searchEndpoint, query: query)
return try JSONSerialization.data(withJSONObject: results.map {
["title": $0.title, "url": $0.url.absoluteString, "snippet": $0.snippet]