Skip to content

MCP tool results are collected as empty {} #22

Closed

Description

@Azther0z

Problem

MCP tool calling is not collected to the langfuse by plugin. Opencode emits tool call result as {title:"...",output:"..."} which the plugin collects correctly, but for MCP call, opencode emits {content:[...]}, which is not compatible with current plugin behavior. So, the langfuse collect {} as output of the MCP call instead.

Image

Cause

src/index.ts:549-561 reads output.title / output.output, then
src/langfuse.ts:913-915 does:

JSON.stringify({ title: input.title, output: input.output })

Both are undefined for MCP tools, and JSON.stringify drops undefined
properties, so it's exactly "{}". Same input.output also feeds rememberToolResult({ content: input.output })
(src/langfuse.ts:932), so the content is lost there too.

Reproduce

// .opencode/plugin/probe.js
import { appendFileSync } from "node:fs";
export const ProbePlugin = async () => ({
  "tool.execute.after": async (input, output) => {
    appendFileSync("/tmp/probe.log", JSON.stringify({
      tool: input.tool,
      outputKeys: Object.keys(output ?? {}),
      payload: JSON.stringify({ title: output?.title, output: output?.output }),
    }) + "\n");
  },
});
export default ProbePlugin;

Run one native tool and one MCP tool:

{"tool":"bash","outputKeys":["title","metadata","output","attachments"],
 "payload":"{\"title\":\"echo hello\",\"output\":\"hello\\n\"}"}

{"tool":"context7_resolve-library-id","outputKeys":["content"],
 "payload":"{}"}

Happens with every MCP server I tried (context7, playwright, sonarqube).

Note: @opencode-ai/plugin declares the hook as
output: { title: string; output: string; metadata: any }
(dist/index.d.ts:249-258), so OpenCode isn't honouring its own type here —
might need an upstream fix too.

Environment

  • OpenCode: 1.18.16
  • Plugin: 0.2.0
  • Langfuse: Cloud (US)

Activity

  1. bezbac commented on Aug 18, 2026

    @bezbac
    Member

    Hi @Azther0z, thanks for creating an issue here. I just checked and noticed this in my own traces as well.

    Would you be interested in contributing a fix? We just opened up the repo to pull requests a few hours ago.

    If not, this is something I’m planning to take a look at in the near term.

  2. Azther0z commented on Aug 18, 2026

    @Azther0z
    ContributorAuthor

    Yes, I am happy to contribute. I should have a PR up in a day or two. Thank you for the opportunity.

  3. added a commit that references this issue on Aug 19, 2026
  4. Azther0z commented on Aug 19, 2026

    @Azther0z
    ContributorAuthor

    Submitted #31

  5. bezbac commented on Aug 20, 2026

    @bezbac
    Member

    This was released as part of v0.3.0.

    You might need to update your OpenCode config to explicitly reference this version if you’ve already used a prior version.

    "plugin": [
      "@langfuse/opencode-observability-plugin@0.3.0",
    ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions