instructions

package
v0.70.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package instructions defines the configuration that sets the instructions an MCP endpoint returns to clients in its initialize and server/discover results. MCPServer, MCPRemoteProxy and VirtualMCPServer share it.

+kubebuilder:object:generate=true +groupName=toolhive.stacklok.dev +versionName=instructions

Index

Constants

View Source
const MaxValueLength = 65536

MaxValueLength is the most characters a value may hold. The RunConfig ConfigMap holds the value twice, in the typed field and in the middleware parameters, and JSON encodes a character in at most six bytes, so both copies stay well under the 1 MiB a ConfigMap may hold.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Mode says how value combines with the instructions the server returns.
	// replace returns value alone. append returns the server's instructions,
	// a blank line, and value. prepend returns value, a blank line, and the
	// server's instructions. When the server returns no instructions, every
	// mode returns value alone.
	// +kubebuilder:validation:Enum=replace;append;prepend
	// +kubebuilder:default=append
	// +optional
	Mode Mode `json:"mode,omitempty" yaml:"mode,omitempty"`

	// Value is the text that mode combines with the server's instructions.
	// Leading and trailing ASCII white space (tab, LF, FF, CR, space) is
	// dropped, and a value that is only such white space is rejected.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MinLength=1
	// +kubebuilder:validation:MaxLength=65536
	// +kubebuilder:validation:Pattern=`\S`
	Value string `json:"value" yaml:"value"`
}

Config sets the instructions an MCP endpoint returns to clients in the result of a successful initialize or server/discover request. Clients commonly add server instructions to the model's context, so this is where an operator adds policy or usage guidance without changing the server.

+gendoc

func (*Config) Apply

func (c *Config) Apply(server string) string

Apply returns the instructions a client receives when the server returns server, which is empty when the server returns none. The value is used without its leading and trailing ASCII white space (see asciiSpace), so a file that ends in a newline or a YAML block adds no blank line.

func (*Config) DeepCopy

func (in *Config) DeepCopy() *Config

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Config.

func (*Config) DeepCopyInto

func (in *Config) DeepCopyInto(out *Config)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Config) Validate

func (c *Config) Validate() error

Validate reports whether the configuration can be applied. An empty Mode is valid and means ModeAppend.

type Mode

type Mode string

Mode says how the configured value combines with the instructions the server returns.

const (
	// ModeReplace returns the configured value in place of the server's
	// instructions.
	ModeReplace Mode = "replace"
	// ModeAppend returns the server's instructions, a blank line, and then the
	// configured value.
	ModeAppend Mode = "append"
	// ModePrepend returns the configured value, a blank line, and then the
	// server's instructions.
	ModePrepend Mode = "prepend"
)

Jump to

Keyboard shortcuts

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