mcpserver

package
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package mcpserver exposes an agent Session through a small, local-only MCP tool surface. Policy, validation, execution, and sensitive capture ownership remain in package agent.

Index

Constants

View Source
const (
	// ToolFind evaluates a visual condition against one explicit observation.
	ToolFind = "robotgo_find"
	// ToolWait performs one policy-bounded visual wait over an explicit region.
	ToolWait = "robotgo_wait"
	// ToolReleaseObservation zeroes and removes one retained observation.
	ToolReleaseObservation = "robotgo_release_observation"
)
View Source
const (
	// ToolCapabilities reports the immutable operation catalog.
	ToolCapabilities = "robotgo_capabilities"
	// ToolObserve performs one policy-gated diagnostics or capture observation.
	ToolObserve = "robotgo_observe"
	// ToolAct plans or executes one typed action.
	ToolAct = "robotgo_act"
	// ToolClose closes the underlying RobotGo agent session.
	ToolClose = "robotgo_close"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActInput

type ActInput struct {
	Mode    ActMode             `json:"mode,omitempty"`
	Request agent.ActionRequest `json:"request"`
}

ActInput is the strict input of robotgo_act. An omitted mode is dry-run.

type ActMode

type ActMode string

ActMode controls whether robotgo_act only plans or actually executes.

const (
	// ActModeDryRun performs full preflight without injecting input.
	ActModeDryRun ActMode = "dry-run"
	// ActModeExecute permits execution, still subject to session policy and
	// per-action confirmation.
	ActModeExecute ActMode = "execute"
)

type ActOutput

type ActOutput struct {
	Result *agent.ActionResult `json:"result,omitempty"`
	Error  *ToolError          `json:"error,omitempty"`
}

ActOutput is the structured output of robotgo_act.

type CapabilitiesOutput

type CapabilitiesOutput struct {
	Catalog agent.OperationCatalog `json:"catalog"`
	Error   *ToolError             `json:"error,omitempty"`
}

CapabilitiesOutput is the structured output of robotgo_capabilities.

type CaptureOutput

type CaptureOutput struct {
	Region agent.CaptureRegion `json:"region"`
	Width  int                 `json:"width"`
	Height int                 `json:"height"`
}

CaptureOutput reports only geometry. The agent observation's pixels and lineage digest deliberately remain private to the in-process session.

type CloseOutput

type CloseOutput struct {
	Closed bool       `json:"closed"`
	Error  *ToolError `json:"error,omitempty"`
}

CloseOutput is the structured output of robotgo_close.

type FindOutput

type FindOutput struct {
	Result *agent.FindColorResult `json:"result,omitempty"`
	Error  *ToolError             `json:"error,omitempty"`
}

FindOutput is the privacy-reduced output of robotgo_find.

type ObservationOutput

type ObservationOutput struct {
	SchemaVersion string                   `json:"schema_version"`
	ObservationID string                   `json:"observation_id"`
	CreatedAt     time.Time                `json:"created_at"`
	Diagnostics   agent.RuntimeDiagnostics `json:"diagnostics"`
	Capture       *CaptureOutput           `json:"capture,omitempty"`
}

ObservationOutput is the privacy-reduced MCP projection of an observation.

type ObserveOutput

type ObserveOutput struct {
	Observation *ObservationOutput `json:"observation,omitempty"`
	Error       *ToolError         `json:"error,omitempty"`
}

ObserveOutput is the structured output of robotgo_observe.

type ReleaseObservationInput

type ReleaseObservationInput struct {
	ObservationID string `json:"observation_id"`
}

ReleaseObservationInput identifies session-owned capture state to zero.

type ReleaseObservationOutput

type ReleaseObservationOutput struct {
	Released bool       `json:"released"`
	Error    *ToolError `json:"error,omitempty"`
}

ReleaseObservationOutput confirms that no retained observation with the requested ID remains. Releasing the same valid ID repeatedly is successful.

type Server

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

Server binds one process-exclusive agent session to one MCP connection.

func New

func New(session Session) (*Server, error)

New constructs a server without opening a transport or touching the desktop.

func (*Server) Close

func (s *Server) Close() error

Close closes the underlying agent session. It is safe to call repeatedly and concurrently. Calls that start after close receive a stable error.

func (*Server) Run

func (s *Server) Run(ctx context.Context, transport mcp.Transport) (runErr error)

Run serves one persistent transport until the peer disconnects or ctx is canceled. The agent session is always closed before Run returns.

type Session

Session is the protocol-independent behavior consumed by the adapter. *agent.Session implements Session.

type ToolError

type ToolError struct {
	Code    agent.ErrorCode `json:"code"`
	Message string          `json:"message"`
}

ToolError is a stable, payload-free error returned in structured tool output. Unclassified backend error strings are never forwarded.

type VisualConditionSession

type VisualConditionSession interface {
	Session
	FindColor(context.Context, agent.FindColorRequest) (agent.FindColorResult, error)
	WaitColor(context.Context, agent.WaitColorRequest) (agent.WaitColorResult, error)
	ReleaseObservation(string) error
}

VisualConditionSession is the additive session extension used by the visual tools. Keeping it separate preserves source compatibility for existing Session implementations; implementations without the extension retain the original four-tool surface. *agent.Session implements VisualConditionSession.

type WaitOutput

type WaitOutput struct {
	Result *agent.WaitColorResult `json:"result,omitempty"`
	Error  *ToolError             `json:"error,omitempty"`
}

WaitOutput is the privacy-reduced output of robotgo_wait.

Jump to

Keyboard shortcuts

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