daemon

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeStringSlice

func EncodeStringSlice(ss []string) string

EncodeStringSlice encodes a string slice as base64 JSON for passing to __daemon.

func EnsureRunning

func EnsureRunning(ctx context.Context, serverName, scope string, command string, args []string, env []string, startupTimeout time.Duration) (string, error)

EnsureRunning makes sure a daemon is running for the server. If not already running, it spawns one as a detached process. Scope isolates daemons per project/workspace. Returns the socket path to connect to.

func IsRunning

func IsRunning(serverName, scope string) bool

IsRunning checks if a daemon is alive for the given server and scope. It verifies both the PID file and socket connectivity.

func LogPath

func LogPath(serverName, scope string) string

LogPath returns the log file path for a server's daemon.

func NewDaemonManageCommand

func NewDaemonManageCommand(serverNames []string) *cobra.Command

NewDaemonManageCommand creates the user-facing "daemon" command with status/stop subcommands.

func NewDaemonRunCommand

func NewDaemonRunCommand() *cobra.Command

NewDaemonRunCommand creates the hidden __daemon command that runs the daemon process. This is invoked by EnsureRunning as a detached subprocess.

func PIDPath

func PIDPath(serverName, scope string) string

PIDPath returns the PID file path for a server's daemon.

func SocketPath

func SocketPath(serverName, scope string) string

SocketPath returns the unix socket path for a server's daemon. Scope isolates daemons per project/workspace (e.g. hash of project root).

func Start

func Start(serverName string, scope string, command string, args []string, env []string, idleTimeout time.Duration) error

Start launches the daemon: starts the MCP server, performs the MCP handshake, listens on a unix socket, and serves client requests until shutdown. This function blocks until the daemon exits.

func Stop

func Stop(serverName, scope string) error

Stop sends SIGTERM to a running daemon.

Types

type Daemon

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

Daemon holds a single MCP server alive and accepts client connections over a unix socket. It proxies JSON-RPC requests to the server and routes responses back to the correct client.

type SocketTransport

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

SocketTransport implements mcp.Transport over a unix socket connection to a running mcpx daemon. Closing it only closes the socket — the daemon stays alive.

func NewSocketTransport

func NewSocketTransport(socketPath string) (*SocketTransport, error)

NewSocketTransport connects to a daemon's unix socket and returns a transport.

func (*SocketTransport) Close

func (t *SocketTransport) Close() error

Close closes the socket connection. The daemon stays alive.

func (*SocketTransport) Send

func (t *SocketTransport) Send(ctx context.Context, req *mcp.Request) (*mcp.Response, error)

Send sends a request over the socket and waits for the response.

func (*SocketTransport) SendNotification

func (t *SocketTransport) SendNotification(ctx context.Context, notif *mcp.Request) error

SendNotification sends a notification (no response expected).

Jump to

Keyboard shortcuts

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