Skip to content

vMCP Code Mode #4741

@jerm-dro

Description

@jerm-dro

Overview

Add opt-in Starlark script execution ("code mode") to vMCP, allowing agents to batch multi-tool workflows into a single server-side call — reducing round-trips, context bloat, and inference cycles. Based on the prototype in PR #4714.

Background

Agents today make sequential tool calls with model inference between each one. For multi-service workflows (e.g., incident triage across PagerDuty, Datadog, Slack, Jira), this means 10+ round-trips and significant token spend. Scripting is possible today only through CLI/shell access, which is less safe and unavailable for knowledge worker use cases where agents lack a shell environment. The prototype demonstrates ~15s improvement by executing a Starlark script server-side that calls tools directly, with parallel() fan-out — without requiring shell access.

This epic production-hardens the prototype and ships it as an opt-in feature. It does NOT implement the full RFC THV-0060 session initialization model.

User Story Breakdown

Story ID Title Description Persona Goal Acceptance Criteria GitHub Issue #
STORY-001 Ship opt-in code mode for vMCP As a platform engineer, I want my agents to be able to execute scripts on tools without shell access so that they can safely reduce context bloat and inference cycles Platform engineer Enable server-side script execution for agents Config toggle, proper dispatch, configurable limits, timeouts, optimizer compat
STORY-002 Add observability for script execution As a cluster operator, I want logging and metrics for script execution so that I can monitor and diagnose issues Cluster operator Operational visibility Structured logs, execution metrics, telemetry integration
STORY-003 Track code mode adoption and usage As a ToolHive developer, I want to know how many people are opting in to code mode and how many tool calls come through it so that I can gauge adoption and prioritize investment ToolHive developer Understand adoption Opt-in counts, call volume comparison, telemetry pipeline

Acceptance Criteria

  • Code mode can be enabled per-VirtualMCPServer via config flag
  • Agents can execute Starlark scripts with tool calls, loops, conditionals, and parallel()
  • Script execution is bounded (step limits, concurrency caps, timeouts)
  • Works correctly with optimizer enabled
  • Observability: logs and metrics for script execution
  • Adoption tracking: code mode opt-in and call volume metrics
  • All linked user stories completed

References

Metadata

Metadata

Assignees

Labels

code-modevMCP Code Mode (Starlark script middleware)enhancementNew feature or requestgoPull requests that update go code

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions