databases

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 21 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package databases is the connectors' toolbox backend (spec_046_databases, spec_047_connectors): MCP Toolbox for Databases, run inside Blitz's process (third_party/mcp-toolbox/embed), serving a category's connection files (Toolbox YAML: sources, tools, toolsets) as one MCP server, its tools named <prefix>__<tool> (db__shop_list_tables).

A ${NAME} in a file is the Blitz secret NAME, the workspace's own, else the global one; never an environment variable. A workspace's own files reach the global secrets, and their read-only tools run unasked, only once the person trusts them (saved in Studio, or the project's settings trusted).

Index

Constants

View Source
const ID = "toolbox"

ID is the backend's ID, which kinds name, and its in-process server's.

Variables

View Source
var MaxSchemaTables = 60

MaxSchemaTables bounds the tables a schema read describes one by one (BigQuery reads each table's metadata).

Functions

func Names

func Names(files []string) []string

Names are the ${NAME}s the files use, sorted.

func ReadsOnly

func ReadsOnly(statement string) bool

ReadsOnly says whether a SQL statement only reads, as Toolbox's tools are marked (a hint: a read-only connection is the guard).

func Transport

func Transport(c config.MCPServerConfig) mcp.Transport

Transport connects to a toolbox server c: each connection loads its files (Args) with their secrets (Env), their file settings (FileSettings, which Serve works out from the workspace's catalog) resolved where each file belongs (baseOf: its workspace, else the home folder), and starts Toolbox, connecting to the databases; closing the connection stops it.

func Vars

func Vars(files []string, scope string, lookup func(scope, key string) (string, bool)) map[string]string

Vars are the values of the files' ${NAME}s that lookup finds (a secrets lookup, as secrets.Vault.Resolve gives) in scope (secrets.AnyScope, or secrets.OnlyWorkspace). The values are remembered for every redactor to mask.

Types

type Backend

type Backend struct{}

Backend is the toolbox backend.

func (Backend) Capabilities

func (Backend) Capabilities() []connectors.Capability

Capabilities are all of them: Toolbox connects, runs tools and queries, and the kinds say how their schema is read.

func (Backend) Check

Check lists what Toolbox would refuse: a custom file that isn't YAML; a BigQuery project that isn't a project ID, or an allowed dataset that isn't dataset or project.dataset (BigQuery's refusal came only when a query ran: "Invalid project ID 'retail-cortex.'").

func (Backend) ID

func (Backend) ID() string

ID is toolbox.

func (Backend) Parse

func (Backend) Parse(cat connectors.Category, kinds []connectors.Kind, name, text string) connectors.Connection

Parse reads a connection file's text into the form: its kind is the one its comment names, else the first of kinds with its source's type. An older file is read as it's brought up to date (upgraded).

func (Backend) Query added in v0.9.4

Query runs run's statement on c as written, on its own connection (spec_059_data DAT-10): read-only when c is, or when run is, and its result read with the driver's column metadata.

func (Backend) ReadSchema

ReadSchema reads c's tables: by its kind's statement (a query whose rows are table, about, and columns as "name type, …"), or its reader.

func (Backend) Render

Render writes c as Toolbox YAML: its source, then its ready-made tools and queries. A secret field always names its secret.

func (Backend) Serve

Serve is the category's toolbox server, when it has files: in-process, its files in Args and their secrets in Env, offered to every agent; its tools on read-only sources run without asking. A workspace file the person hasn't trusted gets only the workspace's own secrets (its ${NAME}s are kept apart in Env: WorkspaceOnly), and its tools all ask first. A workspace file that doesn't load on its own is left out, and Warn says why, so it can't stop the others being served.

func (Backend) SourceTypes added in v0.9.1

func (Backend) SourceTypes(text string) ([]string, error)

SourceTypes are the Toolbox source types of every source in a connection file (connectors.SourceLister): an error for a file that isn't YAML, a document with no kind, or a source with no type.

func (Backend) Test

Test connects to c as written and lists the tools it offers: the error says why it can't be reached.

func (Backend) Try

Try runs one of c's tools (<connection>_<tool>, or the tool alone) with args and returns what it answered, and whether that's an error.

Jump to

Keyboard shortcuts

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