Skip to content

Commit 53dbeee

Browse files
Rename MCPServer CRD port attributes for clarity
- Rename `port` to `proxyPort` - represents proxy runner port - Rename `targetPort` to `mcpPort` - represents MCP server port This change addresses user confusion about port semantics as discussed in issue #1452. The new names clearly indicate which port corresponds to which component: - proxyPort: Port exposed by the proxy runner in Kubernetes - mcpPort: Port that the MCP server listens on internally Updated all relevant files: - CRD types definition and generated YAML - Operator controller logic - All example and test YAML files - Keycloak deployment example 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Chris Burns <[email protected]>
1 parent 3103ffc commit 53dbeee

22 files changed

+51
-51
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ type MCPServerSpec struct {
1616
// +kubebuilder:default=stdio
1717
Transport string `json:"transport,omitempty"`
1818

19-
// Port is the port to expose the MCP server on
19+
// ProxyPort is the port to expose the proxy runner on
2020
// +kubebuilder:validation:Minimum=1
2121
// +kubebuilder:validation:Maximum=65535
2222
// +kubebuilder:default=8080
23-
Port int32 `json:"port,omitempty"`
23+
ProxyPort int32 `json:"proxyPort,omitempty"`
2424

25-
// TargetPort is the port that MCP server listens to
25+
// McpPort is the port that MCP server listens to
2626
// +kubebuilder:validation:Minimum=1
2727
// +kubebuilder:validation:Maximum=65535
2828
// +optional
29-
TargetPort int32 `json:"targetPort,omitempty"`
29+
McpPort int32 `json:"mcpPort,omitempty"`
3030

3131
// Args are additional arguments to pass to the MCP server
3232
// +optional

cmd/thv-operator/controllers/mcpserver_controller.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (r *MCPServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
214214

215215
// Update the MCPServer status with the service URL
216216
if mcpServer.Status.URL == "" {
217-
mcpServer.Status.URL = createServiceURL(mcpServer.Name, mcpServer.Namespace, mcpServer.Spec.Port)
217+
mcpServer.Status.URL = createServiceURL(mcpServer.Name, mcpServer.Namespace, mcpServer.Spec.ProxyPort)
218218
err = r.Status().Update(ctx, mcpServer)
219219
if err != nil {
220220
ctxLogger.Error(err, "Failed to update MCPServer status")
@@ -407,13 +407,13 @@ func (r *MCPServerReconciler) deploymentForMCPServer(m *mcpv1alpha1.MCPServer) *
407407

408408
// Prepare container args
409409
args := []string{"run", "--foreground=true"}
410-
args = append(args, fmt.Sprintf("--proxy-port=%d", m.Spec.Port))
410+
args = append(args, fmt.Sprintf("--proxy-port=%d", m.Spec.ProxyPort))
411411
args = append(args, fmt.Sprintf("--name=%s", m.Name))
412412
args = append(args, fmt.Sprintf("--transport=%s", m.Spec.Transport))
413413
args = append(args, fmt.Sprintf("--host=%s", getProxyHost()))
414414

415-
if m.Spec.TargetPort != 0 {
416-
args = append(args, fmt.Sprintf("--target-port=%d", m.Spec.TargetPort))
415+
if m.Spec.McpPort != 0 {
416+
args = append(args, fmt.Sprintf("--target-port=%d", m.Spec.McpPort))
417417
}
418418

419419
// Generate pod template patch for secrets and merge with user-provided patch
@@ -454,7 +454,7 @@ func (r *MCPServerReconciler) deploymentForMCPServer(m *mcpv1alpha1.MCPServer) *
454454
// Add OAuth discovery resource URL for RFC 9728 compliance
455455
resourceURL := m.Spec.OIDCConfig.ResourceURL
456456
if resourceURL == "" {
457-
resourceURL = createServiceURL(m.Name, m.Namespace, m.Spec.Port)
457+
resourceURL = createServiceURL(m.Name, m.Namespace, m.Spec.ProxyPort)
458458
}
459459
args = append(args, fmt.Sprintf("--resource-url=%s", resourceURL))
460460
}
@@ -626,7 +626,7 @@ func (r *MCPServerReconciler) deploymentForMCPServer(m *mcpv1alpha1.MCPServer) *
626626
VolumeMounts: volumeMounts,
627627
Resources: resources,
628628
Ports: []corev1.ContainerPort{{
629-
ContainerPort: m.Spec.Port,
629+
ContainerPort: m.Spec.ProxyPort,
630630
Name: "http",
631631
Protocol: corev1.ProtocolTCP,
632632
}},
@@ -753,8 +753,8 @@ func (r *MCPServerReconciler) serviceForMCPServer(m *mcpv1alpha1.MCPServer) *cor
753753
Spec: corev1.ServiceSpec{
754754
Selector: ls, // Keep original labels for selector
755755
Ports: []corev1.ServicePort{{
756-
Port: m.Spec.Port,
757-
TargetPort: intstr.FromInt(int(m.Spec.Port)),
756+
Port: m.Spec.ProxyPort,
757+
TargetPort: intstr.FromInt(int(m.Spec.ProxyPort)),
758758
Protocol: corev1.ProtocolTCP,
759759
Name: "http",
760760
}},
@@ -884,7 +884,7 @@ func deploymentNeedsUpdate(deployment *appsv1.Deployment, mcpServer *mcpv1alpha1
884884
}
885885

886886
// Check if the port has changed
887-
portArg := fmt.Sprintf("--proxy-port=%d", mcpServer.Spec.Port)
887+
portArg := fmt.Sprintf("--proxy-port=%d", mcpServer.Spec.ProxyPort)
888888
found = false
889889
for _, arg := range container.Args {
890890
if arg == portArg {
@@ -937,7 +937,7 @@ func deploymentNeedsUpdate(deployment *appsv1.Deployment, mcpServer *mcpv1alpha1
937937
}
938938

939939
// Check if the container port has changed
940-
if len(container.Ports) > 0 && container.Ports[0].ContainerPort != mcpServer.Spec.Port {
940+
if len(container.Ports) > 0 && container.Ports[0].ContainerPort != mcpServer.Spec.ProxyPort {
941941
return true
942942
}
943943

@@ -1009,12 +1009,12 @@ func deploymentNeedsUpdate(deployment *appsv1.Deployment, mcpServer *mcpv1alpha1
10091009
return true
10101010
}
10111011

1012-
// Check if the targetPort has changed
1013-
if mcpServer.Spec.TargetPort != 0 {
1014-
targetPortArg := fmt.Sprintf("--target-port=%d", mcpServer.Spec.TargetPort)
1012+
// Check if the mcpPort has changed
1013+
if mcpServer.Spec.McpPort != 0 {
1014+
mcpPortArg := fmt.Sprintf("--target-port=%d", mcpServer.Spec.McpPort)
10151015
found := false
10161016
for _, arg := range container.Args {
1017-
if arg == targetPortArg {
1017+
if arg == mcpPortArg {
10181018
found = true
10191019
break
10201020
}
@@ -1067,7 +1067,7 @@ func deploymentNeedsUpdate(deployment *appsv1.Deployment, mcpServer *mcpv1alpha1
10671067
// serviceNeedsUpdate checks if the service needs to be updated
10681068
func serviceNeedsUpdate(service *corev1.Service, mcpServer *mcpv1alpha1.MCPServer) bool {
10691069
// Check if the service port has changed
1070-
if len(service.Spec.Ports) > 0 && service.Spec.Ports[0].Port != mcpServer.Spec.Port {
1070+
if len(service.Spec.Ports) > 0 && service.Spec.Ports[0].Port != mcpServer.Spec.ProxyPort {
10711071
return true
10721072
}
10731073

deploy/charts/operator-crds/templates/toolhive.stacklok.dev_mcpservers.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8303,9 +8303,9 @@ spec:
83038303
- containers
83048304
type: object
83058305
type: object
8306-
port:
8306+
proxyPort:
83078307
default: 8080
8308-
description: Port is the port to expose the MCP server on
8308+
description: ProxyPort is the port to expose the proxy runner on
83098309
format: int32
83108310
maximum: 65535
83118311
minimum: 1
@@ -8422,8 +8422,8 @@ spec:
84228422
ServiceAccount is the name of an already existing service account to use by the MCP server.
84238423
If not specified, a ServiceAccount will be created automatically and used by the MCP server.
84248424
type: string
8425-
targetPort:
8426-
description: TargetPort is the port that MCP server listens to
8425+
mcpPort:
8426+
description: McpPort is the port that MCP server listens to
84278427
format: int32
84288428
maximum: 65535
84298429
minimum: 1

deploy/keycloak/mcpserver-with-auth.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ spec:
1313
- name: INSECURE_DISABLE_URL_VALIDATION
1414
value: "true"
1515
transport: streamable-http
16-
port: 9090
17-
targetPort: 9090
16+
proxyPort: 9090
17+
mcpPort: 9090
1818
env:
1919

2020
# OIDC authentication with Keycloak

examples/operator/mcp-servers/mcpserver_fetch.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ metadata:
66
spec:
77
image: ghcr.io/stackloklabs/gofetch/server
88
transport: streamable-http
9-
port: 8080
10-
targetPort: 8080
9+
proxyPort: 8080
10+
mcpPort: 8080
1111
permissionProfile:
1212
type: builtin
1313
name: network

examples/operator/mcp-servers/mcpserver_fetch_tools_filter.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ spec:
88
transport: streamable-http
99
tools:
1010
- fetch
11-
port: 8080
12-
targetPort: 8080
11+
proxyPort: 8080
12+
mcpPort: 8080
1313
permissionProfile:
1414
type: builtin
1515
name: network

examples/operator/mcp-servers/mcpserver_github.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ metadata:
66
spec:
77
image: ghcr.io/github/github-mcp-server
88
transport: stdio
9-
port: 8080
9+
proxyPort: 8080
1010
permissionProfile:
1111
type: builtin
1212
name: network

examples/operator/mcp-servers/mcpserver_mkp.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ metadata:
66
spec:
77
image: ghcr.io/stackloklabs/mkp/server
88
transport: sse
9-
port: 8080
9+
proxyPort: 8080
1010
permissionProfile:
1111
type: builtin
1212
name: network

examples/operator/mcp-servers/mcpserver_with_configmap_oidc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ metadata:
1717
spec:
1818
image: docker.io/mcp/fetch
1919
transport: stdio
20-
port: 8080
20+
proxyPort: 8080
2121
permissionProfile:
2222
type: builtin
2323
name: network

examples/operator/mcp-servers/mcpserver_with_inline_oidc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ metadata:
66
spec:
77
image: docker.io/mcp/fetch
88
transport: stdio
9-
port: 8080
9+
proxyPort: 8080
1010
permissionProfile:
1111
type: builtin
1212
name: network

0 commit comments

Comments
 (0)