Skip to content

Commit ea28447

Browse files
committed
tool annotations
1 parent d698478 commit ea28447

File tree

7 files changed

+53
-0
lines changed

7 files changed

+53
-0
lines changed

pkg/mcp/tools.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ func appendBoolFlag(args []string, flag string, value *bool) []string {
105105
return args
106106
}
107107

108+
// ptr returns a pointer to the given value.
109+
// Useful for setting optional annotation fields.
110+
func ptr[T any](v T) *T {
111+
return &v
112+
}
113+
108114
// healthCheck is a simple tool for testing MCP server connectivity
109115
type healthCheck struct{}
110116

pkg/mcp/tools_build.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ func (t buildTool) desc() *mcp.Tool {
3737
Name: "build",
3838
Title: "Build Function",
3939
Description: "Build the Function's container image in the current directory.",
40+
Annotations: &mcp.ToolAnnotations{
41+
Title: "Build Function",
42+
ReadOnlyHint: false,
43+
DestructiveHint: ptr(false),
44+
IdempotentHint: true, // Building the same source code multiple times produces the same container image.
45+
},
4046
InputSchema: map[string]any{
4147
"type": "object",
4248
"properties": map[string]any{

pkg/mcp/tools_config.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ func (t configVolumesTool) desc() *mcp.Tool {
3232
return &mcp.Tool{
3333
Name: "config_volumes",
3434
Description: "Manages volume configurations for a function. Can add, remove, or list volumes in func.yaml.",
35+
Annotations: &mcp.ToolAnnotations{
36+
Title: "Config Volumes",
37+
ReadOnlyHint: false,
38+
DestructiveHint: ptr(true),
39+
IdempotentHint: false, // Adding the same volume twice or removing a non-existent volume will fail.
40+
},
3541
InputSchema: map[string]any{
3642
"type": "object",
3743
"properties": map[string]any{
@@ -141,6 +147,12 @@ func (t configLabelsTool) desc() *mcp.Tool {
141147
return &mcp.Tool{
142148
Name: "config_labels",
143149
Description: "Manages label configurations for a function. Can add, remove, or list labels in func.yaml.",
150+
Annotations: &mcp.ToolAnnotations{
151+
Title: "Config Labels",
152+
ReadOnlyHint: false,
153+
DestructiveHint: ptr(true),
154+
IdempotentHint: false, // Adding the same label twice or removing a non-existent label will fail.
155+
},
144156
InputSchema: map[string]any{
145157
"type": "object",
146158
"properties": map[string]any{
@@ -229,6 +241,12 @@ func (t configEnvsTool) desc() *mcp.Tool {
229241
return &mcp.Tool{
230242
Name: "config_envs",
231243
Description: "Manages environment variable configurations for a function. Can add, remove, or list environment variables in func.yaml.",
244+
Annotations: &mcp.ToolAnnotations{
245+
Title: "Config Environment Variables",
246+
ReadOnlyHint: false,
247+
DestructiveHint: ptr(true),
248+
IdempotentHint: false, // Adding the same environment variable twice or removing a non-existent one will fail.
249+
},
232250
InputSchema: map[string]any{
233251
"type": "object",
234252
"properties": map[string]any{

pkg/mcp/tools_create.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ func (t createTool) desc() *mcp.Tool {
3434
Name: "create",
3535
Title: "Create Function",
3636
Description: "Initialize a new Function project in the current directory (like 'git init'). Function name defaults to directory name.",
37+
Annotations: &mcp.ToolAnnotations{
38+
Title: "Create Function",
39+
ReadOnlyHint: false,
40+
DestructiveHint: ptr(false),
41+
IdempotentHint: false, // Running create twice on the same path fails because function files already exist.
42+
},
3743
InputSchema: map[string]any{
3844
"type": "object",
3945
"properties": map[string]any{

pkg/mcp/tools_delete.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ func (t deleteTool) desc() *mcp.Tool {
3232
Name: "delete",
3333
Title: "Delete Function",
3434
Description: "Delete a deployed Function from the Kubernetes cluster.",
35+
Annotations: &mcp.ToolAnnotations{
36+
Title: "Delete Function",
37+
ReadOnlyHint: false,
38+
DestructiveHint: ptr(true),
39+
IdempotentHint: true, // Deleting the same function multiple times results in the same end state (function doesn't exist).
40+
},
3541
InputSchema: map[string]any{
3642
"type": "object",
3743
"properties": map[string]any{

pkg/mcp/tools_deploy.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ func (t deployTool) desc() *mcp.Tool {
4747
Name: "deploy",
4848
Title: "Deploy Function",
4949
Description: "Deploy the Function to Kubernetes from the current directory. Builds the container image if needed.",
50+
Annotations: &mcp.ToolAnnotations{
51+
Title: "Deploy Function",
52+
ReadOnlyHint: false,
53+
DestructiveHint: ptr(false),
54+
IdempotentHint: true, // Deploying the same function configuration multiple times converges to the same desired state.
55+
},
5056
InputSchema: map[string]any{
5157
"type": "object",
5258
"properties": map[string]any{

pkg/mcp/tools_list.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ func (t listTool) desc() *mcp.Tool {
2828
return &mcp.Tool{
2929
Name: "list",
3030
Description: "Lists all deployed functions in the current namespace, specified namespace, or all namespaces.",
31+
Annotations: &mcp.ToolAnnotations{
32+
Title: "List Functions",
33+
ReadOnlyHint: true,
34+
IdempotentHint: true, // Listing functions with the same parameters multiple times returns consistent results at any point in time.
35+
},
3136
InputSchema: map[string]any{
3237
"type": "object",
3338
"properties": map[string]any{

0 commit comments

Comments
 (0)