filer

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package filer is a workspace of a go-filer backend, such as a directory, or a bucket, which lists its folders and files, reads them, and watches them, when the backend can, and an MCP server of it

Index

Constants

View Source
const (
	// DefaultLimit is how many folders, and files, are listed, when it isn't
	// said, and MaxLimit the most
	DefaultLimit = 100
	MaxLimit     = 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	*server.Server
	// contains filtered or unexported fields
}

Server is an MCP server of a go-filer backend's folders, and files, as a workspace, whose name, and title, are its namespace's, which has no tools, yet

func NewServer

func NewServer(name, title string, filer gofiler.Filer, opts ...server.Opt) (*Server, error)

NewServer returns an MCP server of the go-filer backend's folders, and files, with the name, which is an identifier, and the title, with the server's options, such as its version. Returns ErrBadParameter when the name isn't an identifier, or there's no backend.

func (*Server) Run

func (s *Server) Run(ctx context.Context, logger *slog.Logger) error

Run serves the backend's changes, as it says them, to the server's clients, until the context is cancelled, when it returns nil, or it fails, which is logged

func (*Server) Workspace

func (s *Server) Workspace() *Workspace

Workspace returns the workspace the server serves

type Workspace

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

Workspace is the workspace of a go-filer backend: its folders, and files, whose URIs are file:// and their paths, such as file:///notes/a.md, and file:///notes/, for a folder, which are percent-encoded

func New

func New(name string, filer gofiler.Filer) (*Workspace, error)

New returns the workspace of the go-filer backend, whose volume has the name. Returns ErrBadParameter when there's no backend.

func (*Workspace) List

List returns a page of the folders, and files, in the folder, or under it, in the order of their paths, from the cursor, which is the path of the last one of the page before, or, for a file's path, the file

func (*Workspace) Read

func (w *Workspace) Read(ctx context.Context, uri string) (llm.Resource, error)

Read returns the file with the URI, which is read as it's read. Returns ErrNotFound when there's none, and ErrBadParameter when it's a folder, or the URI isn't a file's.

func (*Workspace) Root

func (w *Workspace) Root() string

Root returns the root of the folders', and files', URIs, file:///

func (*Workspace) Tree

func (w *Workspace) Tree() bool

Tree returns true, as its folders are listed on their own, by their type, and have their paths

func (*Workspace) WatchResources

func (w *Workspace) WatchResources(ctx context.Context, ch chan<- schema.Change) error

WatchResources sends the folders, and files, which are created, updated, or deleted, and, without a URI, that they changed, but not which, as the backend says a folder's changes may have been missed, to the channel, until the context is cancelled, when it returns nil. It sends a change without a URI first, once it's watching. Returns ErrNotImplemented when the backend doesn't watch its objects, or doesn't say when it's watching, so a change made once it's said to be isn't missed.

Jump to

Keyboard shortcuts

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