tools

package
v0.0.406 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package tools holds the read-only MCP tools served on the mcpservers/mcp subresource (designs-and-proposals storage-mcp-endpoint.md). They read only through Reader, so they do not depend on how the data is fetched or how the caller's access is checked.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorResult added in v0.0.391

func ErrorResult(code ErrorCode, message string, details map[string]any) *mcp.CallToolResult

ErrorResult is the tool error result with code, message and details.

func Register

func Register(s *server.MCPServer, r Reader, opts ...Option)

Register adds every tool to s.

func SizeHint added in v0.0.391

func SizeHint(tool string) string

SizeHint says how to ask tool for less, for an answer above the endpoint's size cap.

func Tools added in v0.0.404

func Tools(r Reader, opts ...Option) []server.ServerTool

Tools returns every tool with its handler, for a server that adds them itself, for example to wrap the handlers.

func WithDefaultNamespace

func WithDefaultNamespace(ctx context.Context, namespace string) context.Context

WithDefaultNamespace sets the namespace a tool uses when the call gives none.

Types

type ErrorCode

type ErrorCode string

ErrorCode is the code of a tool error. The codes and the ToolError shape are the ones kubescape mcpserver uses, so agents handle both the same way.

const (
	ErrCodeResourceNotFound ErrorCode = "RESOURCE_NOT_FOUND"
	ErrCodeRBACDenied       ErrorCode = "RBAC_DENIED"
	ErrCodeInvalidArgument  ErrorCode = "INVALID_ARGUMENT"
	ErrCodeTimeout          ErrorCode = "TIMEOUT"
	// ErrCodeResponseTooLarge is the answer to a call whose result is above
	// the endpoint's size cap.
	ErrCodeResponseTooLarge ErrorCode = "RESPONSE_TOO_LARGE"
)

type Option added in v0.0.404

type Option func(*options)

Option changes the tools for a server other than storage's endpoint, such as kubescape mcpserver.

func WithNamespaceDescription added in v0.0.404

func WithNamespaceDescription(tool, description string) Option

WithNamespaceDescription replaces the description of tool's namespace argument, for a server whose default namespace is not the one in the endpoint's URL.

func WithResourceLinks() Option

WithResourceLinks adds kubescape:// resource links to the answers of list_vulnerability_manifests, list_configuration_security_scan_manifests and list_container_profiles: a resource_uri for each item and the available_templates. Only for a server that serves those resource templates; storage's endpoint does not.

type Reader

type Reader interface {
	ListVulnerabilityManifests(ctx context.Context, namespace string, opts metav1.ListOptions) (*v1beta1.VulnerabilityManifestList, error)
	GetVulnerabilityManifest(ctx context.Context, namespace, name string) (*v1beta1.VulnerabilityManifest, error)
	ListSBOMSyfts(ctx context.Context, namespace string, opts metav1.ListOptions) (*v1beta1.SBOMSyftList, error)
	GetSBOMSyft(ctx context.Context, namespace, name string) (*v1beta1.SBOMSyft, error)
	ListWorkloadConfigurationScans(ctx context.Context, namespace string, opts metav1.ListOptions) (*v1beta1.WorkloadConfigurationScanList, error)
	GetWorkloadConfigurationScan(ctx context.Context, namespace, name string) (*v1beta1.WorkloadConfigurationScan, error)
	ListContainerProfiles(ctx context.Context, namespace string, opts metav1.ListOptions) (*v1beta1.ContainerProfileList, error)
	GetContainerProfile(ctx context.Context, namespace, name string) (*v1beta1.ContainerProfile, error)
}

Reader is what the tools read from. A denied read returns a Forbidden error, as the Kubernetes API does.

type ToolError

type ToolError struct {
	Code    ErrorCode      `json:"code"`
	Message string         `json:"message"`
	Details map[string]any `json:"details,omitempty"`
}

ToolError is the JSON text of a tool error result.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL