feat(mcp): add multi-provider websearch support
This commit is contained in:
+43
-9
@@ -1,10 +1,44 @@
|
||||
export const websearch = {
|
||||
type: "remote" as const,
|
||||
url: "https://mcp.exa.ai/mcp?tools=web_search_exa",
|
||||
enabled: true,
|
||||
headers: process.env.EXA_API_KEY
|
||||
? { "x-api-key": process.env.EXA_API_KEY }
|
||||
: undefined,
|
||||
// Disable OAuth auto-detection - Exa uses API key header, not OAuth
|
||||
oauth: false as const,
|
||||
import type { WebsearchConfig } from "../config/schema"
|
||||
|
||||
type RemoteMcpConfig = {
|
||||
type: "remote"
|
||||
url: string
|
||||
enabled: boolean
|
||||
headers?: Record<string, string>
|
||||
oauth?: false
|
||||
}
|
||||
|
||||
export function createWebsearchConfig(config?: WebsearchConfig): RemoteMcpConfig {
|
||||
const provider = config?.provider || "exa"
|
||||
|
||||
if (provider === "tavily") {
|
||||
const tavilyKey = process.env.TAVILY_API_KEY
|
||||
if (!tavilyKey) {
|
||||
throw new Error("TAVILY_API_KEY environment variable is required for Tavily provider")
|
||||
}
|
||||
|
||||
return {
|
||||
type: "remote" as const,
|
||||
url: "https://mcp.tavily.com/mcp/",
|
||||
enabled: true,
|
||||
headers: {
|
||||
Authorization: `Bearer ${tavilyKey}`,
|
||||
},
|
||||
oauth: false as const,
|
||||
}
|
||||
}
|
||||
|
||||
// Default to Exa
|
||||
return {
|
||||
type: "remote" as const,
|
||||
url: "https://mcp.exa.ai/mcp?tools=web_search_exa",
|
||||
enabled: true,
|
||||
headers: process.env.EXA_API_KEY
|
||||
? { "x-api-key": process.env.EXA_API_KEY }
|
||||
: undefined,
|
||||
oauth: false as const,
|
||||
}
|
||||
}
|
||||
|
||||
// Backward compatibility: export static instance using default config
|
||||
export const websearch = createWebsearchConfig()
|
||||
|
||||
Reference in New Issue
Block a user