group

package
v1.11.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultTTLMs      = 300000   // default TTL for groups in milliseconds (5 minutes)
	DefaultCacheScope = "public" // default cache scope for groups
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	GroupConfig
	// contains filtered or unexported fields
}

Group is an initialized group: the source of truth for a named collection of tools, prompts, resources, and resource templates. It is a self-contained MCP primitive and does not depend on the legacy toolset/promptset types. It keeps O(1) membership sets for its tools, prompts, resources, and templates; manifests are generated on demand by callers from the resolved primitive maps.

func NewGroup

func NewGroup(config GroupConfig) Group

NewGroup builds a Group directly from its config, deriving the membership sets from the declared tool, prompt, resource, and template names. It skips the existence checks performed by GroupConfig.Initialize and is intended for tests and callers that have already validated the names.

func (Group) ContainsPrompt

func (g Group) ContainsPrompt(name string) bool

ContainsPrompt reports whether the group includes a prompt with the given name.

func (Group) ContainsResource added in v1.11.0

func (g Group) ContainsResource(name string) bool

ContainsResource reports whether the group includes a resource with the given name.

func (Group) ContainsResourceTemplate added in v1.11.0

func (g Group) ContainsResourceTemplate(name string) bool

ContainsResourceTemplate reports whether the group includes a resource template with the given name.

func (Group) ContainsTool

func (g Group) ContainsTool(name string) bool

ContainsTool reports whether the group includes a tool with the given name.

func (Group) GetCacheScope added in v1.9.0

func (g Group) GetCacheScope() string

GetCacheScope returns the cache scope for the group

func (Group) GetTTLMs added in v1.9.0

func (g Group) GetTTLMs() int

GetTTLMs returns the time to live for the group

func (Group) ToolsetManifest

func (g Group) ToolsetManifest(serverVersion string, mgr GroupManager) (tools.ToolsetManifest, error)

ToolsetManifest builds a tools.ToolsetManifest for the group's tools, resolving each declared tool name against toolsMap and generating its manifest from srcs. The group holds tool names rather than tool pointers, so callers pass the resolved tools and sources maps.

type GroupConfig

type GroupConfig struct {
	Name                  string   `yaml:"name"`
	Description           string   `yaml:"description"`
	ToolNames             []string `yaml:"tools"`
	PromptNames           []string `yaml:"prompts"`
	ResourceNames         []string `yaml:"resources"`
	ResourceTemplateNames []string `yaml:"resourceTemplates"`
	CacheScope            string   `yaml:"cacheScope" validate:"omitempty,oneof=public private"`
	TTLMs                 *int     `yaml:"ttlMs" validate:"omitempty,gte=0"`
}

GroupConfig is the parsed configuration for a group: a single named collection that holds tools, prompts, resources, and resource templates. Its description doubles as the MCP server instructions for clients connected to the group.

func (GroupConfig) Initialize

func (gc GroupConfig) Initialize(toolsMap map[string]tools.Tool, promptsMap map[string]prompts.Prompt, resourcesMap map[string]resources.Resource, templatesMap map[string]resources.ResourceTemplate) (Group, error)

Initialize validates the group name and checks that every declared tool, prompt, resource, and template exists in the provided maps, building the membership sets used by ContainsTool, ContainsPrompt, ContainsResource, and ContainsResourceTemplate.

type GroupManager

type GroupManager interface {
	GetSource(string) (sources.Source, bool)
	GetTool(string) (tools.Tool, bool)
}

GroupManager defines the minimal view of the primitives.PrimitiveManager that the Group package needs. This is implemented to prevent import cycles.

Jump to

Keyboard shortcuts

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