Repository navigation
Conversation
With the vMCP optimizer on, clients reach code mode scripts through the optimizer's call_tool meta-tool, so code_mode_calls missed them and a report could show code_mode_tool_calls with no code_mode_calls. The usage middleware gains a WithCodeModeCall option. vMCP sets it when the optimizer is on, matching call_tool whose decoded target is execute_tool_script. Plain proxies never set it, since a backend there may have its own tool named call_tool. Co-Authored-By: Claude Opus 5.5 <[email protected]>
rdimitrov
marked this pull request as ready for review
November 24, 2026 21:29
rdimitrov
requested review from
aponcedeleonch,
jerm-dro,
jhrozek,
reyortiz3 and
tgrunnagle
November 24, 2026 21:29
6 tasks done
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## claude/vmcp-codemode-metrics-ed9fe3 #7286 +/- ##
====================================================================
Coverage 81.85% 81.86%
====================================================================
Files 916 916
Lines 92886 92901 +15
====================================================================
+ Hits 76031 76050 +19
+ Misses 16850 16846 -4
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rdimitrov
merged commit Nov 24, 2026
5c4f74a
into
claude/vmcp-codemode-metrics-ed9fe3
42 checks passed
rdimitrov
added a commit
that referenced
this pull request
Nov 24, 2026
…and logs (#7275) * Report code mode script tool calls in usage Tool calls a code mode script makes run inside vMCP and never reach the HTTP usage middleware, so the usage report does not see them. Add an optional OnScript observer to codemode.Config that receives the number of tool calls each script made, and have the vMCP CLI add it to the report as code_mode_tool_calls, separate from count. Part of #4744 Co-Authored-By: Claude Opus 5.5 <[email protected]> * Report pending script tool calls at day end Code mode script tool calls land when a script returns, so they can be pending while the day's count is zero: a script that straddled midnight, or the last script before shutdown. The midnight flush and the shutdown flush now also fire on pending code_mode_tool_calls, without adding them to count. Also align the OnScript doc with ScriptStats ("started", including failed and denied calls), note the accepted shutdown window for scripts still running past the HTTP drain, and document that code_mode_calls misses scripts reached through the optimizer's call_tool. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Add OTel metrics, spans and logs for code mode (#7278) Operators running vMCP with code mode cannot see how scripts behave: there is one debug line per script and no metric or span. Add per-install observability for execute_tool_script. - Metrics under the vMCP scope: toolhive_vmcp_script_executions, _duration, _tool_calls and _parallel_tasks, split by a status attribute (success, error, timeout, step_limit), plus a toolhive_vmcp_code_mode_enabled gauge on every server. - A codemode.ExecuteToolScript span per script with a codemode.CallTool child per inner call, under parallel() too. - Debug logs for script start and finish keyed by a script hash and session ID; the script body is never logged. The engine marks step-limit failures with script.ErrStepLimitExceeded, including inside parallel() children, and reports step count and parallel() fan-out through an optional Config.OnStats. Script results, limits and error messages are unchanged. Part of #4743 Part of #4744 Co-authored-by: Claude Opus 5.5 <[email protected]> * Count code mode calls made through the optimizer's call_tool (#7286) Count code mode calls made through call_tool With the vMCP optimizer on, clients reach code mode scripts through the optimizer's call_tool meta-tool, so code_mode_calls missed them and a report could show code_mode_tool_calls with no code_mode_calls. The usage middleware gains a WithCodeModeCall option. vMCP sets it when the optimizer is on, matching call_tool whose decoded target is execute_tool_script. Plain proxies never set it, since a backend there may have its own tool named call_tool. Co-authored-by: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #7275.
Summary
With the vMCP optimizer on, clients reach code mode scripts through the optimizer's
call_toolmeta-tool rather than callingexecute_tool_scriptdirectly. The anonymous usage report counted only direct calls, so it could showcode_mode_tool_callswith nocode_mode_calls.pkg/usagemetrics:NewMiddlewaretakes options.WithCodeModeCall(match)also counts atools/callas a code mode call whenmatchaccepts it. The directexecute_tool_scriptcheck is unchanged.pkg/vmcp/cli: vMCP passes that option only when the optimizer is on. Its matcher accepts acall_toolcall whose arguments decode, throughoptimizer.CallToolInput, totool_name: execute_tool_script. Names come fromoptimizerdec.CallToolNameandscript.ExecuteToolScriptName.docs/middleware.md:code_mode_callsnow describes both paths.Type of change
Test plan
go test -raceonpkg/usagemetricsandpkg/vmcp/cliThe vMCP test sends real JSON-RPC bodies through
mcp.ParsingMiddlewareand the usage middleware, then readscode_mode_callsfrom the final report. Cases: optimizer on withcall_tooltargetingexecute_tool_script(counted, including a differently casedTool_Nameand atool_namenested inparameters); optimizer on withcall_tooltargeting another tool or with undecodable arguments (not counted); optimizer off with the samecall_toolcall (not counted); a directexecute_tool_scriptcall (counted). Thepkg/usagemetricstable covers the option itself and a middleware without it, as a plain proxy uses it.Does this introduce a user-facing change?
Anonymous usage reports from vMCP with the optimizer on now include script calls made through
call_toolincode_mode_calls. Before, those calls showed up only incount.Special notes for reviewers
pkg/vmcp/cli/usage_metrics.goand is the only caller that setsWithCodeModeCall, and only when the optimizer config is set. Plain proxies build theirs throughCreateMiddleware, which sets no options, so a backend tool namedcall_toolthere is never treated as code mode. The collector's component (vmcp) was the other candidate, but gating at the composition root also covers the optimizer being off.optimizer.CallToolInputwithschema.Translate, the same call the authz middleware and dispatch use, so it sees the target they execute. IndexingArguments["tool_name"]would miss a nested or differently cased key. The decode runs only forcall_toolrequests.vmcpFeatures' parameteroptimizerbecameoptimizerEnabled:usage_metrics.gonow imports theoptimizerpackage, and revive flags the shadowing.TestUsageMetrics_CodeModeToolCallsReportednow uses the sharedreportAfterhelper, with the same assertions.🤖 Generated with Claude Code