server

package
v0.0.0-...-f2e3cbe Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package server implements the Taskfile-backed MCP server.

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 represents our MCP server for Taskfile.yml.

The mu mutex protects in-memory mutations of roots, registeredTools, and generation. Functions called while holding mu must not block, perform I/O, or interact with goroutines that themselves acquire mu. Heavier lifecycle work (loading Taskfiles, cancelling watchers, notifying the MCP registry) MUST be driven by callers after mu has been released.

The watcher set is owned by watchers, which has its own internal lock and lifecycle that is independent of mu. Callers must not hold mu while invoking watcher methods.

func New

func New() *Server

New creates a new Taskfile MCP server. The server starts with a silent logger; callers should override it via SetLogger before Run.

func (*Server) HandleInitialized

func (s *Server) HandleInitialized(ctx context.Context, req *mcp.InitializedRequest)

HandleInitialized is called after the client handshake completes. Before doing any other work it extends the active logger with an MCP arm bound to req.Session so subsequent log records reach the client.

func (*Server) HandleRootsChanged

func (s *Server) HandleRootsChanged(ctx context.Context, req *mcp.RootsListChangedRequest)

HandleRootsChanged is called when the client sends roots/list_changed. It applies the per-root watcher diff regardless of whether syncTools succeeds, so the watcher set continues to track the live root membership.

func (*Server) ReloadRoot

func (s *Server) ReloadRoot(ctx context.Context, uri string) error

ReloadRoot re-creates the task executor for a given canonical root URI and syncs the global MCP tool set.

func (*Server) RootWatchState

func (s *Server) RootWatchState(uri string) ([]string, map[string]struct{}, bool)

RootWatchState returns copies of the current watch configuration for a root. It satisfies watch.StateProvider.

func (*Server) SetLogger

func (s *Server) SetLogger(logger *slog.Logger)

SetLogger replaces the structured logger used by the server. Passing a nil logger restores the default silent logger so Server methods can log unconditionally without nil-checking. The store is atomic so it is safe to call from any goroutine, including after watcher goroutines have started reading the logger.

func (*Server) SetToolRegistry

func (s *Server) SetToolRegistry(registry toolRegistry)

SetToolRegistry attaches the registry used for tool registration updates.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown stops every running watcher and waits for them to exit. It is idempotent and safe to call multiple times. After Shutdown returns, future calls into the watcher manager become no-ops.

Jump to

Keyboard shortcuts

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