Several bugs fixed
This commit is contained in:
@@ -114,7 +114,7 @@ class MCPService {
|
||||
|
||||
// MARK: - Tool Schema Generation
|
||||
|
||||
func getToolSchemas() -> [Tool] {
|
||||
func getToolSchemas(onlineMode: Bool = false) -> [Tool] {
|
||||
var tools: [Tool] = [
|
||||
makeTool(
|
||||
name: "read_file",
|
||||
@@ -220,6 +220,19 @@ class MCPService {
|
||||
tools.append(contentsOf: paperlessService.getToolSchemas())
|
||||
}
|
||||
|
||||
// Add web_search tool when online mode is active
|
||||
// (OpenRouter handles search natively via :online model suffix, so excluded here)
|
||||
if onlineMode {
|
||||
tools.append(makeTool(
|
||||
name: "web_search",
|
||||
description: "Search the web for current information using DuckDuckGo. Use this when you need up-to-date information, news, or facts not in your training data. Formulate a concise, focused search query.",
|
||||
properties: [
|
||||
"query": prop("string", "The search query to look up")
|
||||
],
|
||||
required: ["query"]
|
||||
))
|
||||
}
|
||||
|
||||
return tools
|
||||
}
|
||||
|
||||
@@ -333,6 +346,18 @@ class MCPService {
|
||||
}
|
||||
return copyFile(source: source, destination: destination)
|
||||
|
||||
case "web_search":
|
||||
let query = args["query"] as? String ?? ""
|
||||
guard !query.isEmpty else {
|
||||
return ["error": "Missing required parameter: query"]
|
||||
}
|
||||
let results = await WebSearchService.shared.search(query: query)
|
||||
if results.isEmpty {
|
||||
return ["results": [], "message": "No results found for: \(query)"]
|
||||
}
|
||||
let mapped = results.map { ["title": $0.title, "url": $0.url, "snippet": $0.snippet] }
|
||||
return ["results": mapped]
|
||||
|
||||
default:
|
||||
// Route anytype_* tools to AnytypeMCPService
|
||||
if name.hasPrefix("anytype_") {
|
||||
|
||||
Reference in New Issue
Block a user