Documentation
¶
Index ¶
- Constants
- func CreateBackupPath(path string) string
- func CreateListToken(path string, nextPage int) (string, error)
- func CreateReadToken(path string, offset int64) (string, error)
- func CreateSearchToken(path string, offset int64) (string, error)
- func EncodeContinuationToken(token *ContinuationToken) (string, error)
- func EnsureDir(path string) error
- func GetBool(args map[string]interface{}, key string, defaultVal bool) bool
- func GetInt(args map[string]interface{}, key string, defaultVal int) int
- func GetIntSlice(args map[string]interface{}, key string) []int
- func GetString(args map[string]interface{}, key string, defaultVal string) string
- func GetStringSlice(args map[string]interface{}, key string) []string
- func IsPathAllowed(path string, allowedDirs []string) bool
- func NormalizePath(path string) (string, error)
- func ResolvePath(path string) (string, error)
- func ResolveSymlink(path string) (string, error)
- func ValidatePath(path string, allowedDirs []string) error
- func ValidateToken(token *ContinuationToken, path, operationType string) error
- type BatchOpResult
- type CodeMatch
- type CompressResult
- type ContinuationToken
- type DirectoryEntry
- type DirectoryTreeResult
- type DiskUsageResult
- type EditResult
- type ExtractResult
- type FileOpResult
- type FileSearchResult
- type LargeFileInfo
- type LargeFilesResult
- type ListDirectoryResult
- type ReadFileResult
- type ReadMultipleFilesResult
- type SearchCodeResult
- type SearchFilesResult
- type SearchReplaceResult
- type Server
- type SyncResult
- type ToolDefinition
- type TreeNode
- type WriteFileResult
Constants ¶
const ( ServerName = "llm-filesystem" ServerVersion = "1.5.0" )
const DefaultChunkSize = 1024 * 1024
Default chunk size for auto-chunking (1MB)
const DefaultListPageSize = 100
DefaultListPageSize is the default page size for auto-chunking directory listings
Variables ¶
This section is empty.
Functions ¶
func CreateBackupPath ¶
CreateBackupPath generates a backup path with timestamp
func CreateListToken ¶
CreateListToken creates a token for list_directory pagination
func CreateReadToken ¶
CreateReadToken creates a token for read_file chunked reads
func CreateSearchToken ¶
CreateSearchToken creates a token for search result pagination
func EncodeContinuationToken ¶
func EncodeContinuationToken(token *ContinuationToken) (string, error)
EncodeContinuationToken creates a base64-encoded token string
func GetIntSlice ¶
GetIntSlice extracts an int slice from args map
func GetStringSlice ¶
GetStringSlice extracts a string slice from args map
func IsPathAllowed ¶
IsPathAllowed checks if a path is within any of the allowed directories
func NormalizePath ¶
NormalizePath cleans and normalizes a file path
func ResolvePath ¶
ResolvePath expands ~ and cleans path
func ResolveSymlink ¶
ResolveSymlink resolves a symlink to its target path
func ValidatePath ¶
ValidatePath checks if a path is allowed based on the allowed directories list
func ValidateToken ¶
func ValidateToken(token *ContinuationToken, path, operationType string) error
ValidateToken checks if token is valid for the given path and operation
Types ¶
type BatchOpResult ¶
type BatchOpResult struct {
Success int `json:"success"`
Failed int `json:"failed"`
Operations []FileOpResult `json:"operations"`
}
BatchOpResult represents the result of batch operations
type CodeMatch ¶
type CodeMatch struct {
File string `json:"file"`
Line int `json:"line"`
Content string `json:"content"`
Context []string `json:"context,omitempty"`
ContextBefore []string `json:"context_before,omitempty"`
ContextAfter []string `json:"context_after,omitempty"`
}
CodeMatch represents a single code match
type CompressResult ¶
type CompressResult struct {
Output string `json:"output"`
Format string `json:"format"`
Size int64 `json:"size"`
FilesAdded int `json:"files_added"`
Success bool `json:"success"`
}
CompressResult represents compression result
type ContinuationToken ¶
type ContinuationToken struct {
Version string `json:"v"` // Token version for compatibility
Type string `json:"t"` // Operation type: "list", "read", "search"
Page int `json:"p"` // Current page number
Offset int64 `json:"o"` // Byte offset for file reads
Path string `json:"path"` // Original path for validation
}
ContinuationToken holds state for resuming paginated operations
func DecodeContinuationToken ¶
func DecodeContinuationToken(tokenStr string) (*ContinuationToken, error)
DecodeContinuationToken parses a base64-encoded token string
type DirectoryEntry ¶
type DirectoryEntry struct {
Name string `json:"name"`
Path string `json:"path"`
Type string `json:"type"` // "file" or "directory"
IsDir bool `json:"is_dir"`
Size int64 `json:"size"`
SizeReadable string `json:"size_readable"`
Mode string `json:"mode"`
Permissions uint32 `json:"permissions"`
Modified string `json:"modified"`
Created string `json:"created,omitempty"`
Accessed string `json:"accessed,omitempty"`
Extension string `json:"extension,omitempty"`
MimeType string `json:"mime_type,omitempty"`
IsReadable bool `json:"is_readable"`
IsWritable bool `json:"is_writable"`
}
DirectoryEntry represents a file or directory entry
type DirectoryTreeResult ¶
type DirectoryTreeResult struct {
Tree *TreeNode `json:"tree"` // renamed from "root" for fast-filesystem parity
TotalDirs int `json:"total_dirs"`
TotalFiles int `json:"total_files"`
TotalSize int64 `json:"total_size"`
}
DirectoryTreeResult represents the result of a directory tree operation
type DiskUsageResult ¶
type DiskUsageResult struct {
Path string `json:"path"`
TotalSize int64 `json:"total_size"`
TotalFiles int `json:"total_files"`
TotalDirs int `json:"total_dirs"`
}
DiskUsageResult represents disk usage information
type EditResult ¶
type EditResult struct {
Path string `json:"path"`
Success bool `json:"success"`
Changes int `json:"changes"`
Backup string `json:"backup,omitempty"`
Message string `json:"message"`
OldContent string `json:"old_content,omitempty"`
NewContent string `json:"new_content,omitempty"`
}
EditResult represents the result of an edit operation
type ExtractResult ¶
type ExtractResult struct {
Archive string `json:"archive"`
Destination string `json:"destination"`
FilesExtracted int `json:"files_extracted"`
Success bool `json:"success"`
}
ExtractResult represents extraction result
type FileOpResult ¶
type FileOpResult struct {
Path string `json:"path"`
Source string `json:"source,omitempty"`
Destination string `json:"destination,omitempty"`
Success bool `json:"success"`
Operation string `json:"operation"`
Message string `json:"message"`
}
FileOpResult represents the result of a file operation
type FileSearchResult ¶
type FileSearchResult struct {
Path string `json:"path"`
Name string `json:"name"`
Size int64 `json:"size"`
IsDir bool `json:"is_dir"`
ModTime string `json:"mod_time"`
}
FileSearchResult represents a found file
type LargeFileInfo ¶
type LargeFileInfo struct {
Path string `json:"path"`
Size int64 `json:"size"`
ModTime string `json:"mod_time"`
}
LargeFileInfo represents a large file found
type LargeFilesResult ¶
type LargeFilesResult struct {
Path string `json:"path"`
MinSize int64 `json:"min_size"`
Files []LargeFileInfo `json:"files"`
Total int `json:"total"`
TotalCount int `json:"total_count"`
TotalSize int64 `json:"total_size"`
}
LargeFilesResult represents find large files result
type ListDirectoryResult ¶
type ListDirectoryResult struct {
Path string `json:"path"`
Items []DirectoryEntry `json:"items"` // renamed from "entries" for fast-filesystem parity
Total int `json:"total"`
Page int `json:"page,omitempty"`
PageSize int `json:"page_size,omitempty"`
TotalPages int `json:"total_pages,omitempty"`
ContinuationToken string `json:"continuation_token,omitempty"`
HasMore bool `json:"has_more,omitempty"`
AutoChunked bool `json:"auto_chunked,omitempty"`
}
ListDirectoryResult represents the result of a directory listing
type ReadFileResult ¶
type ReadFileResult struct {
Path string `json:"path"`
Content string `json:"content"`
Size int64 `json:"size"`
Encoding string `json:"encoding"`
TotalSize int64 `json:"total_size,omitempty"`
Lines int `json:"lines,omitempty"`
Truncated bool `json:"truncated,omitempty"`
AutoChunked bool `json:"auto_chunked,omitempty"`
ChunkIndex int `json:"chunk_index,omitempty"`
TotalChunks int `json:"total_chunks,omitempty"`
ContinuationToken string `json:"continuation_token,omitempty"`
HasMore bool `json:"has_more,omitempty"`
Error string `json:"error,omitempty"`
}
ReadFileResult represents the result of a file read operation
type ReadMultipleFilesResult ¶
type ReadMultipleFilesResult struct {
Files []ReadFileResult `json:"files"`
Success int `json:"success"`
Failed int `json:"failed"`
}
ReadMultipleFilesResult represents results from reading multiple files
type SearchCodeResult ¶
type SearchCodeResult struct {
Pattern string `json:"pattern"`
Path string `json:"path"`
Matches []CodeMatch `json:"matches"`
TotalFiles int `json:"total_files"`
TotalMatches int `json:"total_matches"`
RipgrepUsed bool `json:"ripgrep_used"`
SearchTimeMs int64 `json:"search_time_ms"`
}
SearchCodeResult represents the result of a code search
type SearchFilesResult ¶
type SearchFilesResult struct {
Pattern string `json:"pattern"`
Path string `json:"path"`
Matches []FileSearchResult `json:"matches"`
Total int `json:"total"`
}
SearchFilesResult represents the result of a file search
type SearchReplaceResult ¶
type SearchReplaceResult struct {
Path string `json:"path"`
FilesModified int `json:"files_modified"`
TotalChanges int `json:"total_changes"`
Results []EditResult `json:"results"`
}
SearchReplaceResult represents results from search and replace
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps the MCP server with filesystem-specific configuration
func (*Server) AllowedDirs ¶
AllowedDirs returns the configured allowed directories
func (*Server) ExecuteHandler ¶
ExecuteHandler routes tool calls to their implementations
type SyncResult ¶
type SyncResult struct {
Source string `json:"source"`
Destination string `json:"destination"`
FilesCopied int `json:"files_copied"`
DirsCreated int `json:"dirs_created"`
Success bool `json:"success"`
}
SyncResult represents sync result
type ToolDefinition ¶
type ToolDefinition struct {
Name string
Description string
InputSchema json.RawMessage
}
ToolDefinition represents an MCP tool with its schema
func GetToolDefinitions ¶
func GetToolDefinitions() []ToolDefinition
GetToolDefinitions returns all 27 tool definitions (25 v3.4.0 + 2 v3.5.1)