filesystem

package
v0.0.0-...-511229d Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateDirectoryArgs

type CreateDirectoryArgs struct {
	Path string `json:"path"`
}

CreateDirectoryArgs is an argument struct for the create_directory tool.

type DirectoryTreeArgs

type DirectoryTreeArgs struct {
	Path string `json:"path"`
}

DirectoryTreeArgs is an argument struct for the directory_tree tool.

type EditFileArgs

type EditFileArgs struct {
	Path   string          `json:"path"`
	Edits  []EditOperation `json:"edits"`
	DryRun bool            `json:"dryRun"`
}

EditFileArgs is an argument struct for the edit_file tool.

type EditOperation

type EditOperation struct {
	OldText string `json:"oldText"`
	NewText string `json:"newText"`
}

EditOperation is a struct representing an edit operation.

type GetFileInfoArgs

type GetFileInfoArgs struct {
	Path string `json:"path"`
}

GetFileInfoArgs is an argument struct for the get_file_info tool.

type ListDirectoryArgs

type ListDirectoryArgs struct {
	Path string `json:"path"`
}

ListDirectoryArgs is an argument struct for the list_directory tool.

type MoveFileArgs

type MoveFileArgs struct {
	Source      string `json:"source"`
	Destination string `json:"destination"`
}

MoveFileArgs is an argument struct for the move_file tool.

type ReadFileArgs

type ReadFileArgs struct {
	Path string `json:"path"`
}

ReadFileArgs is an argument struct for the read_file tool.

type ReadMultipleFilesArgs

type ReadMultipleFilesArgs struct {
	Paths []string `json:"paths"`
}

ReadMultipleFilesArgs is an argument struct for the read_multiple_files tool.

type SearchFilesArgs

type SearchFilesArgs struct {
	Path    string   `json:"path"`
	Pattern string   `json:"pattern"`
	Exclude []string `json:"excludePatterns"`
}

SearchFilesArgs is an argument struct for the search_files tool.

type Server

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

Server implements the Model Context Protocol (MCP) for filesystem operations. It provides access to the local filesystem through a restricted root directory, exposing standard filesystem operations as MCP tools.

Server ensures all operations remain within the configured root directory path for security. It implements both the mcp.Server and mcp.ToolServer interfaces to provide filesystem functionality through the MCP protocol.

func NewServer

func NewServer(roots []string) (Server, error)

NewServer creates a new filesystem MCP server that provides access to files under the specified root directory.

The server validates that the root path exists and is an accessible directory. All filesystem operations are restricted to this directory and its subdirectories for security.

It returns an error if the root path does not exist, is not a directory, or cannot be accessed.

func (Server) CallTool

func (s Server) CallTool(
	_ context.Context,
	params mcp.CallToolParams,
	_ mcp.ProgressReporter,
	_ mcp.RequestClientFunc,
) (mcp.CallToolResult, error)

CallTool implements mcp.ToolServer interface. Executes a specified filesystem tool with the given parameters. All operations are restricted to paths within the server's root directory.

Returns the tool's execution result and any error encountered. Returns error if the tool is not found or if execution fails.

func (Server) ListTools

func (s Server) ListTools(
	context.Context,
	mcp.ListToolsParams,
	mcp.ProgressReporter,
	mcp.RequestClientFunc,
) (mcp.ListToolsResult, error)

ListTools implements mcp.ToolServer interface. Returns the list of available filesystem tools supported by this server. The tools provide various filesystem operations like reading, writing, and managing files.

Returns a ToolList containing all available filesystem tools and any error encountered.

type WriteFileArgs

type WriteFileArgs struct {
	Path    string `json:"path"`
	Content string `json:"content"`
}

WriteFileArgs is an argument struct for the write_file tool.

Jump to

Keyboard shortcuts

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