|
1 | 1 | export * as ConfigMCP from "./mcp" |
2 | 2 |
|
3 | 3 | import { Schema } from "effect" |
4 | | -import { PositiveInt } from "../schema" |
| 4 | +import { Mcp } from "@opencode-ai/schema/mcp" |
5 | 5 |
|
6 | | -export class Timeout extends Schema.Class<Timeout>("ConfigV2.MCP.Timeout")({ |
7 | | - startup: PositiveInt.pipe(Schema.optional).annotate({ |
8 | | - description: "Maximum time in milliseconds to establish and initialize the MCP server.", |
9 | | - }), |
10 | | - catalog: PositiveInt.pipe(Schema.optional).annotate({ |
11 | | - description: "Maximum time in milliseconds to wait for MCP discovery requests such as tools/list and prompts/list.", |
12 | | - }), |
13 | | - execution: PositiveInt.pipe(Schema.optional).annotate({ |
14 | | - description: "Maximum time in milliseconds to wait for MCP tool and prompt execution.", |
15 | | - }), |
16 | | -}) {} |
17 | | - |
18 | | -export class Local extends Schema.Class<Local>("ConfigV2.MCP.Local")({ |
19 | | - type: Schema.Literal("local"), |
20 | | - command: Schema.String.pipe(Schema.Array), |
21 | | - cwd: Schema.String.pipe(Schema.optional).annotate({ |
22 | | - description: "Working directory for the MCP server process. Relative paths resolve from the workspace directory.", |
23 | | - }), |
24 | | - environment: Schema.Record(Schema.String, Schema.String).pipe(Schema.optional), |
25 | | - disabled: Schema.Boolean.pipe(Schema.optional), |
26 | | - codemode: Schema.Boolean.pipe(Schema.optional).annotate({ |
27 | | - description: "Expose this server's tools through Code Mode. Defaults to true.", |
28 | | - }), |
29 | | - timeout: Timeout.pipe(Schema.optional), |
30 | | -}) {} |
31 | | - |
32 | | -export class OAuth extends Schema.Class<OAuth>("ConfigV2.MCP.OAuth")({ |
33 | | - client_id: Schema.String.pipe(Schema.optional), |
34 | | - client_secret: Schema.String.pipe(Schema.optional), |
35 | | - scope: Schema.String.pipe(Schema.optional), |
36 | | - callback_port: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65535 })).pipe(Schema.optional), |
37 | | - redirect_uri: Schema.String.pipe(Schema.optional), |
38 | | -}) {} |
39 | | - |
40 | | -export class Remote extends Schema.Class<Remote>("ConfigV2.MCP.Remote")({ |
41 | | - type: Schema.Literal("remote"), |
42 | | - url: Schema.String, |
43 | | - headers: Schema.Record(Schema.String, Schema.String).pipe(Schema.optional), |
44 | | - oauth: Schema.Union([OAuth, Schema.Literal(false)]).pipe(Schema.optional), |
45 | | - disabled: Schema.Boolean.pipe(Schema.optional), |
46 | | - codemode: Schema.Boolean.pipe(Schema.optional).annotate({ |
47 | | - description: "Expose this server's tools through Code Mode. Defaults to true.", |
48 | | - }), |
49 | | - timeout: Timeout.pipe(Schema.optional), |
50 | | -}) {} |
51 | | - |
52 | | -export const Server = Schema.Union([Local, Remote]).pipe(Schema.toTaggedUnion("type")) |
| 6 | +// The MCP server config is a public wire contract (used by the mcp.add route), so it lives in |
| 7 | +// @opencode-ai/schema and is re-exported here. |
| 8 | +export const Timeout = Mcp.TimeoutConfig |
| 9 | +export type Timeout = Mcp.TimeoutConfig |
| 10 | +export const Local = Mcp.LocalConfig |
| 11 | +export type Local = Mcp.LocalConfig |
| 12 | +export const OAuth = Mcp.OAuthConfig |
| 13 | +export type OAuth = Mcp.OAuthConfig |
| 14 | +export const Remote = Mcp.RemoteConfig |
| 15 | +export type Remote = Mcp.RemoteConfig |
| 16 | +export const Server = Mcp.ServerConfig |
53 | 17 |
|
54 | 18 | export class Info extends Schema.Class<Info>("ConfigV2.MCP")({ |
55 | 19 | timeout: Timeout.pipe(Schema.optional), |
|
0 commit comments