Remove local MCP Zod schema (#27095)
This commit is contained in:
@@ -6,6 +6,7 @@ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"
|
|||||||
import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js"
|
import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js"
|
||||||
import {
|
import {
|
||||||
CallToolResultSchema,
|
CallToolResultSchema,
|
||||||
|
ListToolsResultSchema,
|
||||||
ToolSchema,
|
ToolSchema,
|
||||||
type Tool as MCPToolDef,
|
type Tool as MCPToolDef,
|
||||||
ToolListChangedNotificationSchema,
|
ToolListChangedNotificationSchema,
|
||||||
@@ -14,7 +15,6 @@ import { Config } from "@/config/config"
|
|||||||
import { ConfigMCP } from "../config/mcp"
|
import { ConfigMCP } from "../config/mcp"
|
||||||
import * as Log from "@opencode-ai/core/util/log"
|
import * as Log from "@opencode-ai/core/util/log"
|
||||||
import { NamedError } from "@opencode-ai/core/util/error"
|
import { NamedError } from "@opencode-ai/core/util/error"
|
||||||
import z from "zod/v4"
|
|
||||||
import { Installation } from "../installation"
|
import { Installation } from "../installation"
|
||||||
import { InstallationVersion } from "@opencode-ai/core/installation/version"
|
import { InstallationVersion } from "@opencode-ai/core/installation/version"
|
||||||
import { withTimeout } from "@/util/timeout"
|
import { withTimeout } from "@/util/timeout"
|
||||||
@@ -35,13 +35,8 @@ import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
|
|||||||
const log = Log.create({ service: "mcp" })
|
const log = Log.create({ service: "mcp" })
|
||||||
const DEFAULT_TIMEOUT = 30_000
|
const DEFAULT_TIMEOUT = 30_000
|
||||||
|
|
||||||
const TolerantToolSchema = ToolSchema.extend({
|
const TolerantListToolsResultSchema = ListToolsResultSchema.extend({
|
||||||
outputSchema: z.unknown().optional(),
|
tools: ToolSchema.omit({ outputSchema: true }).array(),
|
||||||
})
|
|
||||||
|
|
||||||
const TolerantListToolsResultSchema = z.looseObject({
|
|
||||||
tools: z.array(TolerantToolSchema),
|
|
||||||
nextCursor: z.string().optional(),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const Resource = Schema.Struct({
|
export const Resource = Schema.Struct({
|
||||||
@@ -137,7 +132,10 @@ function listTools(key: string, client: MCPClient, timeout: number) {
|
|||||||
|
|
||||||
log.warn("failed to validate MCP tool output schemas, retrying without output schema validation", { key, error })
|
log.warn("failed to validate MCP tool output schemas, retrying without output schema validation", { key, error })
|
||||||
return Effect.tryPromise({
|
return Effect.tryPromise({
|
||||||
try: () => client.request({ method: "tools/list" }, TolerantListToolsResultSchema, { timeout }),
|
try: () =>
|
||||||
|
client.request({ method: "tools/list" }, TolerantListToolsResultSchema, {
|
||||||
|
timeout,
|
||||||
|
}),
|
||||||
catch: (err) => (err instanceof Error ? err : new Error(String(err))),
|
catch: (err) => (err instanceof Error ? err : new Error(String(err))),
|
||||||
}).pipe(
|
}).pipe(
|
||||||
Effect.map((result) =>
|
Effect.map((result) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user