mcp

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

~/_git/wiz/mcp/computer_map.go

~/_git/wiz/mcp/computer_safety.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockedComputerReason added in v0.5.0

func BlockedComputerReason(in ComputerUseInput) string

BlockedComputerReason returns a non-empty reason if the action is hard-blocked (un-overridable, regardless of approval). Empty means allowed.

func IsDestructiveComputerAction added in v0.5.0

func IsDestructiveComputerAction(action string) bool

IsDestructiveComputerAction reports whether an action mutates user-visible state and must go through approval. Exported for consumers' approval policies.

func StartBrowserMCPServer added in v0.5.0

func StartBrowserMCPServer(ctx context.Context, transport mcp.Transport, cfg types.Config) error

StartBrowserMCPServer starts a headed-Chrome-backed MCP server exposing the browser_* tools (navigate, snapshot, click, type, press, scroll, vision). Blocks until ctx is done, at which point the browser is torn down.

func StartComputerMCPServer added in v0.5.0

func StartComputerMCPServer(ctx context.Context, transport mcp.Transport, cfg types.Config) error

StartComputerMCPServer spawns cua-driver as a stdio MCP child and serves the in-process computer_use tool that proxies to it. Blocks until ctx is done.

func StartFileSystemMCPServer

func StartFileSystemMCPServer(ctx context.Context, transport mcp.Transport, root string) error

StartFileSystemMCPServer starts the filesystem MCP server. When root is non-empty, relative paths are rooted at it; an empty root preserves the legacy process-cwd behavior.

func StartSkillsMCPServer

func StartSkillsMCPServer(ctx context.Context, transport mcp.Transport, skills []types.Skill) error

StartSkillsMCPServer runs an in-memory MCP server exposing a load_skill tool that returns a skill's full instructions by name.

func StartTransports

func StartTransports(ctx context.Context, cfg types.Config, shellJobs *ShellJobs) ([]mcp.Transport, error)

func StartWebMCPServer

func StartWebMCPServer(ctx context.Context, transport mcp.Transport, cfg types.Config) error

StartWebMCPServer starts the web MCP server exposing web_fetch and web_search. web_fetch reuses the session's main model and request options (model, API key, base URL, metadata, and reasoning effort) for its extraction pass.

func TransportForServer added in v0.3.0

func TransportForServer(srv types.MCPServer) mcp.Transport

TransportForServer returns the client transport for a configured MCP server. A server with URL set uses a remote HTTP/SSE transport (Streamable HTTP by default, SSE when Transport == "sse"); otherwise it launches Command over stdio, inheriting the process environment plus the server's Env.

Types

type BrowserInput added in v0.5.0

type BrowserInput struct {
	URL       string `json:"url,omitempty" jsonschema:"the URL to open (browser_navigate)"`
	Ref       string `json:"ref,omitempty" jsonschema:"element ref from the snapshot, e.g. @e5 (browser_click/browser_type)"`
	Text      string `json:"text,omitempty" jsonschema:"text to type (browser_type)"`
	Key       string `json:"key,omitempty" jsonschema:"key to press, e.g. Enter, Tab, Escape (browser_press)"`
	Direction string `json:"direction,omitempty" jsonschema:"up or down (browser_scroll)"`
	Full      bool   `json:"full,omitempty" jsonschema:"return the full page snapshot, not just interactive elements (browser_snapshot)"`
	Question  string `json:"question,omitempty" jsonschema:"what to look for in the screenshot (browser_vision)"`
}

BrowserInput is the shared input shape for every browser_* tool. Only the fields relevant to a given tool are populated by the model for that call.

type BrowserOutput added in v0.5.0

type BrowserOutput struct {
	Snapshot     string `json:"snapshot,omitempty"`
	ElementCount int    `json:"element_count,omitempty"`
}

BrowserOutput is the structured result returned to the model for every browser_* tool that produces (or refreshes) a snapshot.

type ComputerElement added in v0.5.0

type ComputerElement struct {
	Index int    `json:"element_index"`
	Role  string `json:"role"`
	Label string `json:"label"`
}

ComputerElement is one AX element surfaced from a capture.

type ComputerUseInput added in v0.5.0

type ComputerUseInput struct {
	Action         string   `` /* 165-byte string literal not displayed */
	Mode           string   `json:"mode,omitempty" jsonschema:"capture mode: som (default),vision,ax"`
	App            string   `` /* 192-byte string literal not displayed */
	MaxElements    int      `json:"max_elements,omitempty" jsonschema:"cap on returned AX elements (default 100, max 1000)"`
	Element        int      `json:"element,omitempty" jsonschema:"1-based SOM index from the last capture (preferred over coordinates)"`
	Coordinate     []int    `json:"coordinate,omitempty" jsonschema:"pixel [x,y]; use only when no element index is available"`
	Button         string   `json:"button,omitempty" jsonschema:"left,right,middle"`
	Modifiers      []string `json:"modifiers,omitempty" jsonschema:"modifier keys held during the action"`
	FromElement    int      `json:"from_element,omitempty"`
	ToElement      int      `json:"to_element,omitempty"`
	FromCoordinate []int    `json:"from_coordinate,omitempty"`
	ToCoordinate   []int    `json:"to_coordinate,omitempty"`
	Direction      string   `json:"direction,omitempty" jsonschema:"up,down,left,right"`
	Amount         int      `json:"amount,omitempty" jsonschema:"scroll wheel ticks (default 3)"`
	Value          string   `json:"value,omitempty" jsonschema:"value for set_value"`
	Text           string   `json:"text,omitempty" jsonschema:"text to type"`
	Keys           string   `json:"keys,omitempty" jsonschema:"key combo, e.g. cmd+s, ctrl+alt+t, return"`
	Seconds        float64  `json:"seconds,omitempty" jsonschema:"seconds to wait (max 30)"`
	RaiseWindow    bool     `json:"raise_window,omitempty"`
	CaptureAfter   bool     `json:"capture_after,omitempty" jsonschema:"take a follow-up capture after the action"`
}

ComputerUseInput is the single wrapper tool's argument set.

type ComputerUseOutput added in v0.5.0

type ComputerUseOutput struct {
	Summary   string            `json:"summary"`
	Elements  []ComputerElement `json:"elements,omitempty"`
	ImageMIME string            `json:"image_mime_type,omitempty"`
}

ComputerUseOutput is the structured result returned to the model.

type ShellJobInfo

type ShellJobInfo struct {
	ID      string
	Script  string
	Status  string // running | completed | failed
	Running bool
	// Backgrounded is true for jobs that run detached from a turn — started via
	// bash_background, or a foreground command the user backgrounded with Ctrl+B.
	// A normal foreground command (consumed inline by the turn) is false.
	Backgrounded bool
}

ShellJobInfo is a UI-facing snapshot of a shell job.

type ShellJobs

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

ShellJobs is the shared registry of shell jobs. It is created in main.go and shared between the shell MCP server (which starts/manages jobs) and the UI (which lists jobs for the footer and backgrounds the foreground one on Ctrl+B).

func NewShellJobs

func NewShellJobs() *ShellJobs

NewShellJobs creates an empty shared shell-job registry.

func NewShellJobsInDir added in v0.4.1

func NewShellJobsInDir(dir string) *ShellJobs

NewShellJobsInDir creates a shell-job registry whose commands run in dir (cmd.Dir). An empty dir preserves the legacy process-cwd behavior.

func (*ShellJobs) DetachForeground

func (s *ShellJobs) DetachForeground() (string, bool)

DetachForeground backgrounds the running foreground shell command (Ctrl+B).

func (*ShellJobs) HasForeground

func (s *ShellJobs) HasForeground() bool

HasForeground reports whether a detachable foreground shell command is currently running.

func (*ShellJobs) HasRunning

func (s *ShellJobs) HasRunning() bool

HasRunning reports whether any shell job (background or foreground) is still running. Used as a WithPendingWork predicate so the live agent run parks while a backgrounded shell command is still in flight.

func (*ShellJobs) Kill

func (s *ShellJobs) Kill(id string) bool

Kill stops a shell job by id.

func (*ShellJobs) List

func (s *ShellJobs) List() []ShellJobInfo

List returns all shell jobs in start order, oldest first.

func (*ShellJobs) Output

func (s *ShellJobs) Output(id string) (stdout, stderr string, ok bool)

Output returns the captured stdout/stderr of a shell job by id.

func (*ShellJobs) SetOnJobDone

func (s *ShellJobs) SetOnJobDone(fn func(ShellJobInfo))

SetOnJobDone registers a callback invoked once for each shell job that finishes (from the job's wait goroutine). The session uses it to inject a completion notice into the live run. fn receives a UI-facing snapshot; it is called for every job — the caller decides whether to act (e.g. only on backgrounded jobs). Safe to call once at setup.

type StickyContext added in v0.5.0

type StickyContext struct {
	PID       int
	WindowID  int
	SessionID string
	Desktop   bool // true after a desktop-scope capture: act by screen-absolute pixel, no window
	// Explicit marks a target the model deliberately chose — open_app, focus_app,
	// or capture(app=...) — as opposed to whatever happened to be frontmost. A
	// plain capture reuses an explicit target instead of re-detecting frontmost,
	// so "open_app then capture" sees the app just opened, not e.g. a mounted
	// DMG's Finder window that stole the front.
	Explicit bool
}

StickyContext is the pid/window/session carried forward from the last capture.

Jump to

Keyboard shortcuts

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