Documentation
¶
Index ¶
- Constants
- func OptionalBool(params ToolHandlerParams, key string, defaultVal bool) bool
- func OptionalString(params ToolHandlerParams, key, defaultVal string) string
- func ParseInt64(value interface{}) (int64, error)
- func RequiredString(params ToolHandlerParams, key string) (string, error)
- func ToRawMessage(v any) json.RawMessage
- type AuthProvider
- type BaseConfig
- type ClusterProvider
- type DeniedResourcesProvider
- type ErrInvalidInt64Type
- type ExtendedConfig
- type ExtendedConfigProvider
- type GroupVersionKind
- type KubernetesClient
- type ListOptions
- type NodesTopOptions
- type Openshift
- type PodsTopOptions
- type Prompt
- type PromptArgument
- type PromptCallRequest
- type PromptCallResult
- type PromptContent
- type PromptHandlerFunc
- type PromptHandlerParams
- type PromptMessage
- type PromptTemplate
- type ServerPrompt
- type ServerTool
- type Tool
- type ToolAnnotations
- type ToolCallRequest
- type ToolCallResult
- type ToolHandlerFunc
- type ToolHandlerParams
- type Toolset
Constants ¶
const ( ClusterProviderKubeConfig = "kubeconfig" ClusterProviderInCluster = "in-cluster" ClusterProviderDisabled = "disabled" )
Variables ¶
This section is empty.
Functions ¶
func OptionalBool ¶ added in v0.0.56
func OptionalBool(params ToolHandlerParams, key string, defaultVal bool) bool
OptionalBool extracts an optional boolean parameter from tool arguments. Returns the boolean value if present and valid, or defaultVal if missing or not a boolean.
func OptionalString ¶ added in v0.0.56
func OptionalString(params ToolHandlerParams, key, defaultVal string) string
OptionalString extracts an optional string parameter from tool arguments. Returns the string value if present and valid, or defaultVal if missing or not a string.
func ParseInt64 ¶ added in v0.0.56
ParseInt64 converts an interface{} value (typically from JSON-decoded tool arguments) to int64. Handles float64 (JSON numbers), int, and int64 types. Returns the converted value and nil error on success, or 0 and an ErrInvalidInt64Type if the type is unsupported.
func RequiredString ¶ added in v0.0.56
func RequiredString(params ToolHandlerParams, key string) (string, error)
RequiredString extracts a required string parameter from tool arguments. Returns the string value and nil error on success. Returns an error if the parameter is missing or not a string.
func ToRawMessage ¶
func ToRawMessage(v any) json.RawMessage
Types ¶
type AuthProvider ¶ added in v0.0.56
type AuthProvider interface {
// IsRequireOAuth indicates whether OAuth authentication is required.
IsRequireOAuth() bool
}
type BaseConfig ¶ added in v0.0.56
type BaseConfig interface {
AuthProvider
ClusterProvider
DeniedResourcesProvider
ExtendedConfigProvider
}
type ClusterProvider ¶ added in v0.0.56
type DeniedResourcesProvider ¶ added in v0.0.56
type DeniedResourcesProvider interface {
// GetDeniedResources returns a list of GroupVersionKinds that are denied.
GetDeniedResources() []GroupVersionKind
}
type ErrInvalidInt64Type ¶ added in v0.0.56
type ErrInvalidInt64Type struct {
Value interface{}
}
ErrInvalidInt64Type is returned when a value cannot be converted to int64.
func (*ErrInvalidInt64Type) Error ¶ added in v0.0.56
func (e *ErrInvalidInt64Type) Error() string
type ExtendedConfig ¶ added in v0.0.56
type ExtendedConfig interface {
// Validate validates the extended configuration. Returns an error if the configuration is invalid.
Validate() error
}
ExtendedConfig is the interface that all configuration extensions must implement. Each extended config manager registers a factory function to parse its config from TOML primitives
type ExtendedConfigProvider ¶ added in v0.0.56
type ExtendedConfigProvider interface {
// GetProviderConfig returns the extended configuration for the given provider strategy.
// The boolean return value indicates whether the configuration was found.
GetProviderConfig(strategy string) (ExtendedConfig, bool)
// GetToolsetConfig returns the extended configuration for the given toolset name.
// The boolean return value indicates whether the configuration was found.
GetToolsetConfig(name string) (ExtendedConfig, bool)
}
type GroupVersionKind ¶ added in v0.0.56
type KubernetesClient ¶ added in v0.0.56
type KubernetesClient interface {
genericclioptions.RESTClientGetter
kubernetes.Interface
// NamespaceOrDefault returns the provided namespace or the default configured namespace if empty
NamespaceOrDefault(namespace string) string
// RESTConfig returns the REST config used to create clients
RESTConfig() *rest.Config
// RESTMapper returns the REST mapper used to map GVK to GVR
RESTMapper() meta.ResettableRESTMapper
// DiscoveryClient returns the cached discovery client
DiscoveryClient() discovery.CachedDiscoveryInterface
// DynamicClient returns the dynamic client
DynamicClient() dynamic.Interface
// MetricsV1beta1Client returns the metrics v1beta1 client
MetricsV1beta1Client() *metricsv1beta1.MetricsV1beta1Client
}
KubernetesClient defines the interface for Kubernetes operations that tool and prompt handlers need. This interface abstracts the concrete Kubernetes implementation to allow controlled access to the underlying resource APIs, better decoupling, and testability.
type ListOptions ¶ added in v0.0.56
type ListOptions struct {
metav1.ListOptions
AsTable bool
}
ListOptions contains options for listing Kubernetes resources.
type NodesTopOptions ¶ added in v0.0.56
type NodesTopOptions struct {
metav1.ListOptions
Name string
}
NodesTopOptions contains options for getting node metrics.
type Openshift ¶ added in v0.0.56
Openshift provides OpenShift-specific detection capabilities. This interface is used by toolsets to conditionally enable OpenShift-specific tools.
type PodsTopOptions ¶ added in v0.0.56
type PodsTopOptions struct {
metav1.ListOptions
AllNamespaces bool
Namespace string
Name string
}
PodsTopOptions contains options for getting pod metrics.
type Prompt ¶ added in v0.0.56
type Prompt struct {
Name string `json:"name" toml:"name"`
Title string `json:"title,omitempty" toml:"title,omitempty"`
Description string `json:"description,omitempty" toml:"description,omitempty"`
Arguments []PromptArgument `json:"arguments,omitempty" toml:"arguments,omitempty"`
Templates []PromptTemplate `json:"messages,omitempty" toml:"messages,omitempty"`
}
Prompt represents the metadata and content of an MCP prompt. See MCP specification: https://spec.modelcontextprotocol.io/specification/server/prompts/
type PromptArgument ¶ added in v0.0.56
type PromptArgument struct {
Name string `json:"name" toml:"name"`
Description string `json:"description,omitempty" toml:"description,omitempty"`
Required bool `json:"required" toml:"required"`
}
PromptArgument defines a parameter that can be passed to a prompt. See MCP specification: https://spec.modelcontextprotocol.io/specification/server/prompts/
type PromptCallRequest ¶ added in v0.0.56
PromptCallRequest interface for accessing prompt call arguments
type PromptCallResult ¶ added in v0.0.56
type PromptCallResult struct {
Description string
Messages []PromptMessage
Error error
}
PromptCallResult represents the result of executing a prompt
func NewPromptCallResult ¶ added in v0.0.56
func NewPromptCallResult(description string, messages []PromptMessage, err error) *PromptCallResult
NewPromptCallResult creates a new PromptCallResult
type PromptContent ¶ added in v0.0.56
type PromptContent struct {
Type string `json:"type" toml:"type"`
Text string `json:"text,omitempty" toml:"text,omitempty"`
}
PromptContent represents the content of a prompt message. See MCP specification: https://spec.modelcontextprotocol.io/specification/server/prompts/
type PromptHandlerFunc ¶ added in v0.0.56
type PromptHandlerFunc func(params PromptHandlerParams) (*PromptCallResult, error)
PromptHandlerFunc is a function that handles prompt execution
type PromptHandlerParams ¶ added in v0.0.56
type PromptHandlerParams struct {
context.Context
ExtendedConfigProvider
KubernetesClient
PromptCallRequest
}
PromptHandlerParams contains the parameters passed to a prompt handler
type PromptMessage ¶ added in v0.0.56
type PromptMessage struct {
Role string `json:"role" toml:"role"`
Content PromptContent `json:"content" toml:"content"`
}
PromptMessage represents a single message in a prompt response. See MCP specification: https://spec.modelcontextprotocol.io/specification/server/prompts/
type PromptTemplate ¶ added in v0.0.56
type PromptTemplate struct {
Role string `json:"role" toml:"role"`
Content string `json:"content" toml:"content"`
}
PromptTemplate represents a message template from configuration with placeholders like {{arg}}. This is used for configuration parsing and gets rendered into PromptMessage at runtime.
type ServerPrompt ¶ added in v0.0.56
type ServerPrompt struct {
Prompt Prompt
Handler PromptHandlerFunc
ClusterAware *bool
ArgumentSchema map[string]PromptArgument
}
ServerPrompt represents a prompt that can be registered with the MCP server. Prompts provide pre-defined workflow templates and guidance to AI assistants.
func (*ServerPrompt) IsClusterAware ¶ added in v0.0.56
func (s *ServerPrompt) IsClusterAware() bool
IsClusterAware indicates whether the prompt can accept a "cluster" or "context" parameter to operate on a specific Kubernetes cluster context. Defaults to true if not explicitly set
type ServerTool ¶
type ServerTool struct {
Tool Tool
Handler ToolHandlerFunc
ClusterAware *bool
TargetListProvider *bool
}
func (*ServerTool) IsClusterAware ¶ added in v0.0.53
func (s *ServerTool) IsClusterAware() bool
IsClusterAware indicates whether the tool can accept a "cluster" or "context" parameter to operate on a specific Kubernetes cluster context. Defaults to true if not explicitly set
func (*ServerTool) IsTargetListProvider ¶ added in v0.0.53
func (s *ServerTool) IsTargetListProvider() bool
IsTargetListProvider indicates whether the tool is used to provide a list of targets (clusters/contexts) Defaults to false if not explicitly set
type Tool ¶
type Tool struct {
// The name of the tool.
// Intended for programmatic or logical use, but used as a display name in past
// specs or fallback (if title isn't present).
Name string `json:"name"`
// A human-readable description of the tool.
//
// This can be used by clients to improve the LLM's understanding of available
// tools. It can be thought of like a "hint" to the model.
Description string `json:"description,omitempty"`
// Additional tool information.
Annotations ToolAnnotations `json:"annotations"`
// A JSON Schema object defining the expected parameters for the tool.
InputSchema *jsonschema.Schema
}
type ToolAnnotations ¶
type ToolAnnotations struct {
// Human-readable title for the tool
Title string `json:"title,omitempty"`
// If true, the tool does not modify its environment.
ReadOnlyHint *bool `json:"readOnlyHint,omitempty"`
// If true, the tool may perform destructive updates to its environment. If
// false, the tool performs only additive updates.
//
// (This property is meaningful only when ReadOnlyHint == false.)
DestructiveHint *bool `json:"destructiveHint,omitempty"`
// If true, calling the tool repeatedly with the same arguments will have no
// additional effect on its environment.
//
// (This property is meaningful only when ReadOnlyHint == false.)
IdempotentHint *bool `json:"idempotentHint,omitempty"`
// If true, this tool may interact with an "open world" of external entities. If
// false, the tool's domain of interaction is closed. For example, the world of
// a web search tool is open, whereas that of a memory tool is not.
OpenWorldHint *bool `json:"openWorldHint,omitempty"`
}
type ToolCallRequest ¶
type ToolCallResult ¶
type ToolCallResult struct {
// Raw content returned by the tool.
Content string
// Error (non-protocol) to send back to the LLM.
Error error
}
func NewToolCallResult ¶
func NewToolCallResult(content string, err error) *ToolCallResult
type ToolHandlerFunc ¶
type ToolHandlerFunc func(params ToolHandlerParams) (*ToolCallResult, error)
type ToolHandlerParams ¶
type ToolHandlerParams struct {
context.Context
ExtendedConfigProvider
KubernetesClient
ToolCallRequest
ListOutput output.Output
}
type Toolset ¶
type Toolset interface {
// GetName returns the name of the toolset.
// Used to identify the toolset in configuration, logs, and command-line arguments.
// Examples: "core", "metrics", "helm"
GetName() string
// GetDescription returns a human-readable description of the toolset.
// Will be used to generate documentation and help text.
GetDescription() string
GetTools(o Openshift) []ServerTool
// GetPrompts returns the prompts provided by this toolset.
// Returns nil if the toolset doesn't provide any prompts.
GetPrompts() []ServerPrompt
}