tools

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package tools is the shared kit for kcp MCP tools: the Scope authorization contract every tool operates within, plus helpers for GVR parsing and unstructured object handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractListItems

func ExtractListItems(list any) []map[string]any

ExtractListItems returns the items of an unstructured list as raw maps.

func ExtractObject

func ExtractObject(obj any) map[string]any

ExtractObject returns an unstructured object's content as a raw map.

func ParseGVR

func ParseGVR(group, version, resource string) (schema.GroupVersionResource, error)

ParseGVR builds a GroupVersionResource from explicit tool input. Group is empty for the core API group; version and resource are required.

func ReadOnly

func ReadOnly(title string) *mcp.ToolAnnotations

ReadOnly returns tool annotations with a human-readable title marking a tool as read-only, so MCP clients can distinguish safe reads from mutations (e.g. for auto-approval).

func ResolveGVR

func ResolveGVR(disc discovery.DiscoveryInterface, apiVersion, kind string) (schema.GroupVersionResource, error)

ResolveGVR maps a manifest's apiVersion and kind to a resource using the workspace's own discovery. Guessing the plural from the kind would silently produce a wrong resource for CRDs with irregular plurals; discovery is exact and reflects exactly the APIs bound into that workspace.

Types

type ClusterInfo

type ClusterInfo struct {
	ClusterName string
	Endpoint    string
}

ClusterInfo holds workspace endpoint information.

type Scope

type Scope interface {
	// Names returns the workspace IDs the caller has access to.
	Names() []string

	// HasAccess reports whether workspace is in the caller's scope.
	HasAccess(workspace string) bool

	// ClientFor returns typed and dynamic clients for the given workspace,
	// acting as the caller.
	ClientFor(workspace string) (kubernetes.Interface, dynamic.Interface, error)

	// Clusters returns the raw workspace access info (name + endpoint).
	Clusters() []ClusterInfo
}

Scope is the per-caller authorization context the tools operate within: the set of workspaces the caller may reach and how to obtain clients for them.

type ScopeError

type ScopeError struct {
	Requested string   `json:"requested"`
	Available []string `json:"available"`
}

ScopeError is returned when a tool targets a workspace outside the caller's scope. It carries both the requested workspace and the available ones so the model understands the access boundary.

func NewScopeError

func NewScopeError(workspace string, scope Scope) *ScopeError

NewScopeError creates a ScopeError for the given workspace and scope.

func (*ScopeError) Error

func (e *ScopeError) Error() string

Directories

Path Synopsis
Package admin provides read tools for kcp operator internals — LogicalClusters, Shards, Partitions and PartitionSets.
Package admin provides read tools for kcp operator internals — LogicalClusters, Shards, Partitions and PartitionSets.
Package apis provides read tools for the machinery of kcp's API sharing model — APIResourceSchemas and APIConversions.
Package apis provides read tools for the machinery of kcp's API sharing model — APIResourceSchemas and APIConversions.
Package core is the default toolset: navigating the caller's workspaces (workspaces, APIBindings, APIExports, WorkspaceTypes, workspace lifecycle) plus generic read access to any resource by GVR.
Package core is the default toolset: navigating the caller's workspaces (workspaces, APIBindings, APIExports, WorkspaceTypes, workspace lifecycle) plus generic read access to any resource by GVR.
Package write provides generic mutation tools — create, update, patch, delete and scale by GVR.
Package write provides generic mutation tools — create, update, patch, delete and scale by GVR.

Jump to

Keyboard shortcuts

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