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

config

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config provides configuration management for CoreMCP. It supports YAML configuration files and environment variables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Server      ServerConfig       `mapstructure:"server"`
	Logging     LoggingConfig      `mapstructure:"logging"`
	Sources     []SourceConfig     `mapstructure:"sources"`
	CustomTools []CustomToolConfig `mapstructure:"custom_tools"`
	Security    SecurityConfig     `mapstructure:"security"`
}

Config represents the complete CoreMCP configuration.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig loads the CoreMCP configuration from a YAML file. It supports environment variables with COREMCP_ prefix and provides sensible defaults. The path parameter can be a directory or a full file path.

type CustomToolConfig added in v0.2.0

type CustomToolConfig struct {
	Name        string          `mapstructure:"name"`        // Tool name (e.g., "get_daily_sales")
	Description string          `mapstructure:"description"` // Tool description for AI
	Source      string          `mapstructure:"source"`      // Which source to run against
	Query       string          `mapstructure:"query"`       // SQL query template
	Parameters  []ToolParameter `mapstructure:"parameters"`  // Optional parameters
}

CustomToolConfig defines a custom MCP tool with a predefined query.

type LoggingConfig

type LoggingConfig struct {
	Level  string `mapstructure:"level"`
	Format string `mapstructure:"format"`
}

type PIIMaskPattern added in v0.2.0

type PIIMaskPattern struct {
	Name        string `mapstructure:"name"`        // Pattern name (e.g., "credit_card")
	Pattern     string `mapstructure:"pattern"`     // Regex pattern
	Replacement string `mapstructure:"replacement"` // Replacement string (default: "***")
	Enabled     bool   `mapstructure:"enabled"`     // Whether this pattern is active
}

PIIMaskPattern defines a pattern for masking PII data.

type SecurityConfig added in v0.2.0

type SecurityConfig struct {
	MaxRowLimit      int              `mapstructure:"max_row_limit"`      // Maximum rows to return (default: 1000)
	EnablePIIMasking bool             `mapstructure:"enable_pii_masking"` // Enable PII data masking
	PIIPatterns      []PIIMaskPattern `mapstructure:"pii_patterns"`       // PII patterns to mask
	AllowedKeywords  []string         `mapstructure:"allowed_keywords"`   // SQL keywords to allow beyond SELECT/WITH
	BlockedKeywords  []string         `mapstructure:"blocked_keywords"`   // Additional SQL keywords to block
}

SecurityConfig holds security-related configuration.

type ServerConfig

type ServerConfig struct {
	Name      string `mapstructure:"name"`
	Version   string `mapstructure:"version"`
	Transport string `mapstructure:"transport"`
	Port      int    `mapstructure:"port"`
}

ServerConfig holds server-related configuration.

type SourceConfig

type SourceConfig struct {
	Name             string `mapstructure:"name"`
	Type             string `mapstructure:"type"` // mssql, firebird, postgres, rest, graphql
	DSN              string `mapstructure:"dsn"`  // Data Source Name (Connection String)
	ReadOnly         *bool  `mapstructure:"readonly"`
	NoLock           bool   `mapstructure:"no_lock"`           // MSSQL: Use READ UNCOMMITTED isolation (equivalent to WITH (NOLOCK))
	NormalizeTurkish bool   `mapstructure:"normalize_turkish"` // Normalize Turkish chars in SQL literals (for legacy Turkish_CI_AS databases)
	// REST/GraphQL specific fields
	BaseURL string            `mapstructure:"base_url"` // Base URL for REST/GraphQL APIs
	APIKey  string            `mapstructure:"api_key"`  // API key (will be encrypted at rest)
	SpecURL string            `mapstructure:"spec_url"` // OpenAPI spec URL for REST
	Headers map[string]string `mapstructure:"headers"`  // Custom headers for REST/GraphQL
	Timeout int               `mapstructure:"timeout"`  // Request timeout in seconds (default: 30)
}

func (SourceConfig) BuildDSN added in v0.4.6

func (s SourceConfig) BuildDSN() string

BuildDSN builds the connection string (DSN) for this source. For REST/GraphQL sources, it constructs the DSN from BaseURL, APIKey, and other fields. For database sources, it returns the configured DSN.

func (SourceConfig) IsReadOnly added in v0.4.5

func (s SourceConfig) IsReadOnly() bool

IsReadOnly returns true if this source is read-only (defaults to true when not explicitly set).

type ToolParameter added in v0.2.0

type ToolParameter struct {
	Name        string `mapstructure:"name"`
	Description string `mapstructure:"description"`
	Required    bool   `mapstructure:"required"`
	Default     string `mapstructure:"default"`
	// Type constrains the allowed values for this parameter.
	// Recognised values: "string" (default), "integer", "number", "date", "identifier".
	// Using a precise type is strongly recommended to prevent SQL injection when the
	// parameter is interpolated directly into the query template without quotes.
	Type string `mapstructure:"type"`
}

ToolParameter defines a parameter for a custom tool.

Jump to

Keyboard shortcuts

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