singlestoresql

package
v0.20.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name               string                `yaml:"name" validate:"required"`
	Kind               string                `yaml:"kind" validate:"required"`
	Source             string                `yaml:"source" validate:"required"`
	Description        string                `yaml:"description" validate:"required"`
	Statement          string                `yaml:"statement" validate:"required"`
	AuthRequired       []string              `yaml:"authRequired"`
	Parameters         parameters.Parameters `yaml:"parameters"`
	TemplateParameters parameters.Parameters `yaml:"templateParameters"`
}

Config defines the configuration for a SingleStore SQL tool.

func (Config) Initialize

func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error)

Initialize sets up and returns a new Tool instance based on the provided configuration and available sources. It verifies that the specified source exists and is compatible, processes tool parameters, and constructs the necessary manifests for tool operation. Returns an initialized Tool or an error if setup fails.

Parameters:

srcs - a map of available sources, keyed by source name.

Returns:

tools.Tool - the initialized tool instance.
error      - an error if the source is missing, incompatible, or setup fails.

func (Config) ToolConfigKind

func (cfg Config) ToolConfigKind() string

ToolConfigKind returns the kind of the tool configuration.

type Tool

type Tool struct {
	Config
	AllParams parameters.Parameters `yaml:"allParams"`
	Pool      *sql.DB
	// contains filtered or unexported fields
}

Tool represents a SingleStore SQL tool instance with its configuration, parameters, and database connection.

func (Tool) Authorized

func (t Tool) Authorized(verifiedAuthServices []string) bool

func (Tool) Invoke

func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error)

Invoke executes the SQL statement defined in the Tool using the provided context and parameter values. It resolves template parameters and standard parameters, executes the query, and processes the result rows. Each row is returned as a map with column names as keys and their corresponding values, handling special cases for JSON and string types. Returns a slice of maps representing the result set, or an error if any step fails.

Parameters:

ctx    - The context for controlling cancellation and timeouts.
params - The parameter values to be used for the SQL statement.

Returns:

  • A slice of maps, where each map represents a row with column names as keys.
  • An error if template resolution, parameter extraction, query execution, or result processing fails.

func (Tool) Manifest

func (t Tool) Manifest() tools.Manifest

func (Tool) McpManifest

func (t Tool) McpManifest() tools.McpManifest

func (Tool) ParseParams

func (t Tool) ParseParams(data map[string]any, claims map[string]map[string]any) (parameters.ParamValues, error)

func (Tool) RequiresClientAuthorization

func (t Tool) RequiresClientAuthorization() bool

func (Tool) ToConfig added in v0.20.0

func (t Tool) ToConfig() tools.ToolConfig

Jump to

Keyboard shortcuts

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