chore(mcp): declare client capabilities (#32222)
This commit is contained in:
parent
7143bf8ff0
commit
11fd6f8255
1 changed files with 15 additions and 3 deletions
|
|
@ -3,7 +3,7 @@ import { LayerNode } from "@opencode-ai/core/effect/layer-node"
|
||||||
import { type Tool } from "ai"
|
import { type Tool } from "ai"
|
||||||
import { ConfigV1 } from "@opencode-ai/core/v1/config/config"
|
import { ConfigV1 } from "@opencode-ai/core/v1/config/config"
|
||||||
import { serviceUse } from "@opencode-ai/core/effect/service-use"
|
import { serviceUse } from "@opencode-ai/core/effect/service-use"
|
||||||
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
|
import { Client, type ClientOptions } from "@modelcontextprotocol/sdk/client/index.js"
|
||||||
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
|
||||||
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js"
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js"
|
||||||
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"
|
||||||
|
|
@ -35,6 +35,18 @@ import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
|
||||||
import { McpCatalog } from "./catalog"
|
import { McpCatalog } from "./catalog"
|
||||||
|
|
||||||
const DEFAULT_TIMEOUT = 30_000
|
const DEFAULT_TIMEOUT = 30_000
|
||||||
|
const CLIENT_OPTIONS = {
|
||||||
|
capabilities: {
|
||||||
|
// https://github.com/anomalyco/opencode/issues/11948
|
||||||
|
// sampling: {},
|
||||||
|
// https://github.com/anomalyco/opencode/issues/23066
|
||||||
|
// elicitation: {},
|
||||||
|
// https://github.com/anomalyco/opencode/issues/2308
|
||||||
|
// roots: {},
|
||||||
|
// https://github.com/anomalyco/opencode/issues/28567
|
||||||
|
// tasks: {},
|
||||||
|
},
|
||||||
|
} satisfies ClientOptions
|
||||||
|
|
||||||
export const Resource = Schema.Struct({
|
export const Resource = Schema.Struct({
|
||||||
name: Schema.String,
|
name: Schema.String,
|
||||||
|
|
@ -186,7 +198,7 @@ export const layer = Layer.effect(
|
||||||
(t) =>
|
(t) =>
|
||||||
Effect.tryPromise({
|
Effect.tryPromise({
|
||||||
try: () => {
|
try: () => {
|
||||||
const client = new Client({ name: "opencode", version: InstallationVersion })
|
const client = new Client({ name: "opencode", version: InstallationVersion }, CLIENT_OPTIONS)
|
||||||
return withTimeout(client.connect(t), timeout).then(() => client)
|
return withTimeout(client.connect(t), timeout).then(() => client)
|
||||||
},
|
},
|
||||||
catch: (e) => (e instanceof Error ? e : new Error(String(e))),
|
catch: (e) => (e instanceof Error ? e : new Error(String(e))),
|
||||||
|
|
@ -768,7 +780,7 @@ export const layer = Layer.effect(
|
||||||
|
|
||||||
return yield* Effect.tryPromise({
|
return yield* Effect.tryPromise({
|
||||||
try: () => {
|
try: () => {
|
||||||
const client = new Client({ name: "opencode", version: InstallationVersion })
|
const client = new Client({ name: "opencode", version: InstallationVersion }, CLIENT_OPTIONS)
|
||||||
return client
|
return client
|
||||||
.connect(transport)
|
.connect(transport)
|
||||||
.then(() => ({ authorizationUrl: "", oauthState, client }) satisfies AuthResult)
|
.then(() => ({ authorizationUrl: "", oauthState, client }) satisfies AuthResult)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue