From 135e04ddddfe832c9e56bcdb253d0651dc51c3de Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Mon, 29 Jun 2026 09:48:40 -0500 Subject: [PATCH] read configs --- packages/core/src/mcp.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/core/src/mcp.ts b/packages/core/src/mcp.ts index 029f174a89..7c8fa820e1 100644 --- a/packages/core/src/mcp.ts +++ b/packages/core/src/mcp.ts @@ -2,6 +2,7 @@ export * as MCP from "./mcp" import { Context, Effect, Layer, Schema } from "effect" import { makeLocationNode } from "./effect/app-node" +import { Config } from "./config" import { ConfigMCP } from "./config/mcp" import { Integration } from "./integration" import { IntegrationConnection } from "./integration/connection" @@ -157,7 +158,23 @@ export class Service extends Context.Service()("@opencode/v2 export const layer = Layer.effect( Service, Effect.gen(function* () { + const config = yield* Config.Service + const documents = (yield* config.entries()).filter((entry): entry is Config.Document => entry.type === "document") + // Global MCP timeout defaults, later config files overriding earlier ones. + const timeout = Object.assign( + {}, + ...documents.flatMap((entry) => (entry.info.mcp?.timeout ? [entry.info.mcp.timeout] : [])), + ) + // Later config files win for duplicate server names; per-server timeout overrides globals. const runtime = new Map() + for (const entry of documents) { + for (const [name, server] of Object.entries(entry.info.mcp?.servers ?? {})) { + runtime.set(ServerName.make(name), { + config: { ...server, timeout: { ...timeout, ...server.timeout } }, + status: server.disabled ? { status: "disabled" } : { status: "disconnected" }, + }) + } + } const requireServer = Effect.fnUntraced(function* (server: ServerName | string) { const name = ServerName.make(server) @@ -224,4 +241,4 @@ export const layer = Layer.effect( }), ) -export const node = makeLocationNode({ service: Service, layer, deps: [] }) +export const node = makeLocationNode({ service: Service, layer, deps: [Config.node] })