server

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: 7 Imported by: 0

Documentation

Overview

Package server provides the MCP server implementation for Aseprite integration.

This package orchestrates the MCP (Model Context Protocol) server lifecycle, connecting MCP tool requests to Aseprite operations through the aseprite and tools packages.

Server Lifecycle:

  1. Create server with New() using validated config
  2. Tools are automatically registered during initialization
  3. Run() starts the server with stdio transport
  4. Server processes tool requests via MCP protocol
  5. Context cancellation triggers graceful shutdown

The server uses stdio transport for communication with MCP clients and supports all registered tool categories (canvas, drawing, animation, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server wraps the MCP server and provides Aseprite tool implementations.

The server initializes all required components (MCP server, Aseprite client, Lua generator) and automatically registers all available tools. It handles the complete lifecycle of MCP tool request processing.

func New

func New(cfg *config.Config, logger core.Logger) (*Server, error)

New creates a new Aseprite MCP server with the given configuration.

The configuration is validated before server creation. If validation fails, an error is returned immediately.

During initialization, New:

  • Creates an Aseprite client with configured executable path and timeout
  • Initializes a Lua script generator
  • Creates the MCP server with protocol implementation
  • Automatically registers all available tools

Returns an error if configuration validation fails.

func (*Server) Client

func (s *Server) Client() *aseprite.Client

Client returns the underlying Aseprite client for testing.

This method is primarily used in tests to access the client for verification and cleanup operations. Not intended for production use.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the MCP server with stdio transport.

The server listens for MCP protocol messages on stdin and writes responses to stdout. Tool requests are processed synchronously in the order received.

Run blocks until:

  • The context is cancelled (graceful shutdown)
  • The client closes the connection
  • A fatal error occurs

Returns an error if server startup or execution fails. Context cancellation triggers graceful shutdown and does not return an error.

Jump to

Keyboard shortcuts

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