Documentation
¶
Overview ¶
Package mcp provides SQLite-backed storage for MCP server configurations.
Index ¶
- type ConfigLookupFunc
- type PostgresStore
- func (p *PostgresStore) Add(cfg *ServerConfig) error
- func (p *PostgresStore) Close() error
- func (p *PostgresStore) Get(name string) (*ServerConfig, error)
- func (p *PostgresStore) InitSchema() error
- func (p *PostgresStore) List() ([]*ServerConfig, error)
- func (p *PostgresStore) Remove(name string) error
- func (p *PostgresStore) SetEnabled(name string, enabled bool) error
- type ServerConfig
- type Store
- func (s *Store) Add(cfg *ServerConfig) error
- func (s *Store) Close() error
- func (s *Store) Get(name string) (*ServerConfig, error)
- func (s *Store) List() ([]*ServerConfig, error)
- func (s *Store) Remove(name string) error
- func (s *Store) SetConfigLookup(fn ConfigLookupFunc)
- func (s *Store) SetEnabled(name string, enabled bool) error
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigLookupFunc ¶
type ConfigLookupFunc func(name string) *ServerConfig
ConfigLookupFunc resolves a server config by name from an external source (e.g., the unified tool store). Returns nil if not found.
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore provides Postgres-backed MCP server config storage.
func NewPostgresStore ¶
func NewPostgresStore(db *sql.DB) *PostgresStore
NewPostgresStore creates a PostgresStore from an existing *sql.DB connection.
func (*PostgresStore) Add ¶
func (p *PostgresStore) Add(cfg *ServerConfig) error
Add inserts a new MCP server configuration.
func (*PostgresStore) Close ¶
func (p *PostgresStore) Close() error
Close closes the database connection. Close is a no-op — the shared DB is owned by the caller.
func (*PostgresStore) Get ¶
func (p *PostgresStore) Get(name string) (*ServerConfig, error)
Get returns an MCP server config by name.
func (*PostgresStore) InitSchema ¶
func (p *PostgresStore) InitSchema() error
InitSchema creates the MCP tables in Postgres if they don't exist.
func (*PostgresStore) List ¶
func (p *PostgresStore) List() ([]*ServerConfig, error)
List returns all MCP server configurations.
func (*PostgresStore) Remove ¶
func (p *PostgresStore) Remove(name string) error
Remove deletes an MCP server config by name.
func (*PostgresStore) SetEnabled ¶
func (p *PostgresStore) SetEnabled(name string, enabled bool) error
SetEnabled enables or disables an MCP server config. If the server is not yet in the database but a ConfigLookupFunc is set, the full config is resolved and inserted before applying the toggle.
type ServerConfig ¶
type ServerConfig struct {
CreatedAt time.Time `json:"created_at"`
Env map[string]string `json:"env,omitempty"`
Name string `json:"name"`
Transport Transport `json:"transport"`
Command string `json:"command,omitempty"`
URL string `json:"url,omitempty"`
Args []string `json:"args,omitempty"`
Enabled bool `json:"enabled"`
}
ServerConfig represents an MCP server configuration. Env values should use ${secret:NAME} references (resolved at runtime via pkg/secret) rather than storing sensitive values directly.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides MCP server config storage backed by SQLite or Postgres.
func NewStore ¶
NewStore creates a new MCP store for the given workspace path. Uses the shared workspace database; returns an error if unavailable.
func OpenStore ¶
OpenStore opens the MCP store using the shared workspace database. Uses the shared driver type to determine the backend (timescale or sqlite).
func (*Store) Add ¶
func (s *Store) Add(cfg *ServerConfig) error
Add inserts a new MCP server configuration.
func (*Store) Close ¶
Close closes the database connection. No-op when using shared bc.db — CloseShared() handles that.
func (*Store) Get ¶
func (s *Store) Get(name string) (*ServerConfig, error)
Get returns an MCP server config by name.
func (*Store) List ¶
func (s *Store) List() ([]*ServerConfig, error)
List returns all MCP server configurations.
func (*Store) SetConfigLookup ¶
func (s *Store) SetConfigLookup(fn ConfigLookupFunc)
SetConfigLookup registers a fallback function that resolves server configs not yet present in the database (e.g., servers defined only in settings or the unified tool store). Used by SetEnabled to auto-insert config-only servers on first toggle.