trino

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package trino provides a Trino toolkit adapter for the MCP data platform.

Package trino provides a Trino toolkit adapter for the MCP data platform.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnotationConfig added in v0.20.0

type AnnotationConfig struct {
	ReadOnlyHint    *bool `yaml:"read_only_hint"`
	DestructiveHint *bool `yaml:"destructive_hint"`
	IdempotentHint  *bool `yaml:"idempotent_hint"`
	OpenWorldHint   *bool `yaml:"open_world_hint"`
}

AnnotationConfig holds tool annotation overrides from configuration.

type Config

type Config struct {
	Host           string                      `yaml:"host"`
	Port           int                         `yaml:"port"`
	User           string                      `yaml:"user"`
	Password       string                      `yaml:"password"` // #nosec G117 -- Trino credential from admin YAML config
	Catalog        string                      `yaml:"catalog"`
	Schema         string                      `yaml:"schema"`
	SSL            bool                        `yaml:"ssl"`
	SSLVerify      bool                        `yaml:"ssl_verify"`
	Timeout        time.Duration               `yaml:"timeout"`
	DefaultLimit   int                         `yaml:"default_limit"`
	MaxLimit       int                         `yaml:"max_limit"`
	ReadOnly       bool                        `yaml:"read_only"`
	ConnectionName string                      `yaml:"connection_name"`
	Descriptions   map[string]string           `yaml:"descriptions"`
	Annotations    map[string]AnnotationConfig `yaml:"annotations"`

	// ProgressEnabled enables progress notifications for query execution.
	// Injected by the platform from progress.enabled config.
	ProgressEnabled bool `yaml:"progress_enabled"`

	// Elicitation configures user confirmation for expensive operations.
	// Injected by the platform from elicitation config.
	Elicitation ElicitationConfig `yaml:"elicitation"`
}

Config holds Trino toolkit configuration.

func ParseConfig

func ParseConfig(cfg map[string]any) (Config, error)

ParseConfig parses a Trino toolkit configuration from a map.

type CostEstimationConfig added in v0.21.0

type CostEstimationConfig struct {
	Enabled      bool  `yaml:"enabled"`
	RowThreshold int64 `yaml:"row_threshold"`
}

CostEstimationConfig configures query cost estimation.

type ElicitationConfig added in v0.21.0

type ElicitationConfig struct {
	// Enabled is the master switch for all elicitation features.
	Enabled bool `yaml:"enabled"`

	// CostEstimation configures query cost estimation and confirmation.
	CostEstimation CostEstimationConfig `yaml:"cost_estimation"`

	// PIIConsent configures PII access consent.
	PIIConsent PIIConsentConfig `yaml:"pii_consent"`
}

ElicitationConfig configures elicitation triggers for the Trino toolkit.

type ElicitationDeclinedError added in v0.21.0

type ElicitationDeclinedError struct {
	Reason string
}

ElicitationDeclinedError indicates the user declined an elicitation request. This error is returned when the user explicitly declines or cancels a confirmation prompt (cost estimation, PII consent, etc.).

func (*ElicitationDeclinedError) Error added in v0.21.0

func (e *ElicitationDeclinedError) Error() string

func (*ElicitationDeclinedError) ErrorCategory added in v0.21.0

func (*ElicitationDeclinedError) ErrorCategory() string

ErrorCategory implements middleware.CategorizedError.

type ElicitationMiddleware added in v0.21.0

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

ElicitationMiddleware intercepts Trino query execution to request user confirmation when queries exceed cost thresholds or access PII data. It implements trinotools.ToolMiddleware.

func (*ElicitationMiddleware) After added in v0.21.0

After is a no-op — elicitation happens before query execution.

func (*ElicitationMiddleware) Before added in v0.21.0

Before checks cost and PII triggers before query execution. Returns an error to abort the query if the user declines.

func (*ElicitationMiddleware) SetSemanticProvider added in v0.21.0

func (em *ElicitationMiddleware) SetSemanticProvider(p semantic.Provider)

SetSemanticProvider updates the semantic provider (called after toolkit init).

type PIIConsentConfig added in v0.21.0

type PIIConsentConfig struct {
	Enabled bool `yaml:"enabled"`
}

PIIConsentConfig configures PII access consent.

type ProgressInjector added in v0.20.0

type ProgressInjector struct{}

ProgressInjector is a trinotools.ToolMiddleware that creates an mcpProgressNotifier per-request from the ServerSession and progress token stored in context by MCPToolCallMiddleware.

func (*ProgressInjector) After added in v0.20.0

After is a no-op — progress notifications are sent during tool execution, not after.

func (*ProgressInjector) Before added in v0.20.0

Before reads the server session and progress token from context and, if both are present, creates an mcpProgressNotifier and stores it in context via trinotools.WithProgressNotifier.

type ReadOnlyInterceptor added in v0.2.0

type ReadOnlyInterceptor struct{}

ReadOnlyInterceptor blocks write operations when read_only mode is enabled. It delegates write detection to the upstream mcp-trino IsWriteSQL function.

func NewReadOnlyInterceptor added in v0.2.0

func NewReadOnlyInterceptor() *ReadOnlyInterceptor

NewReadOnlyInterceptor creates a new read-only query interceptor.

func (*ReadOnlyInterceptor) Intercept added in v0.2.0

Intercept checks if the query is a write operation and blocks it in read-only mode.

type Toolkit

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

Toolkit wraps mcp-trino toolkit for the platform.

func New

func New(name string, cfg Config) (*Toolkit, error)

New creates a new Trino toolkit.

func (*Toolkit) Client

func (t *Toolkit) Client() *trinoclient.Client

Client returns the underlying Trino client for direct use.

func (*Toolkit) Close

func (t *Toolkit) Close() error

Close releases resources.

func (*Toolkit) Config

func (t *Toolkit) Config() Config

Config returns the toolkit configuration.

func (*Toolkit) Connection added in v0.12.1

func (t *Toolkit) Connection() string

Connection returns the connection name for audit logging.

func (*Toolkit) Kind

func (*Toolkit) Kind() string

Kind returns the toolkit kind.

func (*Toolkit) Name

func (t *Toolkit) Name() string

Name returns the toolkit instance name.

func (*Toolkit) RegisterTools

func (t *Toolkit) RegisterTools(s *mcp.Server)

RegisterTools registers Trino tools with the MCP server. The platform provides a unified list_connections tool, so the per-toolkit trino_list_connections is excluded.

func (*Toolkit) SetQueryProvider

func (t *Toolkit) SetQueryProvider(provider query.Provider)

SetQueryProvider sets the query execution provider for enrichment.

func (*Toolkit) SetSemanticProvider

func (t *Toolkit) SetSemanticProvider(provider semantic.Provider)

SetSemanticProvider sets the semantic metadata provider for enrichment.

func (*Toolkit) Tools

func (*Toolkit) Tools() []string

Tools returns the list of tool names that would be provided by this toolkit.

Jump to

Keyboard shortcuts

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