Documentation
¶
Overview ¶
Package mcp is `remohop mcp`: a Model Context Protocol server on stdio that exposes RemoHop's remote shell, port forwarding, clipboard, screenshot, system information and file services as tools, so an AI agent can operate remote machines by their 9-digit ID.
The server is a thin layer over the Go client APIs of the service packages. It keeps one P2P session per target in a pool (see pool), never prompts for credentials (it has no terminal: the protocol owns stdin and stdout) and never writes anything but protocol messages to stdout.
Index ¶
Constants ¶
const (
DefaultIdleTimeout = 10 * time.Minute
)
Defaults for Options.
Variables ¶
This section is empty.
Functions ¶
func DefaultDownloadDir ¶
DefaultDownloadDir is where the MCP tools write when `remohop mcp` is not given --download-dir: a remohop folder in the user's Downloads.
Types ¶
type DialFunc ¶
DialFunc establishes an authenticated session with target (a 9-digit ID, a saved alias or host:port). It must not prompt: the MCP server's stdin and stdout belong to the protocol.
type Options ¶
type Options struct {
// Dial connects to a target. Required.
Dial DialFunc
// DefaultTarget is used when a tool call omits "target".
DefaultTarget string
// IdleTimeout closes sessions unused for this long; 0 means
// DefaultIdleTimeout, negative disables idle closing.
IdleTimeout time.Duration
// DialTimeout bounds one dial; 0 means 60 seconds.
DialTimeout time.Duration
// Version is reported to clients.
Version string
// Logger receives diagnostics; it must never write to stdout. Nil
// discards them.
Logger *slog.Logger
// ReadOnly offers only the tools that change nothing (no commands,
// writes, input, clipboard changes or forwards). It is a convenience on
// this side; what a host allows is enforced by the host (grants).
ReadOnly bool
// WriteDirs are the directories on this computer that tools may
// write to (downloads, saved screenshots and clipboard contents); a
// relative path lands in the first. Nil means DefaultDownloadDir.
// What a tool writes comes from a remote machine and the model may
// have been misled, so it must not reach ~/.ssh, shell startup files
// and the like.
WriteDirs []string
}
Options configures a Server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the MCP server. Create it with New, serve it with Run, and call Close to release the sessions and forwards if Run was not used.
func (*Server) Close ¶
func (s *Server) Close()
Close stops the forwards and closes every pooled session. It is safe to call more than once.