fs

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package fs registers MCP tools for remote file operations (ls, cat, upload, download, grep).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(s *mcp.Server, p SessionProvider, opts Options)

func RegisterFileTransfer

func RegisterFileTransfer(s *mcp.Server, p SessionProvider, opts Options)

RegisterFileTransfer registers upload_file/download_file and their status tools. Which local paths they may touch is the pool's session.PoolOptions.LocalFS, not an argument here — a server that grants no host file access gets tools that fail closed rather than tools that need a root passed correctly.

Types

type Options added in v0.8.0

type Options struct {
	// Blob is the store upload_file resolves a blob id against. A nil store
	// leaves the argument refusing with an error naming the missing flag, which
	// is the same failure mode as a server started without one.
	Blob blob.Store
}

Options configures the registrations in this package.

type SessionProvider

type SessionProvider interface {
	Get(ctx context.Context, id string) (*ssh.Client, error)
	SFTP(ctx context.Context, id string) (*sftp.Client, error)
	Upload(ctx context.Context, sessionID, localPath, remotePath string) (string, error)
	UploadFrom(ctx context.Context, sessionID string, src io.ReadCloser, size int64, remotePath string) (string, error)
	UploadStatus(ctx context.Context, sessionID, uploadID string) (session.UploadStatusResponse, error)
	UploadWait(ctx context.Context, sessionID, uploadID string) (session.UploadStatusResponse, error)
	UploadCancel(ctx context.Context, sessionID, uploadID string) (session.UploadStatusResponse, error)
	Download(ctx context.Context, sessionID, remotePath, localPath string) (string, error)
	DownloadTo(ctx context.Context, sessionID, remotePath, name string, sink blob.Store) (string, error)
	DownloadStatus(ctx context.Context, sessionID, downloadID string) (session.DownloadStatusResponse, error)
	DownloadWait(ctx context.Context, sessionID, downloadID string) (session.DownloadStatusResponse, error)
	DownloadCancel(ctx context.Context, sessionID, downloadID string) (session.DownloadStatusResponse, error)
	Run(ctx context.Context, sessionID string, cmd string) (sshutil.Result, error)
	RunWithOptions(ctx context.Context, sessionID string, cmd string, opts sshutil.RunOptions) (sshutil.Result, error)
}

Jump to

Keyboard shortcuts

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