actionregistry

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package actionregistry provides the canonical GitLab action catalog used by higher-level MCP tool surfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DomainFromToolName

func DomainFromToolName(toolName string) string

DomainFromToolName returns the canonical dynamic domain for a meta-tool name.

func ToActionMaps

func ToActionMaps(catalog *Catalog) map[string]toolutil.ActionMap

ToActionMaps returns legacy route maps for compatibility with existing schema resources, audits, and registration paths.

Types

type Action

type Action struct {
	ID        ActionID
	ToolName  string
	Domain    string
	Name      string
	Route     toolutil.ActionRoute
	SchemaURI string
	Aliases   []string
	Tags      []string
	ReadOnly  bool
}

Action describes one executable GitLab action in the canonical catalog.

type ActionID

type ActionID string

ActionID is the stable dynamic identifier for one GitLab action.

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

Catalog stores deterministic groups and action lookup indexes. A Catalog is intended to be mutated during single-threaded initialization and then shared read-only; concurrent mutation is not supported.

func FromActionMaps

func FromActionMaps(routes map[string]toolutil.ActionMap) *Catalog

FromActionMaps converts legacy route maps into a canonical catalog.

func FromActionMapsWithError

func FromActionMapsWithError(routes map[string]toolutil.ActionMap) (*Catalog, error)

FromActionMapsWithError converts legacy route maps into a canonical catalog and reports invalid groups instead of panicking.

func NewCatalog

func NewCatalog() *Catalog

NewCatalog creates an empty action catalog.

func (*Catalog) Action

func (c *Catalog) Action(id ActionID) (Action, bool)

Action returns a defensive copy of one action by canonical ID.

func (*Catalog) ActionMaps

func (c *Catalog) ActionMaps() map[string]toolutil.ActionMap

ActionMaps returns a defensive legacy route snapshot keyed by tool and action.

func (*Catalog) Actions

func (c *Catalog) Actions() []Action

Actions returns all actions sorted by canonical ID.

func (*Catalog) AddAction

func (c *Catalog) AddAction(toolName string, action Action, groupOptions ...GroupOptions) error

AddAction adds one action to an existing or newly-created group. When the group does not exist, callers may provide GroupOptions so the synthesized group carries the same metadata as a normal catalog group.

func (*Catalog) AddGroup

func (c *Catalog) AddGroup(group Group) error

AddGroup adds a complete group to the catalog.

func (*Catalog) Clone

func (c *Catalog) Clone() *Catalog

Clone returns a defensive deep copy of the catalog.

func (*Catalog) CountActions

func (c *Catalog) CountActions() int

CountActions returns the number of actions in the catalog.

func (*Catalog) CountGroups

func (c *Catalog) CountGroups() int

CountGroups returns the number of groups in the catalog.

func (*Catalog) Filter

func (c *Catalog) Filter(opts FilterOptions) *Catalog

Filter applies all catalog-level filters in a deterministic order.

func (*Catalog) FilterAllowedToolNames

func (c *Catalog) FilterAllowedToolNames(toolNames []string) *Catalog

FilterAllowedToolNames returns a cloned catalog with only explicitly allowed tools.

func (*Catalog) FilterExcludedTools

func (c *Catalog) FilterExcludedTools(excludeTools []string) *Catalog

FilterExcludedTools returns a cloned catalog without excluded tool groups.

func (*Catalog) FilterReadOnlyGroups

func (c *Catalog) FilterReadOnlyGroups() *Catalog

FilterReadOnlyGroups returns a cloned catalog containing only read-only groups.

func (*Catalog) Group

func (c *Catalog) Group(toolName string) (Group, bool)

Group returns a defensive copy of one group by tool name.

func (*Catalog) Groups

func (c *Catalog) Groups() []Group

Groups returns all groups sorted by tool name.

func (*Catalog) Validate

func (c *Catalog) Validate() error

Validate verifies that the catalog has a consistent, executable action index.

type FilterOptions

type FilterOptions struct {
	ExcludeTools     []string
	ReadOnlyOnly     bool
	AllowedToolNames []string
}

FilterOptions describes catalog-level filtering inputs.

type Group

type Group struct {
	ToolName     string
	Description  string
	Icons        []mcp.Icon
	ReadOnly     bool
	FormatResult toolutil.FormatResultFunc
	Actions      map[string]Action
	ActionOrder  []string
}

Group describes all actions exposed through one logical meta-tool group.

func NewGroup

func NewGroup(opts GroupOptions) Group

NewGroup creates an action group with initialized maps.

func (*Group) ActionMap

func (g *Group) ActionMap() toolutil.ActionMap

ActionMap returns a legacy route map for this group.

func (*Group) ActionsInOrder

func (g *Group) ActionsInOrder() []Action

ActionsInOrder returns group actions in deterministic action-name order.

func (*Group) SetAction

func (g *Group) SetAction(action Action)

SetAction inserts or replaces an action in the group.

type GroupOptions

type GroupOptions struct {
	ToolName     string
	Description  string
	Icons        []mcp.Icon
	ReadOnly     bool
	FormatResult toolutil.FormatResultFunc
}

GroupOptions contains metadata for creating a catalog group.

Jump to

Keyboard shortcuts

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