eea27d6f7e
Resolve built-in local MCP runtime executables before handing command arrays to OpenCode so lsp and ast_grep do not depend on a bare node or bun lookup in the host PATH. Keep source, dist, bootstrap, workspace-safety, and disabled_mcps behavior covered by focused tests and real OpenCode MCP status QA. Plan: plans/fix-built-in-mcp-runtime-executables.md
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
import { createWebsearchConfig } from "./websearch"
|
|
import { context7 } from "./context7"
|
|
import { grep_app } from "./grep-app"
|
|
import { createAstGrepMcpConfig } from "./ast-grep"
|
|
import { createLspMcpConfig, type LocalMcpConfig } from "./lsp"
|
|
import type { RuntimeExecutableResolver } from "./runtime-executable"
|
|
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
|
|
}
|
|
|
|
type BuiltinMcpConfig = RemoteMcpConfig | LocalMcpConfig
|
|
|
|
type BuiltinMcpOptions = {
|
|
readonly cwd?: string
|
|
readonly resolveExecutable?: RuntimeExecutableResolver
|
|
}
|
|
|
|
export function createBuiltinMcps(disabledMcps: string[] = [], config?: OhMyOpenCodeConfig, options: BuiltinMcpOptions = {}) {
|
|
const mcps: Record<string, BuiltinMcpConfig> = {}
|
|
|
|
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
|
|
}
|
|
|
|
if (!disabledMcps.includes("lsp")) {
|
|
mcps.lsp = createLspMcpConfig({ resolveExecutable: options.resolveExecutable })
|
|
}
|
|
|
|
if (!disabledMcps.includes("ast_grep")) {
|
|
mcps.ast_grep = createAstGrepMcpConfig({
|
|
cwd: options.cwd,
|
|
disabledTools: config?.disabled_tools,
|
|
resolveExecutable: options.resolveExecutable,
|
|
})
|
|
}
|
|
|
|
return mcps
|
|
}
|