Documentation
¶
Index ¶
- Variables
- type AddOutput
- type Config
- type ConnectionInput
- type Connector
- type Connectors
- type ListInput
- type ListOutput
- type Manager
- func (c *Manager) CancelPending(ctx context.Context, uuid string) error
- func (c *Manager) CompletePending(uuid string) error
- func (c *Manager) Connection(ctx context.Context, name string) (*Connector, error)
- func (c *Manager) Get(name string) *Connector
- func (c *Manager) Pending(uuid string) (*PendingSecret, bool)
- type Namespace
- type Namespaced
- type Namespaces
- type PendingSecret
- type PendingSecrets
- type Service
- func (s *Service) AddConnection(ctx context.Context, input *ConnectionInput) (*AddOutput, error)
- func (s *Service) Connection(ctx context.Context, name string) (*Connector, error)
- func (s *Service) GeneratePendingSecret(ctx context.Context, connector *Connector) (*PendingSecret, error)
- func (s *Service) List(ctx context.Context) []*Connector
- func (s *Service) ListConnectors(ctx context.Context, input *ListInput) *ListOutput
- func (s *Service) Namespace(ctx context.Context) (string, error)
- func (s *Service) Remove(ctx context.Context, name string)
- func (s *Service) Set(ctx context.Context, connector *Connector) (*AddOutput, error)
- func (s *Service) UpsertConnection(ctx context.Context, input *ConnectionInput) error
- type UpdateOutput
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNamespaceNotFound is returned when a namespace derived from the // request context has no connectors registered. ErrNamespaceNotFound = errors.New("namespace not found") // ErrConnectorNotFound is returned when the requested connector name is // missing in the namespace map. ErrConnectorNotFound = errors.New("connector not found") )
Functions ¶
This section is empty.
Types ¶
type AddOutput ¶
type AddOutput struct {
Status string `json:"status"`
Error string `json:"error,omitempty"`
State string `json:"state,omitempty"`
CallbackURL string `json:"callbackURL,omitempty"`
Connector string `json:"connector,omitempty"`
}
AddOutput conveys the result of attempting to register a connector via the dbSetConnection tool.
type Config ¶
type Config struct {
Policy *policy.Policy
DefaultConnectors []*Namespaced
CallbackBaseURL string
BackendForFrontend *auth.BackendForFrontend `json:"backendForFrontend,omitempty" yaml:"backendForFrontend,omitempty"`
// SecretBaseLocation specifies the base URL where connection secrets should
// be stored. It can be any scheme supported by scy (e.g. mem://, file://,
// gsecret://, vault://, ...). The default is an in-memory AFS path:
// mem://localhost/mcp-sqlkit/.secret/
// The final secret location for a connector is constructed as:
// <SecretBaseLocation>/<driver>/<dbname>/<namespace>[.json]
// ensuring secrets are isolated per driver, database name and caller
// namespace. The optional .json suffix is appended for non-file schemes.
SecretBaseLocation string
}
type ConnectionInput ¶
type ConnectionInput struct {
Name string `json:"name" description:"Connector name"`
Driver string `` /* 129-byte string literal not displayed */
Host string `json:"host,omitempty" description:"Host"`
Port int `json:"port,omitempty" description:"Port"`
Project string `json:"project,omitempty" description:"Project"`
Db string `json:"db,omitempty" description:"DB/Dataset"`
Options string `json:"options,omitempty" description:"Options"`
}
ConnectionInput is the structure the user supplies when adding a new connector. It purposefully omits sensitive data like secrets.
func (*ConnectionInput) Expand ¶
func (i *ConnectionInput) Expand(dsn string) string
func (*ConnectionInput) Init ¶
func (i *ConnectionInput) Init(config *meta.Config)
type Connector ¶
type Connector struct {
Name string `json:"name" yaml:"name"`
DSN string `json:"dsn" yaml:"dsn"`
Driver string `json:"driver" yaml:"driver"`
Secrets *scy.Resource `json:"secrets,omitempty" yaml:"secrets,omitempty" internal:"true"`
// contains filtered or unexported fields
}
func (*Connector) SetSecrets ¶
type Connectors ¶
func NewConnectors ¶
func NewConnectors() *Connectors
type ListInput ¶
type ListInput struct {
Pattern string `json:"pattern"`
}
ListInput represents parameters for the List tool. Currently it is empty but defined for forward-compatibility with possible future filters.
type ListOutput ¶
type ListOutput struct {
Data []interface{} `json:"data,omitempty"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
}
ListOutput represents result returned by the List tool.
type Manager ¶
type Manager struct {
Config *Config
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) CancelPending ¶
CancelPending aborts a pending secret submission. Waiting goroutines are released but the connector is NOT activated.
func (*Manager) CompletePending ¶
CompletePending marks pending secret done and activates connector.
func (*Manager) Connection ¶
Connection retrieves the Connector by name from the caller's namespace. It does not perform any UI-specific logic – the Service wrapper is responsible for deciding whether to initiate secret elicitation. Typed errors are returned so that the caller can differentiate between the failure reasons.
type Namespace ¶
type Namespace struct {
Name string
*Connectors
}
type Namespaced ¶
type Namespaces ¶
func NewNamespaces ¶
func NewNamespaces() *Namespaces
type PendingSecret ¶
type PendingSecret struct {
UUID string
Namespace string
ConnectorMeta *meta.Config
Connector *Connector
NS *Namespace
CallbackURL string
CredType reflect.Type
MCP client.Operations
OAuth2Config *oauth2.Config
ElicitID string
// contains filtered or unexported fields
}
PendingSecret represents a connector awaiting credential submission through the secret-elicitation flow.
type PendingSecrets ¶
type PendingSecrets struct {
*syncmap.Map[string, *PendingSecret]
}
PendingSecrets is a concurrency-safe collection of pending entries.
func NewPendingSecrets ¶
func NewPendingSecrets() *PendingSecrets
func (*PendingSecrets) Close ¶
func (p *PendingSecrets) Close(uuid string)
Close signals completion to waiting goroutines.
type Service ¶
type Service struct {
*Manager
// contains filtered or unexported fields
}
func NewService ¶
func NewService(manager *Manager, mcp client.Operations) *Service
NewService builds a connector Service
func (*Service) AddConnection ¶
AddConnection orchestrates creation/upsert of a connector with a two-step elicitation flow: (1) form for non-secret parameters when missing; (2) out-of- band browser flow for secrets. It returns an AddOutput describing the state.
func (*Service) Connection ¶
func (*Service) GeneratePendingSecret ¶
func (*Service) ListConnectors ¶
func (s *Service) ListConnectors(ctx context.Context, input *ListInput) *ListOutput
ListConnectors produces ListOutput with all available connectors. It is a convenience wrapper used by the MCP toolbox tool registration.
func (*Service) Namespace ¶ added in v0.2.0
Namespace returns the caller namespace derived from auth token when enabled.
func (*Service) Set ¶
Set registers or updates a connector in the caller's namespace. If its secret already exists, the connector becomes ACTIVE immediately. Otherwise it is placed in PENDING_SECRET state and, provided the client supports the MCP Elicit protocol, a browser flow is initiated to collect the secret value. The method never returns the secret and therefore is safe over MCP RPC.
func (*Service) UpsertConnection ¶
func (s *Service) UpsertConnection(ctx context.Context, input *ConnectionInput) error
UpsertConnection registers or updates a connector based on structured input that deliberately excludes credential fields. The method validates the input against driver metadata, expands the server-side DSN template and delegates to Service.Add which handles secret elicitation.
type UpdateOutput ¶
type UpdateOutput AddOutput
UpdateOutput is an alias kept for symmetry with AddOutput.