Skip to content

Commit 0d50c86

Browse files
committed
fix mcp tools corrupting session
1 parent 27f7e02 commit 0d50c86

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

opencode.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{
22
"$schema": "https://opencode.ai/config.json",
3+
"mcp": {
4+
"weather": {
5+
"type": "local",
6+
"command": ["opencode", "x", "@h1deya/mcp-server-weather"]
7+
}
8+
},
39
"experimental": {
410
"hook": {
511
"file_edited": {

packages/opencode/src/session/index.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -496,14 +496,20 @@ export namespace Session {
496496
const execute = item.execute
497497
if (!execute) continue
498498
item.execute = async (args, opts) => {
499-
try {
500-
const result = await execute(args, opts)
501-
return result.content
502-
.filter((x: any) => x.type === "text")
503-
.map((x: any) => x.text)
504-
.join("\n\n")
505-
} catch (e: any) {
506-
return e.toString()
499+
const result = await execute(args, opts)
500+
const output = result.content
501+
.filter((x: any) => x.type === "text")
502+
.map((x: any) => x.text)
503+
.join("\n\n")
504+
505+
return {
506+
output,
507+
}
508+
}
509+
item.toModelOutput = (result) => {
510+
return {
511+
type: "text",
512+
value: result.output,
507513
}
508514
}
509515
tools[key] = item

0 commit comments

Comments
 (0)