mirror of
https://github.com/sst/opencode.git
synced 2025-08-31 10:17:26 +00:00
Add Option to Disable MCP Servers (#513)
This commit is contained in:
parent
3a9584a419
commit
f0962e2d9c
3 changed files with 20 additions and 0 deletions
|
@ -264,6 +264,10 @@
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"description": "Environment variables to set when running the MCP server"
|
"description": "Environment variables to set when running the MCP server"
|
||||||
|
},
|
||||||
|
"enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Enable or disable the MCP server on startup"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["type", "command"],
|
"required": ["type", "command"],
|
||||||
|
@ -280,6 +284,10 @@
|
||||||
"url": {
|
"url": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "URL of the remote MCP server"
|
"description": "URL of the remote MCP server"
|
||||||
|
},
|
||||||
|
"enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Enable or disable the MCP server on startup"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["type", "url"],
|
"required": ["type", "url"],
|
||||||
|
|
|
@ -37,6 +37,10 @@ export namespace Config {
|
||||||
.record(z.string(), z.string())
|
.record(z.string(), z.string())
|
||||||
.optional()
|
.optional()
|
||||||
.describe("Environment variables to set when running the MCP server"),
|
.describe("Environment variables to set when running the MCP server"),
|
||||||
|
enabled: z
|
||||||
|
.boolean()
|
||||||
|
.optional()
|
||||||
|
.describe("Enable or disable the MCP server on startup"),
|
||||||
})
|
})
|
||||||
.strict()
|
.strict()
|
||||||
.openapi({
|
.openapi({
|
||||||
|
@ -47,6 +51,10 @@ export namespace Config {
|
||||||
.object({
|
.object({
|
||||||
type: z.literal("remote").describe("Type of MCP server connection"),
|
type: z.literal("remote").describe("Type of MCP server connection"),
|
||||||
url: z.string().describe("URL of the remote MCP server"),
|
url: z.string().describe("URL of the remote MCP server"),
|
||||||
|
enabled: z
|
||||||
|
.boolean()
|
||||||
|
.optional()
|
||||||
|
.describe("Enable or disable the MCP server on startup"),
|
||||||
})
|
})
|
||||||
.strict()
|
.strict()
|
||||||
.openapi({
|
.openapi({
|
||||||
|
|
|
@ -26,6 +26,10 @@ export namespace MCP {
|
||||||
[name: string]: Awaited<ReturnType<typeof experimental_createMCPClient>>
|
[name: string]: Awaited<ReturnType<typeof experimental_createMCPClient>>
|
||||||
} = {}
|
} = {}
|
||||||
for (const [key, mcp] of Object.entries(cfg.mcp ?? {})) {
|
for (const [key, mcp] of Object.entries(cfg.mcp ?? {})) {
|
||||||
|
if (mcp.enabled === false) {
|
||||||
|
log.info("mcp server disabled", { key })
|
||||||
|
continue
|
||||||
|
}
|
||||||
log.info("found", { key, type: mcp.type })
|
log.info("found", { key, type: mcp.type })
|
||||||
if (mcp.type === "remote") {
|
if (mcp.type === "remote") {
|
||||||
const client = await experimental_createMCPClient({
|
const client = await experimental_createMCPClient({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue