toolhive icon indicating copy to clipboard operation
toolhive copied to clipboard

Implement CompositeToolRefs resolution in VirtualMCPServer converter

Open JAORMX opened this issue 4 weeks ago • 0 comments

Summary

The VirtualMCPServer CRD supports referencing external VirtualMCPCompositeToolDefinition resources via CompositeToolRefs, but the converter does not currently process these references.

Current State

CRD (cmd/thv-operator/api/v1alpha1/virtualmcpserver_types.go:32-35):

type VirtualMCPServerSpec struct {
    // CompositeTools defines inline composite tool definitions
    CompositeTools []CompositeToolSpec `json:"compositeTools,omitempty"`

    // CompositeToolRefs references VirtualMCPCompositeToolDefinition resources
    // for complex, reusable workflows
    CompositeToolRefs []CompositeToolDefinitionRef `json:"compositeToolRefs,omitempty"`
}

Converter (cmd/thv-operator/pkg/vmcpconfig/converter.go:67-70):

// Convert CompositeTools
if len(vmcp.Spec.CompositeTools) > 0 {
    config.CompositeTools = c.convertCompositeTools(ctx, vmcp)
}
// CompositeToolRefs are NOT processed

Impact

Users who define reusable composite workflows as separate VirtualMCPCompositeToolDefinition resources and reference them via compositeToolRefs will not have those workflows included in the generated vMCP configuration.

Proposed Solution

  1. Update the converter to fetch referenced VirtualMCPCompositeToolDefinition resources
  2. Convert the external definitions to CompositeToolConfig entries
  3. Merge them with inline CompositeTools
  4. Add validation for duplicate workflow names between inline and referenced tools

The converter will need access to a Kubernetes client to fetch the referenced resources.

Related Files

  • cmd/thv-operator/pkg/vmcpconfig/converter.go (converter)
  • cmd/thv-operator/api/v1alpha1/virtualmcpcompositetooldefinition_types.go (referenced CRD)
  • cmd/thv-operator/controllers/virtualmcpserver_vmcpconfig.go (controller)

JAORMX avatar Nov 27 '25 17:11 JAORMX