roots

package
v0.20.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Global = &State{
	roots: make(map[*mcp.ServerSession][]string),
}

Global is the singleton instance for the entire application.

Functions

This section is empty.

Types

type State

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

State manages the registered project roots on a per-session basis.

func (*State) Add

func (s *State) Add(session *mcp.ServerSession, path string)

Add adds a new project root for the given session after normalizing it to an absolute path.

func (*State) Delete added in v0.16.0

func (s *State) Delete(session *mcp.ServerSession)

Delete removes all registered roots for the given session.

func (*State) Get

func (s *State) Get(session *mcp.ServerSession) []string

Get returns a copy of the registered roots for the given session.

func (*State) GetAllRoots added in v0.20.2

func (s *State) GetAllRoots() []string

GetAllRoots returns a deep copy of all registered roots across all sessions.

func (*State) OnChange added in v0.20.2

func (s *State) OnChange(cb func([]string))

OnChange registers a callback that fires whenever roots change.

func (*State) Sync

func (s *State) Sync(ctx context.Context, session *mcp.ServerSession)

Sync synchronizes roots from the MCP client for the given session.

func (*State) Validate

func (s *State) Validate(session *mcp.ServerSession, projectDir string) (string, error)

Validate checks if the given path is within any of the registered roots for the session. It returns the absolute path if valid, or an error if not.

Jump to

Keyboard shortcuts

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