mcp

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mcp provides SQLite-backed storage for MCP server configurations.

Index

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

func NewStore(workspacePath string) (*Store, error)

NewStore creates a new MCP store for the given workspace path. Uses the shared workspace database; returns an error if unavailable.

func OpenStore

func OpenStore(workspacePath string) (*Store, error)

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

func (s *Store) Close() error

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) Remove

func (s *Store) Remove(name string) error

Remove deletes an MCP server config by name.

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.

func (*Store) SetEnabled

func (s *Store) 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 Transport

type Transport string

Transport represents an MCP server transport type.

const (
	TransportStdio Transport = "stdio"
	TransportSSE   Transport = "sse"
)

Jump to

Keyboard shortcuts

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