Skip to content

fix: dedupe MCP tools when transcript uses CallDynamicTool - #18

Open
Samdam93 wants to merge 1 commit into
langfuse:mainfrom
Samdam93:fix/dedupe-call-dynamic-tool-mcp
Open

Samdam93 wants to merge 1 commit into
langfuse:mainfrom
Samdam93:fix/dedupe-call-dynamic-tool-mcp

Conversation

@Samdam93

Copy link
Copy Markdown

Summary

  • Pair preToolUse / postToolUse and MCP hook events with transcript CallDynamicTool rows so each dynamic MCP invocation produces a single Langfuse tool observation.
  • Preserve hook timing (start/end, duration) and use transcript namespace + toolName for display names (e.g. user-atlas.grep instead of a duplicate zero-latency MCP:grep span).
  • Add assemble and trace tests covering the hook vs transcript naming mismatch.

Problem

Cursor reports the same MCP call under different names on hooks (MCP:tool) vs the agent transcript (CallDynamicTool with namespace / toolName). buildGenerationsFromTranscript only matched identical names, so the assembler kept the timed hook span and added a second transcript-only tool with startTime === endTime.

Test plan

  • pnpm exec vitest run test/assemble.test.ts
  • pnpm exec vitest run test/trace.test.ts (includes MCP dedupe case)
  • pnpm run build (committed dist/ matches sources)

Pair hook events (MCP:tool, before/afterMCPExecution) with transcript
CallDynamicTool rows so Langfuse emits one tool span per call with real
latency and namespace.toolName display names.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants