filesystem

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server added in v0.2.0

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 added in v0.2.0

func NewServer(root 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 added in v0.2.0

func (s Server) CallTool(
	ctx context.Context,
	params mcp.ToolsCallParams,
	_ mcp.RequestClientFunc,
) (mcp.ToolResult, 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.

The ctx parameter provides context for the operation. The params parameter contains the tool name to execute and its arguments.

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

func (Server) Info added in v0.2.0

func (s Server) Info() mcp.Info

Info implements mcp.Server interface.

func (Server) ListTools added in v0.2.0

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.

The ctx parameter provides context for the operation. The params parameter contains pagination and metadata for the listing operation.

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

func (Server) RequireRootsListClient added in v0.2.0

func (s Server) RequireRootsListClient() bool

RequireRootsListClient implements mcp.Server interface.

func (Server) RequireSamplingClient added in v0.2.0

func (s Server) RequireSamplingClient() bool

RequireSamplingClient implements mcp.Server interface.

Jump to

Keyboard shortcuts

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