Skip to content

Commit ea6cd79

Browse files
carlos-gnclaude
andcommitted
Remove redundant ToolType field from Workload
The ToolType field in the Workload struct mapped to either "mcp" (container workloads) or "remote" (remote workloads), but since MCP is the only alternative type in practice, the field has become unnecessary and adds no value. This change eliminates the redundant field from the codebase, simplifying the business logic that previously checked both ToolType and Remote fields. The condition "ToolType != 'mcp' && !Remote" now simplifies to just checking the Remote field directly. Changes: - Remove ToolType field from core.Workload struct - Delete LabelToolType constant and GetToolType function from labels package - Simplify shouldSkipWorkload logic in client manager - Remove ToolType from CLI list command output - Remove tool_type from backend metadata (workloads and vMCP) - Update all affected tests - Update API documentation (swagger.yaml) and regenerate docs Fixes #2923 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: carlos <carlosgn@protonmail.com>
1 parent 55d0cee commit ea6cd79

File tree

16 files changed

+9
-96
lines changed

16 files changed

+9
-96
lines changed

cmd/thv/app/list.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func printTextOutput(workloadList []core.Workload) {
136136

137137
// Create a tabwriter for pretty output
138138
w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
139-
fmt.Fprintln(w, "NAME\tPACKAGE\tSTATUS\tURL\tPORT\tTOOL TYPE\tGROUP\tCREATED AT")
139+
fmt.Fprintln(w, "NAME\tPACKAGE\tSTATUS\tURL\tPORT\tGROUP\tCREATED AT")
140140

141141
// Print workload information
142142
for _, c := range workloadList {
@@ -147,13 +147,12 @@ func printTextOutput(workloadList []core.Workload) {
147147
}
148148

149149
// Print workload information
150-
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\t%s\t%s\t%s\n",
150+
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\t%s\t%s\n",
151151
c.Name,
152152
c.Package,
153153
status,
154154
c.URL,
155155
c.Port,
156-
c.ToolType,
157156
c.Group,
158157
c.CreatedAt,
159158
)

docs/server/docs.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/server/swagger.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/server/swagger.yaml

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

pkg/client/manager.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ import (
1313
"github.com/stacklok/toolhive/pkg/logger"
1414
)
1515

16-
const (
17-
mcpToolType = "mcp"
18-
)
19-
2016
// Client represents a registered ToolHive client.
2117
type Client struct {
2218
Name MCPClient `json:"name"`
@@ -206,9 +202,9 @@ func (m *defaultManager) RemoveServerFromClients(ctx context.Context, serverName
206202
}
207203

208204
// shouldSkipWorkload determines if a workload should be skipped when adding/removing servers from clients.
209-
// Workloads are skipped if they are not MCP tool type and if they are not remote.
205+
// Workloads are skipped if they are not remote.
210206
func shouldSkipWorkload(workload core.Workload) bool {
211-
return workload.ToolType != mcpToolType && !workload.Remote
207+
return !workload.Remote
212208
}
213209

214210
// addWorkloadsToClient adds the specified workloads to the client's configuration

pkg/core/workload.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ type Workload struct {
2222
// Port is the port on which the workload is exposed.
2323
// This is embedded in the URL.
2424
Port int `json:"port"`
25-
// ToolType is the type of tool this workload represents.
26-
// For now, it will always be "mcp" - representing an MCP server.
27-
ToolType string `json:"tool_type"`
2825
// TransportType is the type of transport used for this workload.
2926
TransportType types.TransportType `json:"transport_type"`
3027
// ProxyMode is the proxy mode that clients should use to connect.

pkg/core/workload_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ func TestSortWorkloadsByName(t *testing.T) {
9393
Package: "zebra-pkg",
9494
URL: "http://localhost:8080",
9595
Port: 8080,
96-
ToolType: "mcp",
9796
TransportType: types.TransportTypeSSE,
9897
Status: runtime.WorkloadStatusRunning,
9998
StatusContext: "healthy",
@@ -108,7 +107,6 @@ func TestSortWorkloadsByName(t *testing.T) {
108107
Package: "alpha-pkg",
109108
URL: "http://localhost:8081",
110109
Port: 8081,
111-
ToolType: "mcp",
112110
TransportType: types.TransportTypeStdio,
113111
Status: runtime.WorkloadStatusStopped,
114112
StatusContext: "stopped",
@@ -159,7 +157,6 @@ func TestSortWorkloadsByName(t *testing.T) {
159157
assert.Equal(t, originalWorkload.Package, sortedWorkload.Package)
160158
assert.Equal(t, originalWorkload.URL, sortedWorkload.URL)
161159
assert.Equal(t, originalWorkload.Port, sortedWorkload.Port)
162-
assert.Equal(t, originalWorkload.ToolType, sortedWorkload.ToolType)
163160
assert.Equal(t, originalWorkload.TransportType, sortedWorkload.TransportType)
164161
assert.Equal(t, originalWorkload.Status, sortedWorkload.Status)
165162
assert.Equal(t, originalWorkload.StatusContext, sortedWorkload.StatusContext)

pkg/labels/labels.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ const (
2727
// LabelPort is the label that contains the port
2828
LabelPort = "toolhive-port"
2929

30-
// LabelToolType is the label that indicates the type of tool
31-
LabelToolType = "toolhive-tool-type"
32-
3330
// LabelNetworkIsolation indicates that the network isolation functionality is enabled.
3431
LabelNetworkIsolation = "toolhive-network-isolation"
3532

@@ -50,9 +47,6 @@ func AddStandardLabels(labels map[string]string, containerName, containerBaseNam
5047
labels[LabelBaseName] = containerBaseName
5148
labels[LabelTransport] = transportType
5249
labels[LabelPort] = fmt.Sprintf("%d", port)
53-
54-
// TODO: In the future, we'll support different tool types beyond just "mcp"
55-
labels[LabelToolType] = "mcp"
5650
}
5751

5852
// AddNetworkLabels adds network-related labels to a network
@@ -116,11 +110,6 @@ func GetPort(labels map[string]string) (int, error) {
116110
return port, nil
117111
}
118112

119-
// GetToolType gets the tool type from labels
120-
func GetToolType(labels map[string]string) string {
121-
return labels[LabelToolType]
122-
}
123-
124113
// GetGroup gets the group name from labels
125114
func GetGroup(labels map[string]string) string {
126115
return labels[LabelGroup]
@@ -147,7 +136,6 @@ func IsStandardToolHiveLabel(key string) bool {
147136
LabelBaseName,
148137
LabelTransport,
149138
LabelPort,
150-
LabelToolType,
151139
LabelNetworkIsolation,
152140
}
153141

pkg/labels/labels_test.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ func TestAddStandardLabels(t *testing.T) {
2626
LabelBaseName: "test-base",
2727
LabelTransport: "http",
2828
LabelPort: "8080",
29-
LabelToolType: "mcp",
3029
},
3130
},
3231
{
@@ -41,7 +40,6 @@ func TestAddStandardLabels(t *testing.T) {
4140
LabelBaseName: "another-base",
4241
LabelTransport: "https",
4342
LabelPort: "9090",
44-
LabelToolType: "mcp",
4543
},
4644
},
4745
{
@@ -56,7 +54,6 @@ func TestAddStandardLabels(t *testing.T) {
5654
LabelBaseName: "group-base",
5755
LabelTransport: "sse",
5856
LabelPort: "7070",
59-
LabelToolType: "mcp",
6057
},
6158
},
6259
}
@@ -390,11 +387,6 @@ func TestIsStandardToolHiveLabel(t *testing.T) {
390387
key: LabelPort,
391388
expected: true,
392389
},
393-
{
394-
name: "Standard tool type label",
395-
key: LabelToolType,
396-
expected: true,
397-
},
398390
{
399391
name: "Standard network isolation label",
400392
key: LabelNetworkIsolation,
@@ -693,35 +685,3 @@ func TestParseLabelValidation(t *testing.T) {
693685
})
694686
}
695687
}
696-
697-
func TestGetToolType(t *testing.T) {
698-
t.Parallel()
699-
tests := []struct {
700-
name string
701-
labels map[string]string
702-
expected string
703-
}{
704-
{
705-
name: "Tool type exists",
706-
labels: map[string]string{
707-
LabelToolType: "mcp",
708-
},
709-
expected: "mcp",
710-
},
711-
{
712-
name: "Tool type doesn't exist",
713-
labels: map[string]string{},
714-
expected: "",
715-
},
716-
}
717-
718-
for _, tc := range tests {
719-
t.Run(tc.name, func(t *testing.T) {
720-
t.Parallel()
721-
result := GetToolType(tc.labels)
722-
if result != tc.expected {
723-
t.Errorf("Expected tool type to be %s, but got %s", tc.expected, result)
724-
}
725-
})
726-
}
727-
}

pkg/runner/config_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ func TestRunConfig_WithStandardLabels(t *testing.T) {
460460
"toolhive-name": "test-server",
461461
"toolhive-transport": "sse",
462462
"toolhive-port": "60000",
463-
"toolhive-tool-type": "mcp",
464463
},
465464
},
466465
{
@@ -477,7 +476,6 @@ func TestRunConfig_WithStandardLabels(t *testing.T) {
477476
"toolhive": "true",
478477
"toolhive-name": "test-server",
479478
"toolhive-transport": "stdio",
480-
"toolhive-tool-type": "mcp",
481479
"existing-label": "existing-value",
482480
},
483481
},
@@ -496,7 +494,6 @@ func TestRunConfig_WithStandardLabels(t *testing.T) {
496494
"toolhive-name": "test-server",
497495
"toolhive-transport": "sse", // Should be "sse" not "stdio"
498496
"toolhive-port": "60000",
499-
"toolhive-tool-type": "mcp",
500497
},
501498
},
502499
{
@@ -514,7 +511,6 @@ func TestRunConfig_WithStandardLabels(t *testing.T) {
514511
"toolhive-name": "test-server",
515512
"toolhive-transport": "streamable-http", // Should be "streamable-http" not "stdio"
516513
"toolhive-port": "60000",
517-
"toolhive-tool-type": "mcp",
518514
},
519515
},
520516
}

0 commit comments

Comments
 (0)