Documentation
¶
Index ¶
- Constants
- Variables
- func FormatResourceName(gvr *schema.GroupVersionResource) string
- 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 ConfirmationRule
- type ConfirmationRulesProvider
- type DeniedResourcesProvider
- type ElicitParams
- type ElicitResult
- type Elicitor
- type ErrInvalidInt64Type
- type ExtendedConfig
- type ExtendedConfigProvider
- type GroupVersionKind
- type HTTPValidationRequest
- type HTTPValidator
- 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 RequireTLSProvider
- type ServerPrompt
- type ServerTool
- type StsConfigProvider
- type Tool
- type ToolAnnotations
- type ToolCallRequest
- type ToolCallResult
- type ToolHandlerFunc
- type ToolHandlerParams
- type Toolset
- type ValidationEnabledProvider
- type ValidationError
- type ValidationErrorCode
Constants ¶
const ( ClusterProviderKubeConfig = "kubeconfig" ClusterProviderInCluster = "in-cluster" ClusterProviderDisabled = "disabled" ClusterProviderKcp = "kcp" )
const ( // ElicitActionAccept indicates the user submitted the form with content. ElicitActionAccept = "accept" // ElicitActionDecline indicates the user explicitly declined the request. ElicitActionDecline = "decline" // ElicitActionCancel indicates the user dismissed the form without making a choice. ElicitActionCancel = "cancel" )
ElicitAction constants define the possible user responses to an elicitation request. See MCP specification: https://modelcontextprotocol.io/specification/2025-11-25/client/elicitation
Variables ¶
var ErrElicitationNotSupported = errors.New("client does not support elicitation")
ErrElicitationNotSupported is returned when the MCP client does not support elicitation.
Functions ¶
func FormatResourceName ¶ added in v0.0.58
func FormatResourceName(gvr *schema.GroupVersionResource) string
FormatResourceName creates a human-readable resource identifier from GVR.
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 ClusterProvider ¶ added in v0.0.56
type ConfirmationRule ¶ added in v0.0.60
type ConfirmationRule struct {
// Tool-level fields
Tool string `toml:"tool,omitempty"`
Destructive *bool `toml:"destructive,omitempty"`
// Kube-level fields
Verb string `toml:"verb,omitempty"`
Kind string `toml:"kind,omitempty"`
Group string `toml:"group,omitempty"`
Version string `toml:"version,omitempty"`
Name string `toml:"name,omitempty"`
Namespace string `toml:"namespace,omitempty"`
// Common fields
Message string `toml:"message"`
}
ConfirmationRule defines a rule for prompting the user before an action. Rules are classified as tool-level or kube-level based on which fields are set. A rule must not have both tool-level and kube-level fields set.
func (*ConfirmationRule) IsKubeLevel ¶ added in v0.0.60
func (r *ConfirmationRule) IsKubeLevel() bool
IsKubeLevel returns true if the rule targets Kubernetes API requests.
func (*ConfirmationRule) IsToolLevel ¶ added in v0.0.60
func (r *ConfirmationRule) IsToolLevel() bool
IsToolLevel returns true if the rule targets MCP tool invocations.
func (*ConfirmationRule) Validate ¶ added in v0.0.60
func (r *ConfirmationRule) Validate() error
Validate checks that the rule is well-formed. A rule must be either tool-level or kube-level (not both, and not neither). Tool-level rules must not contain kube-level-only fields and vice versa.
type ConfirmationRulesProvider ¶ added in v0.0.60
type ConfirmationRulesProvider interface {
GetConfirmationRules() []ConfirmationRule
GetConfirmationFallback() string
}
ConfirmationRulesProvider provides access to confirmation rules and the global fallback.
type DeniedResourcesProvider ¶ added in v0.0.56
type DeniedResourcesProvider interface {
// GetDeniedResources returns a list of GroupVersionKinds that are denied.
GetDeniedResources() []GroupVersionKind
}
type ElicitParams ¶ added in v0.0.59
type ElicitParams struct {
// Message is the message to present to the user.
Message string
// RequestedSchema is a JSON Schema defining the expected form fields. Used in form mode only.
RequestedSchema *jsonschema.Schema
// URL is the URL to present to the user. Used in URL mode only.
URL string
// ElicitationID is a tracking identifier for out-of-band URL elicitation completion. Used in URL mode only.
ElicitationID string
}
ElicitParams contains the parameters for an elicitation request. The elicitation mode is inferred from the fields: if URL is set, URL mode is used; otherwise form mode.
type ElicitResult ¶ added in v0.0.59
type ElicitResult struct {
// Action is one of the ElicitAction constants.
Action string
// Content contains the submitted form data. Only populated when Action is ElicitActionAccept.
Content map[string]any
}
ElicitResult represents the user's response to an elicitation request.
type Elicitor ¶ added in v0.0.59
type Elicitor interface {
Elicit(ctx context.Context, params *ElicitParams) (*ElicitResult, error)
}
Elicitor provides a mechanism for tools and prompts to request additional information from the user during execution via the MCP elicitation protocol. It supports two modes:
- Form mode: presents a schema-based form to the user (set Message and RequestedSchema in ElicitParams).
- URL mode: directs the user to a URL (set Message, URL, and optionally ElicitationID in ElicitParams).
See MCP specification: https://modelcontextprotocol.io/specification/2025-11-25/client/elicitation
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 HTTPValidationRequest ¶ added in v0.0.58
type HTTPValidationRequest struct {
GVR *schema.GroupVersionResource
GVK *schema.GroupVersionKind
HTTPMethod string // GET, POST, PUT, DELETE, PATCH
Verb string // get, list, create, update, delete, patch
Namespace string
ResourceName string
Body []byte // For create/update validation
Path string
}
HTTPValidationRequest contains info extracted from an HTTP request for validation.
type HTTPValidator ¶ added in v0.0.58
type HTTPValidator interface {
Validate(ctx context.Context, req *HTTPValidationRequest) error
Name() string
}
HTTPValidator validates HTTP requests before they reach the K8s API server.
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
BaseConfig
KubernetesClient
PromptCallRequest
Elicitor
}
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 RequireTLSProvider ¶ added in v0.0.60
type RequireTLSProvider interface {
IsRequireTLS() bool
}
RequireTLSProvider provides access to require_tls setting.
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 StsConfigProvider ¶ added in v0.0.57
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"`
// Meta contains additional metadata for the tool (e.g., MCP Apps UI resource URI).
// Example: map[string]any{"ui": map[string]any{"resourceUri": "ui://server/app.html"}}
Meta map[string]any `json:"_meta,omitempty"`
// 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
// StructuredContent is an optional JSON-serializable value for MCP Apps UI rendering.
// When set, it is passed as structuredContent in the MCP CallToolResult alongside Content.
// Must be completely omitted (nil) when not used.
StructuredContent any
// Error (non-protocol) to send back to the LLM.
Error error
}
func NewToolCallResult ¶
func NewToolCallResult(content string, err error) *ToolCallResult
NewToolCallResult creates a ToolCallResult with text content only. Use this for tools that return human-readable text output.
func NewToolCallResultFull ¶ added in v0.0.60
func NewToolCallResultFull(text string, structured any, err error) *ToolCallResult
NewToolCallResultFull creates a ToolCallResult with both human-readable text and structured content. Use this when the text representation differs from a JSON serialization of the structured content (e.g., YAML or Table text alongside extracted structured data).
func NewToolCallResultStructured ¶ added in v0.0.58
func NewToolCallResultStructured(structured any, err error) *ToolCallResult
NewToolCallResultStructured creates a ToolCallResult with structured content. The structured value is automatically JSON-serialized into the Content field for backward compatibility with MCP clients that don't support structuredContent.
Per the MCP specification: "For backwards compatibility, a tool that returns structured content SHOULD also return the serialized JSON in a TextContent block." https://modelcontextprotocol.io/specification/2025-11-25/server/tools#structured-content
Use this for tools that return typed/structured data (maps, slices, structs) that MCP clients can parse programmatically.
type ToolHandlerFunc ¶
type ToolHandlerFunc func(params ToolHandlerParams) (*ToolCallResult, error)
type ToolHandlerParams ¶
type ToolHandlerParams struct {
context.Context
BaseConfig
KubernetesClient
ToolCallRequest
ListOutput output.Output
Elicitor
}
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
}
type ValidationEnabledProvider ¶ added in v0.0.58
type ValidationEnabledProvider interface {
IsValidationEnabled() bool
}
ValidationEnabledProvider provides access to validation enabled setting.
type ValidationError ¶ added in v0.0.58
type ValidationError struct {
Code ValidationErrorCode
Message string
Field string // optional, for field-level errors
}
ValidationError provides AI-friendly error information for validation failures.
func NewPermissionDeniedError ¶ added in v0.0.58
func NewPermissionDeniedError(verb, resource, namespace string) *ValidationError
NewPermissionDeniedError creates an error for RBAC permission failures.
func (*ValidationError) Error ¶ added in v0.0.58
func (e *ValidationError) Error() string
Error implements the error interface.
type ValidationErrorCode ¶ added in v0.0.58
type ValidationErrorCode string
ValidationErrorCode categorizes validation failures.
const ( ErrorCodeResourceNotFound ValidationErrorCode = "RESOURCE_NOT_FOUND" ErrorCodeInvalidField ValidationErrorCode = "INVALID_FIELD" ErrorCodePermissionDenied ValidationErrorCode = "PERMISSION_DENIED" )