Documentation
¶
Overview ¶
Package embed runs MCP Toolbox for Databases inside Blitz's own process (spec_databases_046): a pruned copy of Toolbox (third_party/mcp-toolbox) with only the databases Blitz offers (Postgres, AlloyDB, SQLite with sqlite-vec, BigQuery), its config parser (config.go, taken from Toolbox's cmd/internal), and Start, which serves one config's tools as MCP over an in-memory pipe for Blitz's MCP client.
Toolbox's command line isn't used: its signal handling, its version check (a call home) and its global OpenTelemetry setup would act on Blitz's process; here none of them runs.
Index ¶
- Constants
- Variables
- func ConvertConfig(ctx context.Context, raw []byte) ([]byte, error)
- func GetPathsFromConfigFolder(ctx context.Context, folderPath string) ([]string, error)
- func ReadOnlySources(cfg Config) []string
- func ReadOnlyTools(cfg Config) []string
- func ReadsOnly(statement string) bool
- type Config
- type ConfigParser
- type Session
Constants ¶
const Version = "1.14.0"
Version is the Toolbox release this copy was taken from.
Variables ¶
var SourceTypes = []string{"postgres", "alloydb-postgres", "sqlite", "bigquery"}
SourceTypes are the database sources this copy offers.
Functions ¶
func ConvertConfig ¶
ConvertConfig converts configuration file to flat format and rewrites toolsets to the group kind.
func GetPathsFromConfigFolder ¶
GetPathsFromConfigFolder loads all YAML files from a directory and merges them
func ReadOnlySources ¶
ReadOnlySources are cfg's sources that can't write, by name: SQLite, Postgres and AlloyDB with readOnly (the database refuses a write), and BigQuery with writeMode blocked (or readOnly).
func ReadOnlyTools ¶
ReadOnlyTools are cfg's tools on a read-only source (ReadOnlySources), by name: whatever they say they do, they can't change the database.
Types ¶
type Config ¶
type Config struct {
Sources server.SourceConfigs `yaml:"sources"`
AuthServices server.AuthServiceConfigs `yaml:"authServices"`
EmbeddingModels server.EmbeddingModelConfigs `yaml:"embeddingModels"`
Tools server.ToolConfigs `yaml:"tools"`
Prompts server.PromptConfigs `yaml:"prompts"`
Resources server.ResourceConfigs `yaml:"resources"`
ResourceTemplates server.ResourceTemplateConfigs `yaml:"resourceTemplates"`
Groups server.GroupConfigs `yaml:"groups"`
}
Config is a parsed Toolbox configuration: its sources, tools, groups and the rest, merged from every file (Blitz: doc comments added).
func Load ¶
Load reads and merges files (Toolbox's YAML: sources, tools, groups), filling each ${NAME} (or ${NAME:default}) from env alone, never from the process's environment: Blitz puts secrets there. A ${NAME} with no value and no default is an error, naming it.
func LoadWith ¶
func LoadWith(ctx context.Context, files []string, env map[string]string, rewrite func(file string, raw []byte) ([]byte, error)) (Config, error)
LoadWith is Load with each file's text given to rewrite first, before its ${NAME}s are filled (nil: as it is). Blitz resolves a connection's relative paths there, against the folder it belongs to, not the service's working directory.
type ConfigParser ¶
type ConfigParser struct {
EnvVars map[string]string
OptionalEnvVars []string
// AllowMissingEnvVars, when true, substitutes the variable name for an unset
// required ${VAR} placeholder instead of erroring. Used by offline flows like
// skills-generate, where source env vars are needed only to satisfy config
// parsing/validation, never to connect. A non-empty placeholder is used (not
// "") so required string fields still pass validation. The served path leaves
// this false so missing config still fails fast.
AllowMissingEnvVars bool
// contains filtered or unexported fields
}
ConfigParser parses configuration files, filling ${NAME} placeholders from EnvVars.
func (*ConfigParser) LoadAndMergeConfigs ¶
LoadAndMergeConfigs loads multiple YAML files and merges them
func (*ConfigParser) ParseConfig ¶
ParseConfig parses one configuration file's content.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a running Toolbox server's MCP connection: what the client writes goes to the server, and what the server answers is read. Close stops the server and closes its database connections.
func Start ¶
Start initializes cfg's sources (connecting to each: a database that can't be reached is the error) and tools, and serves them as MCP over the returned Session, until Close or ctx is done. Toolbox's log goes to logOut (nil: discarded).
func (*Session) Close ¶
Close stops the server: its MCP session ends and its sources' connections close.