toolhive
toolhive copied to clipboard
Implement CompositeToolRefs resolution in VirtualMCPServer converter
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
- Update the converter to fetch referenced
VirtualMCPCompositeToolDefinitionresources - Convert the external definitions to
CompositeToolConfigentries - Merge them with inline
CompositeTools - 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)