Skip to content

Commit bd962c6

Browse files
authored
Merge branch 'main' into feat/vmcp_composition_multistep
2 parents 09c8ef4 + 107ea07 commit bd962c6

File tree

12 files changed

+52
-53
lines changed

12 files changed

+52
-53
lines changed

cmd/thv-operator/api/v1alpha1/virtualmcpcompositetooldefinition_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,12 @@ func (*VirtualMCPCompositeToolDefinition) validateStepType(index int, step Workf
233233
WorkflowStepTypeElicitation: true,
234234
}
235235
if !validTypes[stepType] {
236-
return fmt.Errorf("spec.steps[%d].type must be one of: tool_call, elicitation", index)
236+
return fmt.Errorf("spec.steps[%d].type must be one of: tool, elicitation", index)
237237
}
238238

239239
if stepType == WorkflowStepTypeToolCall {
240240
if step.Tool == "" {
241-
return fmt.Errorf("spec.steps[%d].tool is required when type is tool_call", index)
241+
return fmt.Errorf("spec.steps[%d].tool is required when type is tool", index)
242242
}
243243
if !isValidToolReference(step.Tool) {
244244
return fmt.Errorf("spec.steps[%d].tool must be in format 'workload.tool_name'", index)

cmd/thv-operator/api/v1alpha1/virtualmcpcompositetooldefinition_webhook_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func TestVirtualMCPCompositeToolDefinitionValidate(t *testing.T) {
171171
errMsg: "spec.steps[0].id is required",
172172
},
173173
{
174-
name: "missing tool for tool_call step",
174+
name: "missing tool for tool step",
175175
ctd: &VirtualMCPCompositeToolDefinition{
176176
Spec: VirtualMCPCompositeToolDefinitionSpec{
177177
Name: "deploy_app",
@@ -186,7 +186,7 @@ func TestVirtualMCPCompositeToolDefinitionValidate(t *testing.T) {
186186
},
187187
},
188188
wantErr: true,
189-
errMsg: "spec.steps[0].tool is required when type is tool_call",
189+
errMsg: "spec.steps[0].tool is required when type is tool",
190190
},
191191
{
192192
name: "invalid tool reference format",

cmd/thv-operator/api/v1alpha1/virtualmcpserver_types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,14 @@ type WorkflowStep struct {
226226
// +kubebuilder:validation:Required
227227
ID string `json:"id"`
228228

229-
// Type is the step type (tool_call, elicitation, etc.)
230-
// +kubebuilder:validation:Enum=tool_call;elicitation
231-
// +kubebuilder:default=tool_call
229+
// Type is the step type (tool, elicitation, etc.)
230+
// +kubebuilder:validation:Enum=tool;elicitation
231+
// +kubebuilder:default=tool
232232
// +optional
233233
Type string `json:"type,omitempty"`
234234

235235
// Tool is the tool to call (format: "workload.tool_name")
236-
// Only used when Type is "tool_call"
236+
// Only used when Type is "tool"
237237
// +optional
238238
Tool string `json:"tool,omitempty"`
239239

@@ -505,7 +505,7 @@ const (
505505
// Workflow step types
506506
const (
507507
// WorkflowStepTypeToolCall calls a backend tool
508-
WorkflowStepTypeToolCall = "tool_call"
508+
WorkflowStepTypeToolCall = "tool"
509509

510510
// WorkflowStepTypeElicitation requests user input
511511
WorkflowStepTypeElicitation = "elicitation"

cmd/thv-operator/api/v1alpha1/virtualmcpserver_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func validateCompositeToolStep(
283283
// validateStepType validates the step type and type-specific requirements
284284
func validateStepType(toolIndex, stepIndex int, step WorkflowStep) error {
285285
if step.Type != "" && step.Type != WorkflowStepTypeToolCall && step.Type != WorkflowStepTypeElicitation {
286-
return fmt.Errorf("spec.compositeTools[%d].steps[%d].type must be tool_call or elicitation", toolIndex, stepIndex)
286+
return fmt.Errorf("spec.compositeTools[%d].steps[%d].type must be tool or elicitation", toolIndex, stepIndex)
287287
}
288288

289289
stepType := step.Type
@@ -292,7 +292,7 @@ func validateStepType(toolIndex, stepIndex int, step WorkflowStep) error {
292292
}
293293

294294
if stepType == WorkflowStepTypeToolCall && step.Tool == "" {
295-
return fmt.Errorf("spec.compositeTools[%d].steps[%d].tool is required when type is tool_call", toolIndex, stepIndex)
295+
return fmt.Errorf("spec.compositeTools[%d].steps[%d].tool is required when type is tool", toolIndex, stepIndex)
296296
}
297297

298298
if stepType == WorkflowStepTypeElicitation && step.Message == "" {

cmd/thv-operator/api/v1alpha1/virtualmcpserver_webhook_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func TestVirtualMCPServerValidate(t *testing.T) {
306306
errMsg: "spec.compositeTools[0].steps[0].id is required",
307307
},
308308
{
309-
name: "invalid composite tool - tool_call step without tool",
309+
name: "invalid composite tool - tool step without tool",
310310
vmcp: &VirtualMCPServer{
311311
Spec: VirtualMCPServerSpec{
312312
GroupRef: GroupRef{Name: "test-group"},
@@ -325,7 +325,7 @@ func TestVirtualMCPServerValidate(t *testing.T) {
325325
},
326326
},
327327
wantErr: true,
328-
errMsg: "spec.compositeTools[0].steps[0].tool is required when type is tool_call",
328+
errMsg: "spec.compositeTools[0].steps[0].tool is required when type is tool",
329329
},
330330
{
331331
name: "invalid composite tool - elicitation step without message",

deploy/charts/operator-crds/crds/toolhive.stacklok.dev_virtualmcpcompositetooldefinitions.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,13 @@ spec:
204204
tool:
205205
description: |-
206206
Tool is the tool to call (format: "workload.tool_name")
207-
Only used when Type is "tool_call"
207+
Only used when Type is "tool"
208208
type: string
209209
type:
210-
default: tool_call
211-
description: Type is the step type (tool_call, elicitation,
212-
etc.)
210+
default: tool
211+
description: Type is the step type (tool, elicitation, etc.)
213212
enum:
214-
- tool_call
213+
- tool
215214
- elicitation
216215
type: string
217216
required:

deploy/charts/operator-crds/crds/toolhive.stacklok.dev_virtualmcpservers.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,14 @@ spec:
265265
tool:
266266
description: |-
267267
Tool is the tool to call (format: "workload.tool_name")
268-
Only used when Type is "tool_call"
268+
Only used when Type is "tool"
269269
type: string
270270
type:
271-
default: tool_call
272-
description: Type is the step type (tool_call, elicitation,
271+
default: tool
272+
description: Type is the step type (tool, elicitation,
273273
etc.)
274274
enum:
275-
- tool_call
275+
- tool
276276
- elicitation
277277
type: string
278278
required:

docs/operator/crd-api.md

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/registry/converters/registry_converters.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ import (
99
"github.com/stacklok/toolhive/pkg/registry/types"
1010
)
1111

12-
// NewServerRegistryFromUpstream creates a ServerRegistry from upstream ServerJSON array.
12+
// NewUpstreamRegistryFromUpstreamServers creates a UpstreamRegistry from upstream ServerJSON array.
1313
// This is used when ingesting data from upstream MCP Registry API endpoints.
14-
func NewServerRegistryFromUpstream(servers []upstreamv0.ServerJSON) *types.ServerRegistry {
15-
return &types.ServerRegistry{
14+
func NewUpstreamRegistryFromUpstreamServers(servers []upstreamv0.ServerJSON) *types.UpstreamRegistry {
15+
return &types.UpstreamRegistry{
1616
Version: "1.0.0",
1717
LastUpdated: time.Now().Format(time.RFC3339),
1818
Servers: servers,
1919
}
2020
}
2121

22-
// NewServerRegistryFromToolhive creates a ServerRegistry from ToolHive Registry.
22+
// NewUpstreamRegistryFromToolhiveRegistry creates a UpstreamRegistry from ToolHive Registry.
2323
// This converts ToolHive format to upstream ServerJSON using the converters package.
2424
// Used when ingesting data from ToolHive-format sources (Git, File, API).
25-
func NewServerRegistryFromToolhive(toolhiveReg *types.Registry) (*types.ServerRegistry, error) {
25+
func NewUpstreamRegistryFromToolhiveRegistry(toolhiveReg *types.Registry) (*types.UpstreamRegistry, error) {
2626
if toolhiveReg == nil {
2727
return nil, fmt.Errorf("toolhive registry cannot be nil")
2828
}
@@ -47,7 +47,7 @@ func NewServerRegistryFromToolhive(toolhiveReg *types.Registry) (*types.ServerRe
4747
servers = append(servers, *serverJSON)
4848
}
4949

50-
return &types.ServerRegistry{
50+
return &types.UpstreamRegistry{
5151
Version: toolhiveReg.Version,
5252
LastUpdated: toolhiveReg.LastUpdated,
5353
Servers: servers,

pkg/registry/converters/registry_converters_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import (
1212
"github.com/stacklok/toolhive/pkg/registry/types"
1313
)
1414

15-
func TestNewServerRegistryFromToolhive(t *testing.T) {
15+
func TestNewUpstreamRegistryFromToolhiveRegistry(t *testing.T) {
1616
t.Parallel()
1717

1818
tests := []struct {
1919
name string
2020
toolhiveReg *types.Registry
2121
expectError bool
22-
validate func(*testing.T, *types.ServerRegistry)
22+
validate func(*testing.T, *types.UpstreamRegistry)
2323
}{
2424
{
2525
name: "successful conversion with container servers",
@@ -42,7 +42,7 @@ func TestNewServerRegistryFromToolhive(t *testing.T) {
4242
RemoteServers: make(map[string]*types.RemoteServerMetadata),
4343
},
4444
expectError: false,
45-
validate: func(t *testing.T, sr *types.ServerRegistry) {
45+
validate: func(t *testing.T, sr *types.UpstreamRegistry) {
4646
t.Helper()
4747
assert.Equal(t, "1.0.0", sr.Version)
4848
assert.Equal(t, "2024-01-01T00:00:00Z", sr.LastUpdated)
@@ -72,7 +72,7 @@ func TestNewServerRegistryFromToolhive(t *testing.T) {
7272
},
7373
},
7474
expectError: false,
75-
validate: func(t *testing.T, sr *types.ServerRegistry) {
75+
validate: func(t *testing.T, sr *types.UpstreamRegistry) {
7676
t.Helper()
7777
assert.Len(t, sr.Servers, 1)
7878
assert.Contains(t, sr.Servers[0].Name, "remote-server")
@@ -87,7 +87,7 @@ func TestNewServerRegistryFromToolhive(t *testing.T) {
8787
RemoteServers: make(map[string]*types.RemoteServerMetadata),
8888
},
8989
expectError: false,
90-
validate: func(t *testing.T, sr *types.ServerRegistry) {
90+
validate: func(t *testing.T, sr *types.UpstreamRegistry) {
9191
t.Helper()
9292
assert.Empty(t, sr.Servers)
9393
},
@@ -98,7 +98,7 @@ func TestNewServerRegistryFromToolhive(t *testing.T) {
9898
t.Run(tt.name, func(t *testing.T) {
9999
t.Parallel()
100100

101-
result, err := NewServerRegistryFromToolhive(tt.toolhiveReg)
101+
result, err := NewUpstreamRegistryFromToolhiveRegistry(tt.toolhiveReg)
102102

103103
if tt.expectError {
104104
assert.Error(t, err)
@@ -114,13 +114,13 @@ func TestNewServerRegistryFromToolhive(t *testing.T) {
114114
}
115115
}
116116

117-
func TestNewServerRegistryFromUpstream(t *testing.T) {
117+
func TestNewUpstreamRegistryFromUpstreamServers(t *testing.T) {
118118
t.Parallel()
119119

120120
tests := []struct {
121121
name string
122122
servers []upstreamv0.ServerJSON
123-
validate func(*testing.T, *types.ServerRegistry)
123+
validate func(*testing.T, *types.UpstreamRegistry)
124124
}{
125125
{
126126
name: "create from upstream servers",
@@ -139,7 +139,7 @@ func TestNewServerRegistryFromUpstream(t *testing.T) {
139139
},
140140
},
141141
},
142-
validate: func(t *testing.T, sr *types.ServerRegistry) {
142+
validate: func(t *testing.T, sr *types.UpstreamRegistry) {
143143
t.Helper()
144144
assert.Equal(t, "1.0.0", sr.Version)
145145
assert.NotEmpty(t, sr.LastUpdated)
@@ -150,7 +150,7 @@ func TestNewServerRegistryFromUpstream(t *testing.T) {
150150
{
151151
name: "create from empty slice",
152152
servers: []upstreamv0.ServerJSON{},
153-
validate: func(t *testing.T, sr *types.ServerRegistry) {
153+
validate: func(t *testing.T, sr *types.UpstreamRegistry) {
154154
t.Helper()
155155
assert.Empty(t, sr.Servers)
156156
},
@@ -161,7 +161,7 @@ func TestNewServerRegistryFromUpstream(t *testing.T) {
161161
t.Run(tt.name, func(t *testing.T) {
162162
t.Parallel()
163163

164-
result := NewServerRegistryFromUpstream(tt.servers)
164+
result := NewUpstreamRegistryFromUpstreamServers(tt.servers)
165165

166166
assert.NotNil(t, result)
167167
if tt.validate != nil {
@@ -183,7 +183,7 @@ func TestNewServerRegistryFromUpstream_DefaultValues(t *testing.T) {
183183
},
184184
}
185185

186-
result := NewServerRegistryFromUpstream(servers)
186+
result := NewUpstreamRegistryFromUpstreamServers(servers)
187187

188188
// Verify defaults
189189
assert.Equal(t, "1.0.0", result.Version)

0 commit comments

Comments
 (0)