Repository navigation
Description
Summary
Extend the kagenti webhook that mutates ToolHive MCP Server Custom Resources to automatically generate the corresponding MCP Gateway CRs (HTTPRoute and MCPServer). This will streamline the developer workflow by automating the registration of ToolHive MCP Servers with the MCP Gateway and hiding implementation details.
Background
Currently, when deploying a ToolHive MCP Server, developers must manually create two additional Custom Resources to register the server with the MCP Gateway:
- HTTPRoute (Gateway API) - Defines the routing rules for the MCP server
- MCPServer (MCP Gateway CR) - Links the server to the gateway via the HTTPRoute
Important Note: There are two different MCPServer CRs in play:
- ToolHive MCPServer (
toolhive.kagenti.com/v1alpha1) - The application MCP server - MCP Gateway MCPServer (
mcp.kagenti.com/v1alpha1) - The gateway registration CR
This manual process is error-prone and exposes unnecessary implementation details to developers.
Proposed Solution
Enhance the existing kagenti mutating webhook to automatically generate the MCP Gateway CRs when a ToolHive MCP Server CR is created or updated.
Generated Resources
For each ToolHive MCP Server, the webhook should generate:
1. HTTPRoute CR
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: <tool-name-route>
namespace: <tool-namespace>
labels:
mcp-server: "true"
spec:
parentRefs:
- name: mcp-gateway
namespace: gateway-system
hostnames:
- "<tool-name>.mcp.local"
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: <tool-name>
port: <tool-port>2. MCP Gateway MCPServer CR
apiVersion: mcp.kagenti.com/v1alpha1
kind: MCPServer
metadata:
name: <tool-name>-gateway
namespace: <tool-namespace>
spec:
toolPrefix:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: <tool-name-route>
namespace: <tool-namespace>Implementation Details
Webhook Behavior
-
On ToolHive MCPServer Creation:
- Generate HTTPRoute with appropriate hostname and routing rules
- Generate MCP Gateway MCPServer with reference to the HTTPRoute
- Apply ownership labels for garbage collection and management
-
On ToolHive MCPServer Update:
- Update generated CRs if relevant fields change (service name, port, tool prefix)
- Maintain idempotency
-
On ToolHive MCPServer Deletion:
- Ensure generated CRs are cleaned up via owner references or labels
Configuration Options
The webhook should extract the following from the ToolHive MCPServer:
- Service name and port (for HTTPRoute backendRef)
- Tool prefix (for MCP Gateway MCPServer spec)
- Namespace
- Any custom annotations or labels to propagate
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
esnible commentedon Dec 2, 2025
Is there documentation or PowerPoint proposals of how we expect the completed system to work? I want to share it with the MCP Gateway developers.
Does the Kagenti UI or Kagenti Operator require the MCP Gateway and/or its CRs? Or is the MCP Gateway merely a part of the Kagenti environment?
cc @david-martin
rubambiza commentedon Feb 2, 2026
No longer valid as ToolHive is no longer being used.