Documentation
¶
Index ¶
- Constants
- type AuditConfig
- type Backend
- type BackendConfig
- type BackendError
- type ColumnInfo
- type Config
- func (c *Config) GetBackendConnectionString() string
- func (c *Config) GetMode() string
- func (c *Config) GetRender() string
- func (c *Config) GetServerAddress() string
- func (c *Config) GetServerTransport() string
- func (c *Config) IsAuditEnabled() bool
- func (c *Config) IsPromptEnabled(name string) bool
- func (c *Config) IsTcpBackend() bool
- func (c *Config) IsToolEnabled(name string) bool
- func (c *Config) Validate() error
- type Duration
- type ExampleBackend
- func (b *ExampleBackend) Close() error
- func (b *ExampleBackend) DescribeMethod(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
- func (b *ExampleBackend) DescribeResource(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
- func (b *ExampleBackend) ExecQuery(ctx context.Context, query string) (map[string]any, error)
- func (b *ExampleBackend) ListMethods(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
- func (b *ExampleBackend) ListProviders(ctx context.Context) ([]map[string]any, error)
- func (b *ExampleBackend) ListRegistry(ctx context.Context, input dto.RegistryInput) ([]map[string]any, error)
- func (b *ExampleBackend) ListResources(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
- func (b *ExampleBackend) ListServices(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
- func (b *ExampleBackend) Ping(ctx context.Context) error
- func (b *ExampleBackend) PullProvider(ctx context.Context, input dto.RegistryInput) (map[string]any, error)
- func (b *ExampleBackend) RunQueryJSON(ctx context.Context, input dto.QueryJSONInput) ([]map[string]interface{}, error)
- func (b *ExampleBackend) ServerInfo(ctx context.Context, _ any) (dto.ServerInfoOutput, error)
- func (b *ExampleBackend) ValidateQuery(ctx context.Context, query string) ([]map[string]any, error)
- type Field
- type MCPClient
- type MCPServer
- type Provider
- type QueryResult
- type Resource
- type SchemaProvider
- type ServerConfig
- type Service
Constants ¶
const ( MCPClientTypeHTTP = "http" MCPClientTypeSTDIO = "stdio" )
const (
DefaultHTTPServerAddress = "127.0.0.1:9876"
)
const ( // ExplainerPromptWriteSafeSelectTool is the static body of the write_safe_select prompt. ExplainerPromptWriteSafeSelectTool = `` /* 257-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditConfig ¶ added in v0.10.474
type AuditConfig struct {
// Disabled turns the audit subsystem off entirely. Default false
// (audit is on by default).
Disabled bool `json:"disabled,omitempty" yaml:"disabled,omitempty"`
// FailureMode controls what happens when the sink returns an error.
// Legal values: "strict" (default), "strict_mutations", "best_effort".
FailureMode string `json:"failure_mode,omitempty" yaml:"failure_mode,omitempty"`
// Sink selects the destination kind. Currently only "file" is
// implemented; other values are reserved. Empty defaults to "file".
Sink string `json:"sink,omitempty" yaml:"sink,omitempty"`
// File holds file-sink-specific options. Only consulted when Sink is
// "file" (the default).
File sink.FileConfig `json:"file,omitempty" yaml:"file,omitempty"`
}
AuditConfig configures the audit subsystem.
func (AuditConfig) GetFailureMode ¶ added in v0.10.474
func (a AuditConfig) GetFailureMode() string
GetFailureMode returns the effective failure-mode string with the default substituted for empty input.
type Backend ¶
type Backend interface {
// Ping verifies the backend connection is active.
Ping(ctx context.Context) error
// Close gracefully shuts down the backend connection.
Close() error
// ServerInfo returns server identity and runtime metadata.
ServerInfo(ctx context.Context, args any) (dto.ServerInfoOutput, error)
// ExecQuery executes a non-row-returning SQL statement (mutations, EXEC).
ExecQuery(ctx context.Context, query string) (map[string]any, error)
// ValidateQuery parses and plans a SELECT without executing it.
ValidateQuery(ctx context.Context, query string) ([]map[string]any, error)
// RunQueryJSON executes a SELECT and returns the rows.
RunQueryJSON(ctx context.Context, input dto.QueryJSONInput) ([]map[string]interface{}, error)
// ListProviders lists available providers.
ListProviders(ctx context.Context) ([]map[string]any, error)
// ListServices lists services under a provider.
ListServices(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
// ListResources lists resources under a provider/service.
ListResources(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
// ListMethods lists access methods for a resource.
ListMethods(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
// DescribeResource returns the output fields for a resource's primary read method.
DescribeResource(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
// DescribeMethod returns the full I/O contract for one method.
DescribeMethod(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
// ListRegistry lists providers (and their versions) available in the registry.
// When input.Provider is empty, lists all available providers; otherwise lists
// versions for that provider. Distinct from ListProviders, which lists only
// providers already pulled into the local cache.
ListRegistry(ctx context.Context, input dto.RegistryInput) ([]map[string]any, error)
// PullProvider installs a provider from the registry into the local approot
// cache. input.Provider is required; input.Version is optional (empty pulls
// the latest published version). Returns the same shape as ExecQuery.
PullProvider(ctx context.Context, input dto.RegistryInput) (map[string]any, error)
}
func NewExampleBackend ¶
NewExampleBackend creates a new example backend instance.
type BackendConfig ¶
type BackendConfig struct {
// Type specifies the backend type ("tcp", "memory").
Type string `json:"type" yaml:"type"`
// AppName is an optional application name describing the backend.
// In the first instance, this is stackql.
// **Possible** future use case for the backing db (e.g., "postgres", "mysql", etc).
AppName string `json:"app_name" yaml:"app_name"`
// ConnectionString contains the connection details for the backend.
// Format depends on the backend type.
ConnectionString string `json:"dsn" yaml:"dsn"`
// MaxConnections limits the number of backend connections.
MaxConnections int `json:"max_connections" yaml:"max_connections"`
// ConnectionTimeout specifies the timeout for backend connections.
ConnectionTimeout Duration `json:"connection_timeout" yaml:"connection_timeout"`
// QueryTimeout specifies the timeout for individual queries.
QueryTimeout Duration `json:"query_timeout" yaml:"query_timeout"`
}
BackendConfig contains configuration for the backend connection.
type BackendError ¶
type BackendError struct {
// Code is a machine-readable error code.
Code string `json:"code"`
// Message is a human-readable error message.
Message string `json:"message"`
// Details contains additional context about the error.
Details map[string]interface{} `json:"details,omitempty"`
}
BackendError represents an error that occurred in the backend.
func (*BackendError) Error ¶
func (e *BackendError) Error() string
type ColumnInfo ¶
type ColumnInfo interface {
// GetName returns the column name as returned by the query.
GetName() string
// GetType returns the data type of the column (e.g., "string", "int64", "float64").
GetType() string
// IsNullable indicates whether the column can contain null values.
IsNullable() bool
}
ColumnInfo provides metadata about a result column.
func NewColumnInfo ¶
func NewColumnInfo(name, colType string, nullable bool) ColumnInfo
NewColumnInfo creates a new ColumnInfo instance.
type Config ¶
type Config struct {
// Server contains server-specific configuration.
Server ServerConfig `json:"server" yaml:"server"`
// Backend contains backend-specific configuration.
Backend BackendConfig `json:"backend" yaml:"backend"`
// EnabledTools restricts which MCP tools the server publishes.
// When nil or empty, every built-in tool is published (default behavior).
// When populated, only the named tools are registered.
EnabledTools []string `json:"enabled_tools,omitempty" yaml:"enabled_tools,omitempty"`
// EnabledPrompts restricts which MCP prompts the server publishes.
// Same semantics as EnabledTools: nil or empty means all registered prompts are published.
EnabledPrompts []string `json:"enabled_prompts,omitempty" yaml:"enabled_prompts,omitempty"`
}
Config represents the complete configuration for the MCP server.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a configuration with sensible defaults.
func DefaultHTTPConfig ¶
func DefaultHTTPConfig() *Config
func DefaultSSEConfig ¶
func DefaultSSEConfig() *Config
func LoadFromJSON ¶
LoadFromJSON loads configuration from JSON data.
func LoadFromYAML ¶
LoadFromYAML loads configuration from YAML data.
func (*Config) GetBackendConnectionString ¶
func (*Config) GetMode ¶ added in v0.10.474
GetMode returns the server's effective mode. Empty string is mapped to the safe default.
func (*Config) GetRender ¶ added in v0.10.542
GetRender returns the server-level default render format for tool result text content. Empty string is mapped to the markdown default.
func (*Config) GetServerAddress ¶
func (*Config) GetServerTransport ¶
func (*Config) IsAuditEnabled ¶ added in v0.10.474
IsAuditEnabled reports whether audit logging should run. Audit is on by default unless explicitly disabled.
func (*Config) IsPromptEnabled ¶ added in v0.10.474
IsPromptEnabled reports whether the named prompt should be published. Empty/nil EnabledPrompts means all prompts are enabled.
func (*Config) IsTcpBackend ¶
func (*Config) IsToolEnabled ¶ added in v0.10.474
IsToolEnabled reports whether the named tool should be published. Empty/nil EnabledTools means all tools are enabled.
type Duration ¶
Duration is a wrapper around time.Duration that can be marshaled to/from JSON and YAML.
func (Duration) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Duration) MarshalYAML ¶
MarshalYAML implements yaml.Marshaler.
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Duration) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler.
type ExampleBackend ¶
type ExampleBackend struct {
// contains filtered or unexported fields
}
ExampleBackend is a simple implementation of the Backend interface for demonstration purposes. This shows how to implement the Backend interface without depending on StackQL internals.
func (*ExampleBackend) Close ¶
func (b *ExampleBackend) Close() error
Close implements the Backend interface.
func (*ExampleBackend) DescribeMethod ¶ added in v0.10.474
func (b *ExampleBackend) DescribeMethod(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
func (*ExampleBackend) DescribeResource ¶ added in v0.10.474
func (b *ExampleBackend) DescribeResource(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
func (*ExampleBackend) ListMethods ¶
func (b *ExampleBackend) ListMethods(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
func (*ExampleBackend) ListProviders ¶
func (*ExampleBackend) ListRegistry ¶ added in v0.10.500
func (b *ExampleBackend) ListRegistry(ctx context.Context, input dto.RegistryInput) ([]map[string]any, error)
func (*ExampleBackend) ListResources ¶
func (b *ExampleBackend) ListResources(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
func (*ExampleBackend) ListServices ¶
func (b *ExampleBackend) ListServices(ctx context.Context, hI dto.HierarchyInput) ([]map[string]any, error)
func (*ExampleBackend) Ping ¶
func (b *ExampleBackend) Ping(ctx context.Context) error
Ping implements the Backend interface.
func (*ExampleBackend) PullProvider ¶ added in v0.10.500
func (b *ExampleBackend) PullProvider(ctx context.Context, input dto.RegistryInput) (map[string]any, error)
func (*ExampleBackend) RunQueryJSON ¶
func (b *ExampleBackend) RunQueryJSON(ctx context.Context, input dto.QueryJSONInput) ([]map[string]interface{}, error)
func (*ExampleBackend) ServerInfo ¶
func (b *ExampleBackend) ServerInfo(ctx context.Context, _ any) (dto.ServerInfoOutput, error)
func (*ExampleBackend) ValidateQuery ¶ added in v0.9.266
type Field ¶
type Field interface {
// GetName returns the field identifier.
GetName() string
// GetType returns the field data type.
GetType() string
// IsRequired indicates if this field is mandatory for certain operations.
IsRequired() bool
// GetDescription returns human-readable documentation for the field.
GetDescription() string
}
Field represents a field within a resource.
type MCPClient ¶
type MCPServer ¶
func NewExampleBackendServer ¶
func NewMCPServerWithExampleBackend ¶
NewMCPServerWithExampleBackend creates a new MCP server with an example backend. This is a convenience function for testing and demonstration purposes.
type Provider ¶
type Provider interface {
// GetName returns the provider identifier (e.g., "aws", "google").
GetName() string
// GetVersion returns the provider version.
GetVersion() string
// GetServices returns all services available in this provider.
GetServices() []Service
}
Provider represents a StackQL provider with its services and resources.
func NewProvider ¶
NewProvider creates a new Provider instance.
type QueryResult ¶
type QueryResult interface {
// GetColumns returns metadata about each column in the result set.
GetColumns() []ColumnInfo
// GetRows returns the actual data returned by the query.
GetRows() [][]interface{}
// GetRowsAffected returns the number of rows affected by DML operations.
GetRowsAffected() int64
// GetExecutionTime returns the time taken to execute the query in milliseconds.
GetExecutionTime() int64
}
QueryResult represents the result of a query execution.
func NewQueryResult ¶
func NewQueryResult(columns []ColumnInfo, rows [][]interface{}, rowsAffected, executionTime int64) QueryResult
NewQueryResult creates a new QueryResult instance.
type Resource ¶
type Resource interface {
// GetName returns the resource identifier (e.g., "instances", "buckets").
GetName() string
// GetMethods returns the available operations for this resource.
GetMethods() []string
// GetFields returns the available fields in this resource.
GetFields() []Field
}
Resource represents a queryable resource.
type SchemaProvider ¶
type SchemaProvider interface {
// GetProviders returns all available providers (e.g., aws, google, azure).
GetProviders() []Provider
}
SchemaProvider represents the metadata structure of available resources.
func NewSchemaProvider ¶
func NewSchemaProvider(providers []Provider) SchemaProvider
NewSchemaProvider creates a new SchemaProvider instance.
type ServerConfig ¶
type ServerConfig struct {
// Name is the server name advertised to clients.
Name string `json:"name" yaml:"name"`
// Transport specifies the transport configuration for the server.
Transport string `json:"transport" yaml:"transport"`
// Address is the server Address advertised to clients.
Address string `json:"address" yaml:"address"`
// Scheme is the protocol scheme used by the server.
Scheme string `json:"scheme" yaml:"scheme"`
// Version is the server version advertised to clients.
Version string `json:"version" yaml:"version"`
TLSCertFile string `json:"tls_cert_file,omitempty" yaml:"tls_cert_file,omitempty"`
TLSKeyFile string `json:"tls_key_file,omitempty" yaml:"tls_key_file,omitempty"`
TransportCfg map[string]any `json:"transport_cfg,omitempty" yaml:"transport_cfg,omitempty"`
// Description is a human-readable description of the server.
Description string `json:"description" yaml:"description"`
// MaxConcurrentRequests limits the number of concurrent client requests.
MaxConcurrentRequests int `json:"max_concurrent_requests" yaml:"max_concurrent_requests"`
// RequestTimeout specifies the timeout for individual requests.
RequestTimeout Duration `json:"request_timeout" yaml:"request_timeout"`
// Mode controls the safety contract for query / mutation / lifecycle tools.
// Legal values: "read_only", "safe", "delete_safe", "full_access".
// Empty string is treated as "safe".
//
// For back-compat with PR1, the JSON/YAML key `read_only: true` is also
// accepted and is equivalent to Mode = "read_only". When both `mode`
// and `read_only` are set, `mode` wins.
Mode string `json:"mode,omitempty" yaml:"mode,omitempty"`
// Render sets the server-level default for tool result text content.
// Legal values: "markdown" (default), "json". A per-call `format`
// argument on a tool overrides this default (issue #669).
Render string `json:"render,omitempty" yaml:"render,omitempty"`
// Audit configures the audit subsystem. Audit is enabled by default
// (Disabled is false) and writes to a file sink.
Audit AuditConfig `json:"audit,omitempty" yaml:"audit,omitempty"`
}
ServerConfig contains configuration for the MCP server itself.
func (*ServerConfig) UnmarshalJSON ¶ added in v0.10.474
func (s *ServerConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON honours the legacy `read_only: true` shim.
func (*ServerConfig) UnmarshalYAML ¶ added in v0.10.474
func (s *ServerConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML honours the legacy `read_only: true` shim.
type Service ¶
type Service interface {
// GetName returns the service identifier (e.g., "ec2", "compute").
GetName() string
// GetResources returns all resources available in this service.
GetResources() []Resource
}
Service represents a service within a provider.
func NewService ¶
NewService creates a new Service instance.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package audit holds the MCP-specific audit event shape and the string constants for decisions and failure modes recorded in that shape.
|
Package audit holds the MCP-specific audit event shape and the string constants for decisions and failure modes recorded in that shape. |
|
Package policy classifies SQL queries and decides whether the server should allow, refuse, or seek approval for a tool call based on the configured server mode.
|
Package policy classifies SQL queries and decides whether the server should allow, refuse, or seek approval for a tool call based on the configured server mode. |
|
Package render produces text renderings of tool results for MCP clients.
|
Package render produces text renderings of tool results for MCP clients. |