2026-02-02 03:36:48 +08:00
|
|
|
import { createWebsearchConfig } from "./websearch"
|
2025-12-05 02:23:34 +09:00
|
|
|
import { context7 } from "./context7"
|
2025-12-13 19:13:40 +09:00
|
|
|
import { grep_app } from "./grep-app"
|
2025-12-05 03:58:21 +09:00
|
|
|
import type { McpName } from "./types"
|
2026-02-02 03:36:48 +08:00
|
|
|
import type { OhMyOpenCodeConfig } from "../config/schema"
|
2025-12-05 02:15:39 +09:00
|
|
|
|
2025-12-05 03:58:21 +09:00
|
|
|
export { McpNameSchema, type McpName } from "./types"
|
2025-12-05 02:23:34 +09:00
|
|
|
|
2026-01-06 14:12:22 -07:00
|
|
|
type RemoteMcpConfig = {
|
|
|
|
|
type: "remote"
|
|
|
|
|
url: string
|
|
|
|
|
enabled: boolean
|
|
|
|
|
headers?: Record<string, string>
|
2026-01-17 16:36:23 +05:30
|
|
|
oauth?: false
|
2026-01-06 14:12:22 -07:00
|
|
|
}
|
|
|
|
|
|
2026-02-02 03:36:48 +08:00
|
|
|
export function createBuiltinMcps(disabledMcps: string[] = [], config?: OhMyOpenCodeConfig) {
|
|
|
|
|
const allBuiltinMcps: Record<McpName, RemoteMcpConfig> = {
|
|
|
|
|
websearch: createWebsearchConfig(config?.websearch),
|
|
|
|
|
context7,
|
|
|
|
|
grep_app,
|
|
|
|
|
}
|
2025-12-05 02:23:34 +09:00
|
|
|
|
2026-01-06 14:12:22 -07:00
|
|
|
const mcps: Record<string, RemoteMcpConfig> = {}
|
2025-12-05 02:23:34 +09:00
|
|
|
|
2026-02-02 03:36:48 +08:00
|
|
|
for (const [name, mcp] of Object.entries(allBuiltinMcps)) {
|
2026-01-05 21:12:05 +09:00
|
|
|
if (!disabledMcps.includes(name)) {
|
2026-02-02 03:36:48 +08:00
|
|
|
mcps[name] = mcp
|
2025-12-05 02:23:34 +09:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return mcps
|
2025-12-05 02:15:39 +09:00
|
|
|
}
|