Skip to content

Commit be22750

Browse files
authored
fix(opencode): expose structured MCP output (#32074)
1 parent 4ddfa7c commit be22750

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

packages/opencode/src/mcp/catalog.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ export function convertTool(mcpTool: MCPToolDef, client: Client, timeout?: numbe
5050
return dynamicTool({
5151
description: mcpTool.description ?? "",
5252
inputSchema: jsonSchema(inputSchema),
53-
execute: (args: unknown, options) =>
54-
client.callTool(
53+
execute: async (args: unknown, options) => {
54+
const result = await client.callTool(
5555
{
5656
name: mcpTool.name,
5757
arguments: (args || {}) as Record<string, unknown>,
@@ -62,7 +62,13 @@ export function convertTool(mcpTool: MCPToolDef, client: Client, timeout?: numbe
6262
signal: options.abortSignal,
6363
timeout,
6464
},
65-
),
65+
)
66+
if (result.structuredContent === undefined || result.structuredContent === null) return result
67+
return {
68+
...result,
69+
content: [{ type: "text" as const, text: JSON.stringify(result.structuredContent) }],
70+
}
71+
},
6672
})
6773
}
6874

0 commit comments

Comments
 (0)