GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): keep MCP servers whose tool output schema has no type by tlq5l · Pull Request #57832 · anomalyco/opencode

fix(core): keep MCP servers whose tool output schema has no type #57832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tlq5l wants to merge 1 commit into anomalyco:dev from tlq5l:mcp-output-type

Uh oh!

There was an error while loading. Please reload this page.

Closed

fix(core): keep MCP servers whose tool output schema has no type #57832

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
4beee8f
fix(core): keep MCP servers whose tool output schema has no type
tlq5l Oct 21, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
fix(core): keep MCP servers whose tool output schema has no type
Agent: claude
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@tlq5l
tlq5l committed Oct 21, 2026
commit 4beee8f91d550289ffc29c9592eb8d923363df5c

There are no files selected for viewing

24 changes: 24 additions & 0 deletions 24 packages/core/src/mcp/client.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ export const connect = Effect.fnUntraced(function* (
)
}

typeOutputSchemas(transport)

yield* Effect.tryPromise({
try: (signal) =>
client.connect(transport, { timeout: config.timeout?.startup ?? DEFAULT_STARTUP_TIMEOUT, signal }),
Expand Down Expand Up @@ -417,6 +419,28 @@ function rejectsUnknownQuery(url: URL) {
return url.hostname === "localhost" || url.hostname === "[::1]" || /^127(\.\d+){3}$/.test(url.hostname)
}

// The SDK rejects the whole tools/list result when one tool's outputSchema has no top-level "type"
// (for example `$defs` plus `anyOf`), which would take every tool on the server down with it.
// Declaring such a schema an object keeps the tool; its variants are normally objects.
function typeOutputSchemas(transport: Transport) {
let onmessage = transport.onmessage
Object.defineProperty(transport, "onmessage", {
configurable: true,
get: () => onmessage,
set: (handler: Transport["onmessage"]) => {
onmessage =
handler &&
((message, extra) => {
const tools = "result" in message && Array.isArray(message.result.tools) ? message.result.tools : []
for (const tool of tools)
if (typeof tool?.outputSchema === "object" && tool.outputSchema !== null && !("type" in tool.outputSchema))
tool.outputSchema.type = "object"
handler(message, extra)
})
},
})
}

// Absent config is legacy: the SDK sends the plain initialize handshake with no discover probe.
function negotiation(protocol: ConfigMCP.Protocol | undefined): VersionNegotiationOptions | undefined {
if (protocol === undefined || protocol === "legacy") return undefined
Expand Down
43 changes: 43 additions & 0 deletions 43 packages/core/test/fixture/mcp-anyof-output.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Speaks raw JSON-RPC: the MCP server SDK would wrap an outputSchema that has no top-level "type".
const send = (message: unknown) => process.stdout.write(JSON.stringify(message) + "\n")
const callers = {
$defs: {
Callers: { type: "object", properties: { callers: { type: "array" } }, required: ["callers"] },
Kind: { type: "object", properties: { kind: { type: "string" } }, required: ["kind"] },
},
anyOf: [{ $ref: "#/$defs/Callers" }, { $ref: "#/$defs/Kind" }],
}

let buffer = ""
process.stdin.on("data", (chunk) => {
buffer += chunk
for (let end = buffer.indexOf("\n"); end >= 0; end = buffer.indexOf("\n")) {
const message = JSON.parse(buffer.slice(0, end))
buffer = buffer.slice(end + 1)
if (message.id === undefined) continue
if (message.method === "initialize")
send({
jsonrpc: "2.0",
id: message.id,
result: {
protocolVersion: message.params.protocolVersion,
capabilities: { tools: {} },
serverInfo: { name: "anyof-output", version: "1.0.0" },
},
})
else if (message.method === "tools/list")
send({
jsonrpc: "2.0",
id: message.id,
result: {
tools: [
{ name: "plain", inputSchema: { type: "object" }, outputSchema: { type: "object" } },
{ name: "callers", inputSchema: { type: "object" }, outputSchema: callers },
],
},
})
else if (message.method === "tools/call")
send({ jsonrpc: "2.0", id: message.id, result: { content: [], structuredContent: { kind: "fallback" } } })
else send({ jsonrpc: "2.0", id: message.id, error: { code: -32601, message: "Method not found" } })
}
})
22 changes: 22 additions & 0 deletions 22 packages/core/test/mcp.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,28 @@ test("retains output schemas across paginated MCP discovery", async () => {
])
})

test("keeps an MCP server whose tool output schema has no top-level type", async () => {
const result = await Effect.runPromise(
Effect.scoped(
Effect.gen(function* () {
const connection = yield* connect(
"anyof-output",
new ConfigMCP.Local({
type: "local",
command: [process.execPath, path.join(import.meta.dir, "fixture/mcp-anyof-output.ts")],
}),
import.meta.dir,
)
return { tools: yield* connection.tools(), called: yield* connection.callTool({ name: "callers" }) }
}),
),
)

expect(result.tools.map((tool) => tool.name)).toEqual(["plain", "callers"])
expect(result.tools[1]?.outputSchema?.type).toBe("object")
expect(result.called.structured).toEqual({ kind: "fallback" })
})

test("lists paginated prompts and invokes them through the MCP client", async () => {
const result = await Effect.runPromise(
Effect.scoped(
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.