Documentation
¶
Overview ¶
Package server implements the Taskfile-backed MCP server.
Index ¶
- type Server
- func (s *Server) HandleInitialized(ctx context.Context, req *mcp.InitializedRequest)
- func (s *Server) HandleRootsChanged(ctx context.Context, req *mcp.RootsListChangedRequest)
- func (s *Server) ReloadRoot(ctx context.Context, uri string) error
- func (s *Server) RootWatchState(uri string) ([]string, map[string]struct{}, bool)
- func (s *Server) SetLogger(logger *slog.Logger)
- func (s *Server) SetToolRegistry(registry toolRegistry)
- func (s *Server) Shutdown()
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 ¶
ReloadRoot re-creates the task executor for a given canonical root URI and syncs the global MCP tool set.
func (*Server) RootWatchState ¶
RootWatchState returns copies of the current watch configuration for a root. It satisfies watch.StateProvider.
func (*Server) SetLogger ¶
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.