fix(mcp): handle missing Tavily API key gracefully
Previously, when websearch was configured with Tavily provider and the TAVILY_API_KEY environment variable was not set, the entire plugin would fail to load with no visible error to the user. Changes: 1. createWebsearchConfig now returns undefined when Tavily key is missing 2. Added warning log: '[websearch] Tavily API key not found, skipping websearch MCP' 3. createBuiltinMcps now skips undefined configs instead of adding them 4. Added tests for both missing and present Tavily API key scenarios Fixes #2996
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { WebsearchConfig } from "../config/schema"
|
||||
import { log } from "../shared/logger"
|
||||
|
||||
type RemoteMcpConfig = {
|
||||
type: "remote"
|
||||
@@ -14,7 +15,8 @@ export function createWebsearchConfig(config?: WebsearchConfig): RemoteMcpConfig
|
||||
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")
|
||||
log("[websearch] Tavily API key not found, skipping websearch MCP")
|
||||
return undefined
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user