-
Notifications
You must be signed in to change notification settings - Fork 2
Document MCPToolConfig and toolConfigRef for K8s operator #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
13e6a01
docs(k8s): document MCPToolConfig and toolConfigRef; add guide and si…
JAORMX 02803cc
Apply suggestions from code review
JAORMX 49dfc07
docs(k8s): org-scoped GitHub example for MCPToolConfig\n- Rename tool…
JAORMX 1d52f7a
Update docs/toolhive/guides-k8s/tool-config.mdx
JAORMX 8e26f67
Update docs/toolhive/guides-k8s/tool-config.mdx
JAORMX 5ebff6e
Update docs/toolhive/guides-k8s/tool-config.mdx
JAORMX 19d1892
Update docs/toolhive/guides-k8s/tool-config.mdx
JAORMX 731a429
Update docs/toolhive/guides-k8s/tool-config.mdx
JAORMX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,236 @@ | ||
| --- | ||
| title: Configure tools for MCP servers on Kubernetes | ||
| description: | ||
| Filter and rename MCP server tools using the MCPToolConfig CRD and | ||
| toolConfigRef. | ||
| --- | ||
|
|
||
| ## Overview | ||
|
|
||
| Use the MCPToolConfig Custom Resource Definition (CRD) to centrally manage which | ||
| tools an MCP server exposes, and optionally rename tools or override their | ||
| descriptions. You reference the configuration from an MCPServer using the | ||
| toolConfigRef field. | ||
|
|
||
| - toolsFilter: allow‑list the tools to expose. | ||
| - toolsOverride: rename tools and/or change their descriptions. | ||
| - Same‑namespace only: an MCPServer can reference only MCPToolConfig objects in | ||
JAORMX marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| the same namespace. | ||
| - Precedence: toolConfigRef takes precedence over the deprecated spec.tools | ||
| field on MCPServer. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - ToolHive operator installed. See | ||
| [Deploy the operator using Helm](./deploy-operator-helm.md). | ||
| - Permissions to create namespaced resources (and optionally RBAC for servers | ||
| that need cluster access). | ||
|
|
||
JAORMX marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ## Define a basic tool filter | ||
|
|
||
| This example exposes only three tools on a server: | ||
|
|
||
| ```yaml title="toolconfig-basic.yaml" | ||
| apiVersion: toolhive.stacklok.dev/v1alpha1 | ||
| kind: MCPToolConfig | ||
| metadata: | ||
| name: basic-tool-filter | ||
| namespace: default | ||
danbarr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| spec: | ||
| toolsFilter: | ||
| - read_file | ||
| - write_file | ||
| - list_directory | ||
| ``` | ||
| ## Rename tools and override descriptions | ||
| You can rename tools to match your team's conventions and refine their | ||
| descriptions: | ||
danbarr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ```yaml title="toolconfig-with-overrides.yaml" | ||
| apiVersion: toolhive.stacklok.dev/v1alpha1 | ||
| kind: MCPToolConfig | ||
| metadata: | ||
| name: github-tools-config | ||
| namespace: default | ||
| spec: | ||
| toolsFilter: | ||
| - create_pull_request | ||
| - get_pull_request | ||
| - list_pull_requests | ||
| - merge_pull_request | ||
| toolsOverride: | ||
| create_pull_request: | ||
| name: github_create_pr | ||
| description: Create a new GitHub pull request | ||
danbarr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| get_pull_request: | ||
| name: github_get_pr | ||
| description: Retrieve details of a GitHub pull request | ||
| list_pull_requests: | ||
| name: github_list_prs | ||
| description: List pull requests in a repository | ||
| merge_pull_request: | ||
| name: github_merge_pr | ||
| description: Merge a GitHub pull request | ||
| ``` | ||
JAORMX marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ## Reference the configuration from an MCP server | ||
| Add toolConfigRef to your MCPServer. toolConfigRef overrides spec.tools | ||
| (deprecated). | ||
danbarr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ```yaml title="mcpserver-with-toolconfig.yaml" | ||
JAORMX marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| apiVersion: toolhive.stacklok.dev/v1alpha1 | ||
| kind: MCPServer | ||
| metadata: | ||
| name: mkp | ||
| namespace: toolhive-system | ||
| spec: | ||
| image: ghcr.io/stackloklabs/mkp/server:0.2.3 | ||
| transport: streamable-http | ||
| targetPort: 8080 | ||
| port: 8080 | ||
| serviceAccount: mkp-sa | ||
| toolConfigRef: | ||
| name: mkp-tools | ||
| args: | ||
| - '--read-write=true' | ||
| ``` | ||
| ## End‑to‑end example (cluster‑scoped RBAC) | ||
| The following manifest shows a minimal, end‑to‑end setup that runs the MKP | ||
| server inside the cluster, grants it wide permissions (for demo only), defines | ||
| an MCPToolConfig, and references it from the server: | ||
danbarr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ```yaml title="mkp-with-toolconfig.yaml" | ||
| apiVersion: v1 | ||
| kind: ServiceAccount | ||
| metadata: | ||
| name: mkp-sa | ||
| namespace: toolhive-system | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: mkp-cluster-role | ||
| rules: | ||
| - apiGroups: ['*'] | ||
| resources: ['*'] | ||
| verbs: ['*'] | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: mkp-cluster-role-binding | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: mkp-cluster-role | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: mkp-sa | ||
| namespace: toolhive-system | ||
| --- | ||
| apiVersion: toolhive.stacklok.dev/v1alpha1 | ||
| kind: MCPToolConfig | ||
| metadata: | ||
| name: mkp-tools | ||
| namespace: toolhive-system | ||
| spec: | ||
| toolsFilter: | ||
| - homelab_k8s_apply_resource | ||
| - homelab_k8s_delete_resource | ||
| - homelab_k8s_get_resource | ||
| - homelab_k8s_list_resources | ||
| - homelab_k8s_post_resource | ||
| toolsOverride: | ||
| apply_resource: | ||
| name: homelab_k8s_apply_resource | ||
JAORMX marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| description: | | ||
| Apply (create or update) a Kubernetes resource. | ||
| Required: | ||
| - resource: plural resource name (e.g., deployments, services) | ||
| - version: API version (e.g., v1, v1beta1) | ||
| - manifest: full resource manifest (apiVersion, kind, metadata, spec) | ||
| Optional: | ||
| - group: API group (e.g., apps, networking.k8s.io) | ||
| - resource_type: clustered|namespaced (default inferred from resource; use namespaced and provide namespace when required) | ||
| - namespace: target namespace for namespaced resources | ||
| delete_resource: | ||
JAORMX marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| name: homelab_k8s_delete_resource | ||
| description: | | ||
| Delete a Kubernetes resource. | ||
| Required: | ||
| - resource, version, name | ||
| Optional: | ||
| - group, namespace (for namespaced resources) | ||
| get_resource: | ||
JAORMX marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| name: homelab_k8s_get_resource | ||
| description: | | ||
| Get a Kubernetes resource or its subresource (e.g., status, scale, logs). | ||
| - For pod logs, supported parameters include: container, previous, sinceSeconds, sinceTime, timestamps, limitBytes, tailLines. | ||
| - For subresources, set subresource: status|scale|logs etc. | ||
| - For namespaced resources, set namespace. | ||
| list_resources: | ||
JAORMX marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| name: homelab_k8s_list_resources | ||
| description: | | ||
| List Kubernetes resources with flexible filtering. | ||
| Supported parameters: | ||
| - namespace (for namespaced resources) | ||
| - label_selector | ||
| - include_annotations (bool), include_annotation_keys, exclude_annotation_keys (wildcards supported with *) | ||
| - limit (0 = no limit), continue (for pagination) | ||
| post_resource: | ||
JAORMX marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| name: homelab_k8s_post_resource | ||
| description: | | ||
| Post to a Kubernetes resource or subresource (e.g., exec). | ||
| - Provide body according to subresource. | ||
| - For exec, body fields: command (string or array), container (optional), timeout (seconds, optional). | ||
| - For namespaced resources, set namespace. | ||
| --- | ||
| apiVersion: toolhive.stacklok.dev/v1alpha1 | ||
| kind: MCPServer | ||
| metadata: | ||
| name: mkp | ||
| namespace: toolhive-system | ||
| spec: | ||
| image: ghcr.io/stackloklabs/mkp/server:0.2.3 | ||
| transport: streamable-http | ||
| targetPort: 8080 | ||
| port: 8080 | ||
| serviceAccount: mkp-sa | ||
| toolConfigRef: | ||
| name: mkp-tools | ||
| args: | ||
| - '--read-write=true' | ||
| ``` | ||
| :::warning[Least privilege] | ||
| The ClusterRole above is intentionally broad for demonstration. In production, | ||
| scope permissions to the minimum your workflows require. | ||
| ::: | ||
| ## Inspect status and troubleshoot | ||
| Use kubectl to inspect status and track change propagation: | ||
| ```bash | ||
| kubectl -n toolhive-system get mcptoolconfigs | ||
| kubectl -n toolhive-system get mcptoolconfig mkp-tools -o yaml | ||
| kubectl -n toolhive-system get mcpserver mkp -o yaml | ||
| ``` | ||
|
|
||
| - If an MCPToolConfig is still referenced, deletion is blocked by a finalizer. | ||
| Remove all toolConfigRef references first. | ||
| - If an MCPServer references a missing MCPToolConfig, the server enters Failed | ||
| and the controller logs include the missing name and namespace. | ||
|
|
||
| ## Related | ||
|
|
||
| - See the [Kubernetes CRD reference](../reference/crd-spec.mdx) for the full | ||
| MCPToolConfig and MCPServerSpec schemas. | ||
| - Learn how to [run the MKP server in Kubernetes](../guides-mcp/k8s.mdx). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.