Skip to content

Commit 5623684

Browse files
authored
feat(config): add configurable prompts support (#559)
Enable administrators to define custom MCP prompts in config.toml using template substitution with {{argument}} syntax. - PromptLoader for loading prompts from TOML config - Core prompt types (ServerPrompt, Prompt, PromptArgument, PromptMessage) - Template argument substitution with {{variable}} syntax - Required argument validation - Integration with MCP server to register and serve config prompts Signed-off-by: Nader Ziada <[email protected]>
1 parent 765a172 commit 5623684

File tree

16 files changed

+1624
-8
lines changed

16 files changed

+1624
-8
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,27 @@ vim /etc/kubernetes-mcp-server/conf.d/99-local.toml
292292
pkill -HUP kubernetes-mcp-server
293293
```
294294

295+
### MCP Prompts
296+
297+
The server supports MCP prompts for workflow templates. Define custom prompts in `config.toml`:
298+
299+
```toml
300+
[[prompts]]
301+
name = "my-workflow"
302+
title = "my workflow"
303+
description = "Custom workflow"
304+
305+
[[prompts.arguments]]
306+
name = "resource_name"
307+
required = true
308+
309+
[[prompts.messages]]
310+
role = "user"
311+
content = "Help me with {{resource_name}}"
312+
```
313+
314+
See docs/PROMPTS.md for detailed documentation.
315+
295316
## 🛠️ Tools and Functionalities <a id="tools-and-functionalities"></a>
296317

297318
The Kubernetes MCP server supports enabling or disabling specific groups of tools and functionalities (tools, resources, prompts, and so on) via the `--toolsets` command-line flag or `toolsets` configuration option.

docs/PROMPTS.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# MCP Prompts Support
2+
3+
The Kubernetes MCP Server supports [MCP Prompts](https://modelcontextprotocol.io/docs/concepts/prompts), which provide pre-defined workflow templates and guidance to AI assistants.
4+
5+
## What are MCP Prompts?
6+
7+
MCP Prompts are pre-defined templates that guide AI assistants through specific workflows. They combine:
8+
- **Structured guidance**: Step-by-step instructions for common tasks
9+
- **Parameterization**: Arguments that customize the prompt for specific contexts
10+
- **Conversation templates**: Pre-formatted messages that guide the interaction
11+
12+
## Creating Custom Prompts
13+
14+
Define custom prompts in your `config.toml` file - no code changes or recompilation needed!
15+
16+
### Example
17+
18+
```toml
19+
[[prompts]]
20+
name = "check-pod-logs"
21+
title = "Check Pod Logs"
22+
description = "Quick way to check pod logs"
23+
24+
[[prompts.arguments]]
25+
name = "pod_name"
26+
description = "Name of the pod"
27+
required = true
28+
29+
[[prompts.arguments]]
30+
name = "namespace"
31+
description = "Namespace of the pod"
32+
required = false
33+
34+
[[prompts.messages]]
35+
role = "user"
36+
content = "Show me the logs for pod {{pod_name}} in {{namespace}}"
37+
38+
[[prompts.messages]]
39+
role = "assistant"
40+
content = "I'll retrieve and analyze the logs for you."
41+
```
42+
43+
## Configuration Reference
44+
45+
### Prompt Fields
46+
- **name** (required): Unique identifier for the prompt
47+
- **title** (optional): Human-readable display name
48+
- **description** (required): Brief explanation of what the prompt does
49+
- **arguments** (optional): List of parameters the prompt accepts
50+
- **messages** (required): Conversation template with role/content pairs
51+
52+
### Argument Fields
53+
- **name** (required): Argument identifier
54+
- **description** (optional): Explanation of the argument's purpose
55+
- **required** (optional): Whether the argument must be provided (default: false)
56+
57+
### Argument Substitution
58+
Use `{{argument_name}}` placeholders in message content. The template engine replaces these with actual values when the prompt is called.
59+
60+
## Configuration File Location
61+
62+
Place your prompts in the `config.toml` file used by the MCP server. Specify the config file path using the `--config` flag when starting the server.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
github.com/stretchr/testify v1.11.1
1717
golang.org/x/oauth2 v0.34.0
1818
golang.org/x/sync v0.19.0
19+
gopkg.in/yaml.v3 v3.0.1
1920
helm.sh/helm/v3 v3.19.3
2021
k8s.io/api v0.34.3
2122
k8s.io/apiextensions-apiserver v0.34.3
@@ -133,7 +134,6 @@ require (
133134
google.golang.org/protobuf v1.36.6 // indirect
134135
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
135136
gopkg.in/inf.v0 v0.9.1 // indirect
136-
gopkg.in/yaml.v3 v3.0.1 // indirect
137137
k8s.io/apiserver v0.34.3 // indirect
138138
k8s.io/component-base v0.34.3 // indirect
139139
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect

0 commit comments

Comments
 (0)