Help us shape the future of Go! Take the 2026 Go Developer Survey

core

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package core defines the core interfaces and types for CoreMCP database adapters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnInfo added in v0.2.0

type ColumnInfo struct {
	Name        string
	DataType    string
	IsNullable  bool
	Description string // Comment/Description from database
}

ColumnInfo represents detailed information about a table column.

type ForeignKey added in v0.2.0

type ForeignKey struct {
	ColumnName       string
	ReferencedTable  string
	ReferencedColumn string
	ConstraintName   string
}

ForeignKey represents a foreign key relationship.

type ProcParameter added in v0.4.0

type ProcParameter struct {
	Name     string // e.g. "@StartDate"
	DataType string // e.g. "datetime"
	Mode     string // "IN", "OUT", "INOUT"
}

ProcParameter represents a parameter of a stored procedure.

type QueryResult

type QueryResult struct {
	Columns []string
	Rows    []map[string]any // (column_name: value)
}

QueryResult contains the results of a database query execution.

type Source

type Source interface {
	// Name returns the human-readable name of the database adapter.
	Name() string
	// Connect establishes a connection to the database.
	Connect(ctx context.Context) error
	// Close closes the database connection.
	Close(ctx context.Context) error
	// GetSchema retrieves the database table schema information.
	GetSchema(ctx context.Context) ([]TableSchema, error)
	// GetViews retrieves all views in the database.
	GetViews(ctx context.Context) ([]ViewSchema, error)
	// GetProcedures retrieves all stored procedures in the database.
	GetProcedures(ctx context.Context) ([]StoredProcedure, error)
	// ExecuteQuery runs a SQL query and returns the results.
	ExecuteQuery(ctx context.Context, query string, args ...any) (*QueryResult, error)
	// ExecuteProcedure executes a stored procedure by name with the given named parameters.
	// The procedure name is validated before execution.
	// Implementations may reject execution when the source is read-only.
	ExecuteProcedure(ctx context.Context, name string, params map[string]string) (*QueryResult, error)
}

Source represents a database connection and query interface. All database adapters must implement this interface.

type StoredProcedure added in v0.4.0

type StoredProcedure struct {
	Name        string
	Parameters  []ProcParameter
	Description string
}

StoredProcedure represents a stored procedure in the database.

type TableSchema

type TableSchema struct {
	Name        string
	Columns     []ColumnInfo
	ForeignKeys []ForeignKey
	PrimaryKeys []string
}

TableSchema represents the structure of a database table.

type ViewSchema added in v0.4.0

type ViewSchema struct {
	Name    string
	Columns []ColumnInfo
}

ViewSchema represents a database view.

Jump to

Keyboard shortcuts

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