feat(core): add mcp support (#34513)

This commit is contained in:
Aiden Cline 2026-06-30 08:37:44 -05:00 committed by GitHub
commit b1ca070b3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 1966 additions and 388 deletions

View file

@ -17,6 +17,7 @@ import { QuestionHandler } from "./handlers/question"
import { ReferenceHandler } from "./handlers/reference"
import { LocationHandler } from "./handlers/location"
import { IntegrationHandler } from "./handlers/integration"
import { McpHandler } from "./handlers/mcp"
import { CredentialHandler } from "./handlers/credential"
import { ProjectHandler } from "./handlers/project"
import { ProjectCopyHandler } from "./handlers/project-copy"
@ -31,6 +32,7 @@ export const handlers = Layer.mergeAll(
GenerateHandler,
ProviderHandler,
IntegrationHandler,
McpHandler,
CredentialHandler,
ProjectHandler,
PermissionHandler,

View file

@ -0,0 +1,19 @@
import { MCP } from "@opencode-ai/core/mcp/index"
import { Effect } from "effect"
import { HttpApiBuilder } from "effect/unstable/httpapi"
import { Api } from "../api"
import { response } from "../location"
export const McpHandler = HttpApiBuilder.group(Api, "server.mcp", (handlers) =>
Effect.gen(function* () {
return handlers.handle(
"mcp.list",
Effect.fn(function* () {
const service = yield* MCP.Service
return yield* response(
service.servers().pipe(Effect.map((servers) => servers.map((info) => ({ name: info.name, status: info.status })))),
)
}),
)
}),
)