Source File
roots.go
Belonging Package
github.com/mark3labs/mcp-go/server
package serverimport ()var (// ErrNoClientSession is returned when there is no active client session in the contextErrNoClientSession = errors.New("no active client session")// ErrRootsNotSupported is returned when the session does not support rootsErrRootsNotSupported = errors.New("session does not support roots"))// RequestRoots sends an list roots request to the client.// The client must have declared roots capability during initialization.// The session must implement SessionWithRoots to support this operation.func ( *MCPServer) ( context.Context, mcp.ListRootsRequest) (*mcp.ListRootsResult, error) {:= ClientSessionFromContext()if == nil {return nil, ErrNoClientSession}// Check if the session supports roots requestsif , := .(SessionWithRoots); {return .ListRoots(, )}return nil, ErrRootsNotSupported}
![]() |
The pages are generated with Golds v0.8.4. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |