tools

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation ¶

Overview ¶

Copyright 2025 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index ¶

Constants ¶

This section is empty.

Variables ¶

View Source
var ErrUnauthorized = errors.New("unauthorized")

Functions ¶

func CheckDuplicateParameters ¶ added in v0.10.0

func CheckDuplicateParameters(ps Parameters) error

CheckDuplicateParameters verify there are no duplicate parameter names

func CheckParamRequired ¶ added in v0.10.0

func CheckParamRequired(required bool, defaultV any) bool

CheckParamRequired checks if a parameter is required based on the required and default field.

func ConvertAnySliceToTyped ¶ added in v0.9.0

func ConvertAnySliceToTyped(s []any, itemType string) (any, error)

ConvertAnySliceToTyped a []any to typed slice ([]string, []int, []float etc.)

func ConvertArrayParamToString ¶ added in v0.7.0

func ConvertArrayParamToString(param any) (string, error)

helper function to convert a string array parameter to a comma separated string

func IsAuthorized ¶ added in v0.0.4

func IsAuthorized(authRequiredSources []string, verifiedAuthServices []string) bool

Helper function that returns if a tool invocation request is authorized

func IsValidName ¶

func IsValidName(s string) bool

func MatchStringOrRegex ¶ added in v0.18.0

func MatchStringOrRegex(input, target any) bool

MatchStringOrRegex checks if the input matches the target

func PopulateTemplate ¶ added in v0.15.0

func PopulateTemplate(templateName, templateString string, data map[string]any) (string, error)

PopulateTemplate populate a Go template with no custom formatters

func PopulateTemplateWithFunc ¶ added in v0.15.0

func PopulateTemplateWithFunc(templateName, templateString string, data map[string]any, funcMap template.FuncMap) (string, error)

PopulateTemplateWithFunc populate a Go template with provided functions

func PopulateTemplateWithJSON ¶ added in v0.10.0

func PopulateTemplateWithJSON(templateName, templateString string, data map[string]any) (string, error)

PopulateTemplateWithJSON populate a Go template with a custom `json` array formatter

func ProcessParameters ¶ added in v0.7.0

func ProcessParameters(templateParams Parameters, params Parameters) (Parameters, []ParameterManifest, error)

ProcessParameters concatenate templateParameters and parameters from a tool. It returns a list of concatenated parameters, concatenated Toolbox manifest, and concatenated MCP Manifest.

func Register ¶ added in v0.7.0

func Register(kind string, factory ToolConfigFactory) bool

Register allows individual tool packages to register their configuration factory function. This is typically called from an init() function in the tool's package. It associates a 'kind' string with a function that can produce the specific ToolConfig type. It returns true if the registration was successful, and false if a tool with the same kind was already registered.

func ResolveTemplateParams ¶ added in v0.7.0

func ResolveTemplateParams(templateParams Parameters, originalStatement string, paramsMap map[string]any) (string, error)

Types ¶

type AccessToken ¶ added in v0.13.0

type AccessToken string

func (AccessToken) ParseBearerToken ¶ added in v0.15.0

func (token AccessToken) ParseBearerToken() (string, error)

type ArrayParameter ¶

type ArrayParameter struct {
	CommonParameter `yaml:",inline"`
	Default         *[]any    `yaml:"default"`
	Items           Parameter `yaml:"items"`
}

ArrayParameter is a parameter representing the "array" type.

func NewArrayParameter ¶

func NewArrayParameter(name string, desc string, items Parameter) *ArrayParameter

NewArrayParameter is a convenience function for initializing a ArrayParameter.

func NewArrayParameterWithAllowedValues ¶ added in v0.18.0

func NewArrayParameterWithAllowedValues(name string, desc string, allowedValues []any, items Parameter) *ArrayParameter

NewArrayParameterWithAllowedValues is a convenience function for initializing a ArrayParameter with a list of allowed values.

func NewArrayParameterWithAuth ¶ added in v0.0.4

func NewArrayParameterWithAuth(name string, desc string, items Parameter, authServices []ParamAuthService) *ArrayParameter

NewArrayParameterWithAuth is a convenience function for initializing a ArrayParameter with a list of ParamAuthService.

func NewArrayParameterWithDefault ¶ added in v0.8.0

func NewArrayParameterWithDefault(name string, defaultV []any, desc string, items Parameter) *ArrayParameter

NewArrayParameterWithDefault is a convenience function for initializing a ArrayParameter with default value.

func NewArrayParameterWithExcludedValues ¶ added in v0.19.0

func NewArrayParameterWithExcludedValues(name string, desc string, excludedValues []any, items Parameter) *ArrayParameter

NewArrayParameterWithExcludedValues is a convenience function for initializing a ArrayParameter with a list of excluded values.

func NewArrayParameterWithRequired ¶ added in v0.10.0

func NewArrayParameterWithRequired(name string, desc string, required bool, items Parameter) *ArrayParameter

NewArrayParameterWithRequired is a convenience function for initializing a ArrayParameter with default value.

func (*ArrayParameter) GetAuthServices ¶ added in v0.2.0

func (p *ArrayParameter) GetAuthServices() []ParamAuthService

func (*ArrayParameter) GetDefault ¶ added in v0.8.0

func (p *ArrayParameter) GetDefault() any

func (*ArrayParameter) GetItems ¶ added in v0.9.0

func (p *ArrayParameter) GetItems() Parameter

func (*ArrayParameter) IsAllowedValues ¶ added in v0.18.0

func (p *ArrayParameter) IsAllowedValues(v []any) bool

func (*ArrayParameter) IsExcludedValues ¶ added in v0.19.0

func (p *ArrayParameter) IsExcludedValues(v []any) bool

func (*ArrayParameter) Manifest ¶ added in v0.2.0

func (p *ArrayParameter) Manifest() ParameterManifest

Manifest returns the manifest for the ArrayParameter.

func (*ArrayParameter) McpManifest ¶ added in v0.3.0

func (p *ArrayParameter) McpManifest() (ParameterMcpManifest, []string)

McpManifest returns the MCP manifest for the ArrayParameter.

func (*ArrayParameter) Parse ¶

func (p *ArrayParameter) Parse(v any) (any, error)

func (*ArrayParameter) UnmarshalYAML ¶

func (p *ArrayParameter) UnmarshalYAML(ctx context.Context, unmarshal func(interface{}) error) error

type BooleanParameter ¶

type BooleanParameter struct {
	CommonParameter `yaml:",inline"`
	Default         *bool `yaml:"default"`
}

BooleanParameter is a parameter representing the "boolean" type.

func NewBooleanParameter ¶

func NewBooleanParameter(name string, desc string) *BooleanParameter

NewBooleanParameter is a convenience function for initializing a BooleanParameter.

func NewBooleanParameterWithAllowedValues ¶ added in v0.18.0

func NewBooleanParameterWithAllowedValues(name string, desc string, allowedValues []any) *BooleanParameter

NewBooleanParameterWithAllowedValues is a convenience function for initializing a BooleanParameter with a list of allowed values.

func NewBooleanParameterWithAuth ¶ added in v0.0.4

func NewBooleanParameterWithAuth(name string, desc string, authServices []ParamAuthService) *BooleanParameter

NewBooleanParameterWithAuth is a convenience function for initializing a BooleanParameter with a list of ParamAuthService.

func NewBooleanParameterWithDefault ¶ added in v0.8.0

func NewBooleanParameterWithDefault(name string, defaultV bool, desc string) *BooleanParameter

NewBooleanParameterWithDefault is a convenience function for initializing a BooleanParameter with default value.

func NewBooleanParameterWithExcludedValues ¶ added in v0.19.0

func NewBooleanParameterWithExcludedValues(name string, desc string, excludedValues []any) *BooleanParameter

NewBooleanParameterWithExcludedValues is a convenience function for initializing a BooleanParameter with a list of excluded values.

func NewBooleanParameterWithRequired ¶ added in v0.10.0

func NewBooleanParameterWithRequired(name string, desc string, required bool) *BooleanParameter

NewBooleanParameterWithRequired is a convenience function for initializing a BooleanParameter.

func (*BooleanParameter) GetAuthServices ¶ added in v0.2.0

func (p *BooleanParameter) GetAuthServices() []ParamAuthService

func (*BooleanParameter) GetDefault ¶ added in v0.8.0

func (p *BooleanParameter) GetDefault() any

func (*BooleanParameter) Manifest ¶ added in v0.8.0

func (p *BooleanParameter) Manifest() ParameterManifest

Manifest returns the manifest for the BooleanParameter.

func (*BooleanParameter) Parse ¶

func (p *BooleanParameter) Parse(v any) (any, error)

type CommonParameter ¶

type CommonParameter struct {
	Name           string             `yaml:"name" validate:"required"`
	Type           string             `yaml:"type" validate:"required"`
	Desc           string             `yaml:"description" validate:"required"`
	Required       *bool              `yaml:"required"`
	AllowedValues  []any              `yaml:"allowedValues"`
	ExcludedValues []any              `yaml:"excludedValues"`
	AuthServices   []ParamAuthService `yaml:"authServices"`
	AuthSources    []ParamAuthService `yaml:"authSources"` // Deprecated: Kept for compatibility.
}

CommonParameter are default fields that are emebdding in most Parameter implementations. Embedding this stuct will give the object Name() and Type() functions.

func (*CommonParameter) GetAllowedValues ¶ added in v0.18.0

func (p *CommonParameter) GetAllowedValues() []any

GetAllowedValues returns the allowed values for the Parameter.

func (*CommonParameter) GetExcludedValues ¶ added in v0.19.0

func (p *CommonParameter) GetExcludedValues() []any

GetExcludedValues returns the excluded values for the Parameter.

func (*CommonParameter) GetName ¶

func (p *CommonParameter) GetName() string

GetName returns the name specified for the Parameter.

func (*CommonParameter) GetRequired ¶ added in v0.10.0

func (p *CommonParameter) GetRequired() bool

GetRequired returns the type specified for the Parameter.

func (*CommonParameter) GetType ¶

func (p *CommonParameter) GetType() string

GetType returns the type specified for the Parameter.

func (*CommonParameter) IsAllowedValues ¶ added in v0.18.0

func (p *CommonParameter) IsAllowedValues(v any) bool

IsAllowedValues checks if the value is allowed.

func (*CommonParameter) IsExcludedValues ¶ added in v0.19.0

func (p *CommonParameter) IsExcludedValues(v any) bool

IsExcludedValues checks if the value is allowed.

func (*CommonParameter) McpManifest ¶ added in v0.3.0

func (p *CommonParameter) McpManifest() (ParameterMcpManifest, []string)

McpManifest returns the MCP manifest for the Parameter.

type FloatParameter ¶

type FloatParameter struct {
	CommonParameter `yaml:",inline"`
	Default         *float64 `yaml:"default"`
	MinValue        *float64 `yaml:"minValue"`
	MaxValue        *float64 `yaml:"maxValue"`
}

FloatParameter is a parameter representing the "float" type.

func NewFloatParameter ¶

func NewFloatParameter(name string, desc string) *FloatParameter

NewFloatParameter is a convenience function for initializing a FloatParameter.

func NewFloatParameterWithAllowedValues ¶ added in v0.18.0

func NewFloatParameterWithAllowedValues(name string, desc string, allowedValues []any) *FloatParameter

NewFloatParameterWithAllowedValues is a convenience function for initializing a FloatParameter with a list of allowed values.

func NewFloatParameterWithAuth ¶ added in v0.0.4

func NewFloatParameterWithAuth(name string, desc string, authServices []ParamAuthService) *FloatParameter

NewFloatParameterWithAuth is a convenience function for initializing a FloatParameter with a list of ParamAuthService.

func NewFloatParameterWithDefault ¶ added in v0.8.0

func NewFloatParameterWithDefault(name string, defaultV float64, desc string) *FloatParameter

NewFloatParameterWithDefault is a convenience function for initializing a FloatParameter with default value.

func NewFloatParameterWithExcludedValues ¶ added in v0.19.0

func NewFloatParameterWithExcludedValues(name string, desc string, excludedValues []any) *FloatParameter

NewFloatParameterWithExcludedValues is a convenience function for initializing a FloatParameter with a list of excluded values.

func NewFloatParameterWithRange ¶ added in v0.18.0

func NewFloatParameterWithRange(name string, desc string, minValue *float64, maxValue *float64) *FloatParameter

NewFloatParameterWithRange is a convenience function for initializing a FloatParameter.

func NewFloatParameterWithRequired ¶ added in v0.10.0

func NewFloatParameterWithRequired(name string, desc string, required bool) *FloatParameter

NewFloatParameterWithRequired is a convenience function for initializing a FloatParameter.

func (*FloatParameter) GetAuthServices ¶ added in v0.2.0

func (p *FloatParameter) GetAuthServices() []ParamAuthService

func (*FloatParameter) GetDefault ¶ added in v0.8.0

func (p *FloatParameter) GetDefault() any

func (*FloatParameter) Manifest ¶ added in v0.8.0

func (p *FloatParameter) Manifest() ParameterManifest

Manifest returns the manifest for the FloatParameter.

func (*FloatParameter) McpManifest ¶ added in v0.10.0

func (p *FloatParameter) McpManifest() (ParameterMcpManifest, []string)

McpManifest returns the MCP manifest for the FloatParameter. json schema only allow numeric types of 'integer' and 'number'.

func (*FloatParameter) Parse ¶

func (p *FloatParameter) Parse(v any) (any, error)

type HTTPMethod ¶ added in v0.3.0

type HTTPMethod string

HTTPMethod is a string of a valid HTTP method (e.g "GET")

func (*HTTPMethod) UnmarshalYAML ¶ added in v0.3.0

func (i *HTTPMethod) UnmarshalYAML(ctx context.Context, unmarshal func(interface{}) error) error

type IntParameter ¶

type IntParameter struct {
	CommonParameter `yaml:",inline"`
	Default         *int `yaml:"default"`
	MinValue        *int `yaml:"minValue"`
	MaxValue        *int `yaml:"maxValue"`
}

IntParameter is a parameter representing the "int" type.

func NewIntParameter ¶

func NewIntParameter(name string, desc string) *IntParameter

NewIntParameter is a convenience function for initializing a IntParameter.

func NewIntParameterWithAllowedValues ¶ added in v0.18.0

func NewIntParameterWithAllowedValues(name string, desc string, allowedValues []any) *IntParameter

NewIntParameterWithAllowedValues is a convenience function for initializing a IntParameter with a list of allowedValues

func NewIntParameterWithAuth ¶ added in v0.0.4

func NewIntParameterWithAuth(name string, desc string, authServices []ParamAuthService) *IntParameter

NewIntParameterWithAuth is a convenience function for initializing a IntParameter with a list of ParamAuthService.

func NewIntParameterWithDefault ¶ added in v0.8.0

func NewIntParameterWithDefault(name string, defaultV int, desc string) *IntParameter

NewIntParameterWithDefault is a convenience function for initializing a IntParameter with default value.

func NewIntParameterWithExcludedValues ¶ added in v0.19.0

func NewIntParameterWithExcludedValues(name string, desc string, excludedValues []any) *IntParameter

NewIntParameterWithExcludedValues is a convenience function for initializing a IntParameter with a list of excludedValues

func NewIntParameterWithRange ¶ added in v0.18.0

func NewIntParameterWithRange(name string, desc string, minValue *int, maxValue *int) *IntParameter

NewIntParameterWithRange is a convenience function for initializing a IntParameter.

func NewIntParameterWithRequired ¶ added in v0.10.0

func NewIntParameterWithRequired(name string, desc string, required bool) *IntParameter

NewIntParameterWithRequired is a convenience function for initializing a IntParameter.

func (*IntParameter) GetAuthServices ¶ added in v0.2.0

func (p *IntParameter) GetAuthServices() []ParamAuthService

func (*IntParameter) GetDefault ¶ added in v0.8.0

func (p *IntParameter) GetDefault() any

func (*IntParameter) Manifest ¶ added in v0.8.0

func (p *IntParameter) Manifest() ParameterManifest

Manifest returns the manifest for the IntParameter.

func (*IntParameter) Parse ¶

func (p *IntParameter) Parse(v any) (any, error)

type Manifest ¶ added in v0.0.2

type Manifest struct {
	Description  string              `json:"description"`
	Parameters   []ParameterManifest `json:"parameters"`
	AuthRequired []string            `json:"authRequired"`
}

Manifest is the representation of tools sent to Client SDKs.

type MapParameter ¶ added in v0.10.0

type MapParameter struct {
	CommonParameter `yaml:",inline"`
	Default         *map[string]any `yaml:"default,omitempty"`
	ValueType       string          `yaml:"valueType,omitempty"`
}

MapParameter is a parameter representing a map with string keys. If ValueType is specified (e.g., "string"), values are validated against that type. If ValueType is empty, it is treated as a generic map[string]any.

func NewMapParameter ¶ added in v0.10.0

func NewMapParameter(name string, desc string, valueType string) *MapParameter

NewMapParameter is a convenience function for initializing a MapParameter.

func NewMapParameterWithAllowedValues ¶ added in v0.18.0

func NewMapParameterWithAllowedValues(name string, desc string, allowedValues []any, valueType string) *MapParameter

NewMapParameterWithAllowedValues is a convenience function for initializing a MapParameter with a list of allowed values.

func NewMapParameterWithAuth ¶ added in v0.10.0

func NewMapParameterWithAuth(name string, desc string, valueType string, authServices []ParamAuthService) *MapParameter

NewMapParameterWithAuth is a convenience function for initializing a MapParameter with auth services.

func NewMapParameterWithDefault ¶ added in v0.10.0

func NewMapParameterWithDefault(name string, defaultV map[string]any, desc string, valueType string) *MapParameter

NewMapParameterWithDefault is a convenience function for initializing a MapParameter with a default value.

func NewMapParameterWithExcludedValues ¶ added in v0.19.0

func NewMapParameterWithExcludedValues(name string, desc string, excludedValues []any, valueType string) *MapParameter

NewMapParameterWithExcludedValues is a convenience function for initializing a MapParameter with a list of excluded values.

func NewMapParameterWithRequired ¶ added in v0.10.0

func NewMapParameterWithRequired(name string, desc string, required bool, valueType string) *MapParameter

NewMapParameterWithRequired is a convenience function for initializing a MapParameter as required.

func (*MapParameter) GetAuthServices ¶ added in v0.10.0

func (p *MapParameter) GetAuthServices() []ParamAuthService

func (*MapParameter) GetDefault ¶ added in v0.10.0

func (p *MapParameter) GetDefault() any

func (*MapParameter) GetValueType ¶ added in v0.10.0

func (p *MapParameter) GetValueType() string

func (*MapParameter) IsAllowedValues ¶ added in v0.18.0

func (p *MapParameter) IsAllowedValues(v map[string]any) bool

func (*MapParameter) IsExcludedValues ¶ added in v0.19.0

func (p *MapParameter) IsExcludedValues(v map[string]any) bool

func (*MapParameter) Manifest ¶ added in v0.10.0

func (p *MapParameter) Manifest() ParameterManifest

Manifest returns the manifest for the MapParameter.

func (*MapParameter) McpManifest ¶ added in v0.10.0

func (p *MapParameter) McpManifest() (ParameterMcpManifest, []string)

McpManifest returns the MCP manifest for the MapParameter.

func (*MapParameter) Parse ¶ added in v0.10.0

func (p *MapParameter) Parse(v any) (any, error)

Parse validates and parses an incoming value for the map parameter.

func (*MapParameter) UnmarshalYAML ¶ added in v0.10.0

func (p *MapParameter) UnmarshalYAML(ctx context.Context, unmarshal func(interface{}) error) error

UnmarshalYAML handles parsing the MapParameter from YAML input.

type McpManifest ¶ added in v0.3.0

type McpManifest struct {
	// The name of the tool.
	Name string `json:"name"`
	// A human-readable description of the tool.
	Description string `json:"description,omitempty"`
	// A JSON Schema object defining the expected parameters for the tool.
	InputSchema McpToolsSchema `json:"inputSchema,omitempty"`
	Metadata    map[string]any `json:"_meta,omitempty"`
}

Definition for a tool the MCP client can call.

func GetMcpManifest ¶ added in v0.17.0

func GetMcpManifest(name, desc string, authInvoke []string, params Parameters) McpManifest

type McpToolsSchema ¶ added in v0.3.0

type McpToolsSchema struct {
	Type       string                          `json:"type"`
	Properties map[string]ParameterMcpManifest `json:"properties"`
	Required   []string                        `json:"required"`
}

McpToolsSchema is the representation of input schema for McpManifest.

type ParamAuthService ¶ added in v0.2.0

type ParamAuthService struct {
	Name  string `yaml:"name"`
	Field string `yaml:"field"`
}

type ParamValue ¶ added in v0.0.3

type ParamValue struct {
	Name  string
	Value any
}

ParamValue represents the parameter's name and value.

type ParamValues ¶ added in v0.0.3

type ParamValues []ParamValue

ParamValues is an ordered list of ParamValue

func GetParams ¶ added in v0.7.0

func GetParams(params Parameters, paramValuesMap map[string]any) (ParamValues, error)

GetParams return the ParamValues that are associated with the Parameters.

func ParseParams ¶

func ParseParams(ps Parameters, data map[string]any, claimsMap map[string]map[string]any) (ParamValues, error)

ParseParams is a helper function for parsing Parameters from an arbitraryJSON object.

func (ParamValues) AsMap ¶ added in v0.0.3

func (p ParamValues) AsMap() map[string]interface{}

AsMap returns a map of ParamValue's names to values.

func (ParamValues) AsMapByOrderedKeys ¶ added in v0.0.3

func (p ParamValues) AsMapByOrderedKeys() map[string]interface{}

AsMapByOrderedKeys returns a map of a key's position to it's value, as necessary for Spanner PSQL. Example { $1 -> "value1", $2 -> "value2" }

func (ParamValues) AsMapWithDollarPrefix ¶ added in v0.1.0

func (p ParamValues) AsMapWithDollarPrefix() map[string]interface{}

AsMapWithDollarPrefix ensures all keys are prefixed with a dollar sign for Dgraph. Example: Input: {"role": "admin", "$age": 30} Output: {"$role": "admin", "$age": 30}

func (ParamValues) AsSlice ¶ added in v0.0.3

func (p ParamValues) AsSlice() []any

AsSlice returns a slice of the Param's values (in order).

type Parameter ¶

type Parameter interface {
	// Note: It's typically not idiomatic to include "Get" in the function name,
	// but this is done to differentiate it from the fields in CommonParameter.
	GetName() string
	GetType() string
	GetDefault() any
	GetRequired() bool
	GetAuthServices() []ParamAuthService
	Parse(any) (any, error)
	Manifest() ParameterManifest
	McpManifest() (ParameterMcpManifest, []string)
}

type ParameterManifest ¶

type ParameterManifest struct {
	Name                 string             `json:"name"`
	Type                 string             `json:"type"`
	Required             bool               `json:"required"`
	Description          string             `json:"description"`
	AuthServices         []string           `json:"authSources"`
	Items                *ParameterManifest `json:"items,omitempty"`
	AdditionalProperties any                `json:"additionalProperties,omitempty"`
}

ParameterManifest represents parameters when served as part of a ToolManifest.

type ParameterMcpManifest ¶ added in v0.3.0

type ParameterMcpManifest struct {
	Type                 string                `json:"type"`
	Description          string                `json:"description"`
	Items                *ParameterMcpManifest `json:"items,omitempty"`
	AdditionalProperties any                   `json:"additionalProperties,omitempty"`
}

ParameterMcpManifest represents properties when served as part of a ToolMcpManifest.

type Parameters ¶

type Parameters []Parameter

Parameters is a type used to allow unmarshal a list of parameters

func (Parameters) Manifest ¶ added in v0.0.2

func (ps Parameters) Manifest() []ParameterManifest

func (Parameters) McpManifest ¶ added in v0.3.0

func (ps Parameters) McpManifest() (McpToolsSchema, map[string][]string)

func (*Parameters) UnmarshalYAML ¶

func (c *Parameters) UnmarshalYAML(ctx context.Context, unmarshal func(interface{}) error) error

type ParseTypeError ¶

type ParseTypeError struct {
	Name  string
	Type  string
	Value any
}

ParseTypeError is a custom error for incorrectly typed Parameters.

func (ParseTypeError) Error ¶

func (e ParseTypeError) Error() string

type StringParameter ¶

type StringParameter struct {
	CommonParameter `yaml:",inline"`
	Default         *string `yaml:"default"`
	Escape          *string `yaml:"escape"`
}

StringParameter is a parameter representing the "string" type.

func NewStringParameter ¶

func NewStringParameter(name string, desc string) *StringParameter

NewStringParameter is a convenience function for initializing a StringParameter.

func NewStringParameterWithAllowedValues ¶ added in v0.18.0

func NewStringParameterWithAllowedValues(name string, desc string, allowedValues []any) *StringParameter

NewStringParameterWithAllowedValues is a convenience function for initializing a StringParameter with a list of allowedValues

func NewStringParameterWithAuth ¶ added in v0.0.4

func NewStringParameterWithAuth(name string, desc string, authServices []ParamAuthService) *StringParameter

NewStringParameterWithAuth is a convenience function for initializing a StringParameter with a list of ParamAuthService.

func NewStringParameterWithDefault ¶ added in v0.8.0

func NewStringParameterWithDefault(name string, defaultV, desc string) *StringParameter

NewStringParameterWithDefault is a convenience function for initializing a StringParameter with default value.

func NewStringParameterWithEscape ¶ added in v0.18.0

func NewStringParameterWithEscape(name, desc, escape string) *StringParameter

NewStringParameterWithEscape is a convenience function for initializing a StringParameter.

func NewStringParameterWithExcludedValues ¶ added in v0.19.0

func NewStringParameterWithExcludedValues(name string, desc string, excludedValues []any) *StringParameter

NewStringParameterWithExcludedValues is a convenience function for initializing a StringParameter with a list of excludedValues

func NewStringParameterWithRequired ¶ added in v0.10.0

func NewStringParameterWithRequired(name string, desc string, required bool) *StringParameter

NewStringParameterWithRequired is a convenience function for initializing a StringParameter.

func (*StringParameter) GetAuthServices ¶ added in v0.2.0

func (p *StringParameter) GetAuthServices() []ParamAuthService

func (*StringParameter) GetDefault ¶ added in v0.8.0

func (p *StringParameter) GetDefault() any

func (*StringParameter) Manifest ¶ added in v0.8.0

func (p *StringParameter) Manifest() ParameterManifest

Manifest returns the manifest for the StringParameter.

func (*StringParameter) Parse ¶

func (p *StringParameter) Parse(v any) (any, error)

Parse casts the value "v" as a "string".

type Tool ¶

type Tool interface {
	Invoke(context.Context, ParamValues, AccessToken) (any, error)
	ParseParams(map[string]any, map[string]map[string]any) (ParamValues, error)
	Manifest() Manifest
	McpManifest() McpManifest
	Authorized([]string) bool
	RequiresClientAuthorization() bool
}

type ToolConfig ¶ added in v0.0.2

type ToolConfig interface {
	ToolConfigKind() string
	Initialize(map[string]sources.Source) (Tool, error)
}

func DecodeConfig ¶ added in v0.7.0

func DecodeConfig(ctx context.Context, kind string, name string, decoder *yaml.Decoder) (ToolConfig, error)

DecodeConfig looks up the registered factory for the given kind and uses it to decode the tool configuration.

type ToolConfigFactory ¶ added in v0.7.0

type ToolConfigFactory func(ctx context.Context, name string, decoder *yaml.Decoder) (ToolConfig, error)

ToolConfigFactory defines the signature for a function that creates and decodes a specific tool's configuration. It takes the context, the tool's name, and a YAML decoder to parse the config.

type Toolset ¶

type Toolset struct {
	Name        string          `yaml:"name"`
	Tools       []*Tool         `yaml:",inline"`
	Manifest    ToolsetManifest `yaml:",inline"`
	McpManifest []McpManifest   `yaml:",inline"`
}

type ToolsetConfig ¶

type ToolsetConfig struct {
	Name      string   `yaml:"name"`
	ToolNames []string `yaml:",inline"`
}

func (ToolsetConfig) Initialize ¶

func (t ToolsetConfig) Initialize(serverVersion string, toolsMap map[string]Tool) (Toolset, error)

type ToolsetManifest ¶

type ToolsetManifest struct {
	ServerVersion string              `json:"serverVersion"`
	ToolsManifest map[string]Manifest `json:"tools"`
}

Directories ¶

Path Synopsis
alloydb
bigquery
cassandra
clickhouse
cloudhealthcare
cloudsql
cloudsqlmssql
cloudsqlmysql
cloudsqlpg
dataform
dataplex
elasticsearch
firebird
firestore
looker
mindsdb
mongodb
mssql
mysql
neo4j
neo4jexecutecypher/classifier
Package classifier provides tools to classify Cypher queries as either read-only or write operations.
Package classifier provides tools to classify Cypher queries as either read-only or write operations.
neo4jschema/cache
Package cache provides a simple, thread-safe, in-memory key-value store.
Package cache provides a simple, thread-safe, in-memory key-value store.
neo4jschema/helpers
Package helpers provides utility functions for transforming and processing Neo4j schema data.
Package helpers provides utility functions for transforming and processing Neo4j schema data.
neo4jschema/types
Package types contains the shared data structures for Neo4j schema representation.
Package types contains the shared data structures for Neo4j schema representation.
oceanbase
oracle
postgres
serverlessspark
singlestore
spanner
sqlite
tidb
trino
utility

Jump to

Keyboard shortcuts

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