a695730891
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
36 lines
881 B
TypeScript
36 lines
881 B
TypeScript
import { createWebsearchConfig } from "./websearch"
|
|
import { context7 } from "./context7"
|
|
import { grep_app } from "./grep-app"
|
|
import type { OhMyOpenCodeConfig } from "../config/schema"
|
|
|
|
export { McpNameSchema, type McpName } from "./types"
|
|
|
|
type RemoteMcpConfig = {
|
|
type: "remote"
|
|
url: string
|
|
enabled: boolean
|
|
headers?: Record<string, string>
|
|
oauth?: false
|
|
}
|
|
|
|
export function createBuiltinMcps(disabledMcps: string[] = [], config?: OhMyOpenCodeConfig) {
|
|
const mcps: Record<string, RemoteMcpConfig> = {}
|
|
|
|
if (!disabledMcps.includes("websearch")) {
|
|
const websearchConfig = createWebsearchConfig(config?.websearch)
|
|
if (websearchConfig) {
|
|
mcps.websearch = websearchConfig
|
|
}
|
|
}
|
|
|
|
if (!disabledMcps.includes("context7")) {
|
|
mcps.context7 = context7
|
|
}
|
|
|
|
if (!disabledMcps.includes("grep_app")) {
|
|
mcps.grep_app = grep_app
|
|
}
|
|
|
|
return mcps
|
|
}
|