Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions acp/api/v1alpha1/mcpserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,25 @@ const (
ResourceMemory ResourceName = "memory"
)

// ToolAnnotation contains metadata and hints about a tool's behavior
type ToolAnnotation struct {
// If true, the tool does not modify its environment
// +optional
ReadOnlyHint *bool `json:"readOnlyHint,omitempty"`

// If true, the tool may perform destructive updates
// +optional
DestructiveHint *bool `json:"destructiveHint,omitempty"`

// If true, repeated calls with same args have no additional effect
// +optional
IdempotentHint *bool `json:"idempotentHint,omitempty"`

// If true, tool interacts with external entities
// +optional
OpenWorldHint *bool `json:"openWorldHint,omitempty"`
}

// MCPTool represents a tool provided by an MCP server
type MCPTool struct {
// Name of the tool
Expand All @@ -100,6 +119,10 @@ type MCPTool struct {
// +kubebuilder:pruning:PreserveUnknownFields
// +optional
InputSchema runtime.RawExtension `json:"inputSchema,omitempty"`

// Annotations contains metadata and hints about the tool's behavior
// +optional
Annotations *ToolAnnotation `json:"annotations,omitempty"`
}

// MCPServerStatus defines the observed state of MCPServer
Expand Down
4 changes: 4 additions & 0 deletions acp/api/v1alpha1/toolcall_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ type ToolCallSpec struct {
// Arguments contains the arguments for the tool call
// +kubebuilder:validation:Required
Arguments string `json:"arguments"`

// ToolAnnotations contains metadata about the tool's behavior
// +optional
ToolAnnotations *ToolAnnotation `json:"toolAnnotations,omitempty"`
}

// ToolCallStatus defines the observed state of ToolCall
Expand Down
9 changes: 5 additions & 4 deletions acp/internal/adapters/mcp_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ func ConvertMCPToolsToLLMClientTools(mcpTools []acp.MCPTool, serverName string)
}
}

// Create the tool with the function definition
// Create the tool with the function definition and annotations
clientTools = append(clientTools, llmclient.Tool{
Type: "function",
Function: toolFunction,
ACPToolType: acp.ToolTypeMCP,
Type: "function",
Function: toolFunction,
ACPToolType: acp.ToolTypeMCP,
ACPToolAnnotations: tool.Annotations,
})
}

Expand Down
9 changes: 6 additions & 3 deletions acp/internal/controller/task/task_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,12 @@ func (r *TaskReconciler) createToolCalls(ctx context.Context, task *acp.Task, st
return ctrl.Result{}, err
}

// Create a map of tool name to tool type for quick lookup
// Create maps for tool type and tool annotations for quick lookup
toolTypeMap := make(map[string]acp.ToolType)
toolAnnotationsMap := make(map[string]*acp.ToolAnnotation)
for _, tool := range tools {
toolTypeMap[tool.Function.Name] = tool.ACPToolType
toolAnnotationsMap[tool.Function.Name] = tool.ACPToolAnnotations
}

// For each tool call, create a new ToolCall with a unique name using the ToolCallRequestID
Expand Down Expand Up @@ -561,8 +563,9 @@ func (r *TaskReconciler) createToolCalls(ctx context.Context, task *acp.Task, st
ToolRef: acp.LocalObjectReference{
Name: tc.Function.Name,
},
ToolType: toolTypeMap[tc.Function.Name],
Arguments: tc.Function.Arguments,
ToolType: toolTypeMap[tc.Function.Name],
Arguments: tc.Function.Arguments,
ToolAnnotations: toolAnnotationsMap[tc.Function.Name],
},
}
if err := r.Client.Create(ctx, newTC); err != nil {
Expand Down
Loading
Loading