Skip to content

Document the code mode split behind the vMCP optimizer - #7294

Merged
rdimitrov merged 1 commit into
mainfrom
claude/codemode-otel-optimizer-split-0b24fc
Nov 25, 2026
Merged

rdimitrov merged 1 commit into
mainfrom
claude/codemode-otel-optimizer-split-0b24fc

Conversation

@rdimitrov

@rdimitrov rdimitrov commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Summary

With the vMCP optimizer on, clients see only find_tool and call_tool, so toolhive_mcp_tool_calls labels every call tool="call_tool" and never shows execute_tool_script. The code mode split documented for #4744 (shipped in #7275) is therefore blind to scripts on any vMCP that runs the optimizer. The script metrics and the usage report count correctly in that mode; only the documented PromQL split was missing.

The optimizer's existing toolhive_vmcp_optimizer_call_tool_requests counter already labels each call_tool call with its target as tool_name, so the split needs no new series or labels:

  • docs/operator/virtualmcpserver-observability.md states which series holds the split with and without the optimizer, and gives PromQL that unions the two counters with or. The queries work for either mode and for a fleet that mixes both, fleet-wide or by (instance). The regular-call side now excludes find_tool and call_tool, which the previous tool!="execute_tool_script" query would have counted as regular calls.
  • TestIntegration_CodeModeTelemetry gains an optimizer case: it runs a script and a regular tool through call_tool over the real HTTP chain and checks /metrics for tool="call_tool" 2 on the request counter and tool_name="execute_tool_script" 1 and tool_name="search-svc_search" 1 on the optimizer counter, proving the script's inner calls do not reach the optimizer.

Completes the split from #4744 for the optimizer case.

Type of change

  • Documentation

Test plan

  • Unit tests (task test)
  • Linting (task lint-fix)
  • Manual testing (describe below)

go test -race on ./pkg/vmcp/server/... passes (integration test also run with -count=5), and golangci-lint v2.15.0 reports 0 issues on the package. Every query in the doc was checked with promtool test rules (Prometheus v3.5.0) against series shaped like the scraped /metrics output: a mixed fleet (one server without the optimizer: 4 scripts and 3 direct calls; one with it: 2 find_tool, 1 call_tool to a script, 2 to a regular tool) gave 5 scripts, 5 regular calls, share 0.5, and per instance 4/3 and 1/2; a fleet with no optimizer at all gave 4 and 3.

Does this introduce a user-facing change?

Documentation only. Before: the documented split queried toolhive_mcp_tool_calls{tool="execute_tool_script"}, which reads zero on a vMCP with the optimizer on, and counted find_tool/call_tool as regular calls. After: the documented queries count scripts and regular calls correctly with or without the optimizer. No metric, label or default changes.

Special notes for reviewers

  • Why not a code change: the optimizer counter already carries the resolved target, and or is safe because one vMCP process runs either with or without the optimizer, so each server reports through exactly one of the two series. A new label on toolhive_mcp_tool_calls would duplicate that.
  • The optimizer counter has no server attribute, so the per-server split groups by a scrape target label (instance), as the doc says.
  • tool_name on the optimizer counter is the name the client passed to call_tool, including unknown names, so its cardinality is bounded by the client, not by the tool catalog. That is pre-existing and unchanged here.

🤖 Generated with Claude Code

With the optimizer on, clients only call find_tool and call_tool, so
toolhive_mcp_tool_calls never shows execute_tool_script and the
documented PromQL split could not see scripts. The optimizer's
call_tool counter already labels each call with its target tool, so
the split needs no new series: document queries that union the two
counters and work with or without the optimizer, and extend the code
mode telemetry integration test to cover the optimizer case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the size/S Small PR: 100-299 lines changed label Nov 24, 2026
@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.89%. Comparing base (3b6fe79) to head (180b012).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7294      +/-   ##
==========================================
- Coverage   81.90%   81.89%   -0.02%     
==========================================
  Files         921      921              
  Lines       93181    93181              
==========================================
- Hits        76322    76310      -12     
- Misses      16854    16866      +12     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rdimitrov
rdimitrov merged commit 7f6b5da into main Nov 25, 2026
46 of 47 checks passed
@rdimitrov
rdimitrov deleted the claude/codemode-otel-optimizer-split-0b24fc branch November 25, 2026 00:03
@github-actions github-actions Bot mentioned this pull request Nov 25, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant