config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config provides configuration management for the Aseprite MCP server.

Configuration is loaded exclusively from a JSON file at ~/.config/pixel-mcp/config.json. No environment variables or auto-discovery mechanisms are used - all paths must be explicitly configured.

Example config file:

{
  "aseprite_path": "/absolute/path/to/aseprite",
  "temp_dir": "/tmp/pixel-mcp",
  "timeout": 30,
  "log_level": "info",
  "log_file": "",
  "enable_timing": false
}

The aseprite_path field is required and must point to a real Aseprite executable.

Index

Constants

View Source
const (
	// DefaultTimeout is the default maximum duration for Aseprite operations (30 seconds)
	DefaultTimeout = 30 * time.Second

	// DefaultLogLevel is the default logging verbosity ("info")
	DefaultLogLevel = "info"
)

Default configuration values applied when fields are not specified in the config file.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// AsepritePath is the absolute path to the Aseprite executable.
	// REQUIRED. Must point to a real, executable file.
	AsepritePath string `json:"aseprite_path"`

	// TempDir is the directory for temporary Lua script files.
	// Defaults to /tmp/pixel-mcp if not specified.
	TempDir string `json:"temp_dir"`

	// Timeout is the maximum duration for Aseprite command execution.
	// Defaults to 30 seconds if not specified.
	Timeout time.Duration `json:"timeout"`

	// LogLevel is the logging verbosity level.
	// Valid values: "debug", "info", "warn", "error"
	// Defaults to "info" if not specified.
	LogLevel string `json:"log_level"`

	// LogFile is the optional path to a log file for persistent logging.
	// If empty, logs only go to stderr.
	// Defaults to empty string if not specified.
	LogFile string `json:"log_file"`

	// EnableTiming enables request tracking and operation timing for all tools.
	// When enabled, each operation gets a unique request ID and duration is logged.
	// Defaults to false if not specified.
	EnableTiming bool `json:"enable_timing"`
}

Config holds the Aseprite MCP server configuration.

All fields must be explicitly set in the config file, except:

  • TempDir defaults to /tmp/pixel-mcp if not specified
  • Timeout defaults to 30 seconds if not specified
  • LogLevel defaults to "info" if not specified
  • LogFile defaults to empty (stderr only) if not specified
  • EnableTiming defaults to false if not specified

The AsepritePath is REQUIRED and must be an absolute path to a real executable.

func Load

func Load() (*Config, error)

Load loads configuration from the default config file at ~/.config/pixel-mcp/config.json.

The config file MUST exist and MUST contain an explicit aseprite_path field. No environment variables or auto-discovery mechanisms are used.

Returns an error if:

  • Config file doesn't exist
  • Config file is malformed JSON
  • aseprite_path is not set
  • aseprite_path doesn't point to a real executable
  • Validation fails for any other field

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid and usable.

Validation checks:

  • Aseprite executable exists at the configured path
  • Temp directory is writable
  • Timeout is positive
  • LogLevel is one of: debug, info, warn, error

Returns an error if any validation check fails. This method is automatically called by Load() before returning the config.

Jump to

Keyboard shortcuts

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