Documentation
¶
Overview ¶
Package axmcp exposes embeddable macOS Accessibility MCP tools and Cobra CLI commands for reuse in other servers and command-line tools, and documents the axmcp module.
Embedding MCP tools ¶
Register all AX tools or a chosen subset on any *mcp.Server:
if err := axmcp.RegisterTools(server,
axmcp.WithGroups(axmcp.GroupInspect, axmcp.GroupInteract),
axmcp.WithExcludeTools(axmcp.ToolPinch),
); err != nil {
return err
}
Embedding CLI commands ¶
Mount the full axmcp CLI command set or a subset into another Cobra CLI:
axCmd, err := axmcp.NewCommand(
axmcp.WithUse("ax"),
axmcp.WithCommands(axmcp.CommandApps, axmcp.CommandTree, axmcp.CommandFind),
)
if err != nil {
return err
}
root.AddCommand(axCmd)
Related packages ¶
- github.com/tmc/axmcp/appshot captures and exports window context and images.
- github.com/tmc/axmcp/axcmd provides embeddable Accessibility CLI commands.
- github.com/tmc/axmcp/ghostcursor draws animated cursor overlays.
Commands ¶
The module provides the following entry points:
- cmd/appshot, a CLI for capturing one running macOS window
- cmd/axmcp, a stdio MCP server and CLI for macOS Accessibility automation
- cmd/xcmcp, a stdio MCP server for project inspection, build and test, simulator control, device control, UI inspection, and Xcode integration
- cmd/computer-use-mcp, a stdio MCP server implementing the Codex Computer Use contract with per-session application state
- cmd/xc, a direct CLI built on the same Xcode packages
- cmd/ax, a direct CLI for the macOS Accessibility API
- cmd/ascript and cmd/ascriptmcp, tools for scriptable macOS applications
Environment ¶
axmcp targets macOS and assumes Xcode and the simulator tooling are installed. Packages that drive the UI require Accessibility permission in System Settings > Privacy & Security > Accessibility.
Index ¶
- func Commands(opts ...CommandOption) ([]*cobra.Command, error)
- func NewCommand(opts ...CommandOption) (*cobra.Command, error)
- func RegisterTools(server *mcp.Server, opts ...ToolOption) error
- func SetAccessibilityWait(d time.Duration)
- func SetCLIVisibility(enabled bool, delay time.Duration)
- func SetDiagnosticWriter(w io.Writer)
- func WaitForVisualFeedback()
- type Command
- type CommandOption
- type Group
- type Tool
- type ToolOption
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Commands ¶
func Commands(opts ...CommandOption) ([]*cobra.Command, error)
Commands constructs fresh Cobra subcommands for the selected subset so they can be embedded directly into any host Cobra CLI.
func NewCommand ¶
func NewCommand(opts ...CommandOption) (*cobra.Command, error)
NewCommand constructs a fresh parent Cobra command (default Use: "axmcp") with visibility flags and the selected subcommands attached.
Example ¶
package main
import (
"fmt"
"github.com/spf13/cobra"
"github.com/tmc/axmcp"
)
func main() {
host := &cobra.Command{Use: "mytool"}
sub, err := axmcp.NewCommand(
axmcp.WithUse("ax"),
axmcp.WithCommands(axmcp.CommandApps, axmcp.CommandFind, axmcp.CommandScreenshot),
)
if err != nil {
panic(err)
}
host.AddCommand(sub)
for _, c := range sub.Commands() {
fmt.Println(c.Name())
}
}
Output: apps find screenshot
func RegisterTools ¶
func RegisterTools(server *mcp.Server, opts ...ToolOption) error
RegisterTools registers the selected AX MCP tools on server. With no options, all 34 AX tools are registered.
Example ¶
package main
import (
"fmt"
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/tmc/axmcp"
)
func main() {
server := mcp.NewServer(&mcp.Implementation{Name: "my-mcp", Version: "1.0.0"}, nil)
if err := axmcp.RegisterTools(server,
axmcp.WithGroups(axmcp.GroupInspect),
axmcp.WithExcludeTools(axmcp.ToolMenuRead),
); err != nil {
panic(err)
}
tools, _ := axmcp.ResolveTools(
axmcp.WithGroups(axmcp.GroupInspect),
axmcp.WithExcludeTools(axmcp.ToolMenuRead),
)
fmt.Println(len(tools))
}
Output: 6
func SetAccessibilityWait ¶
SetAccessibilityWait configures how long AX operations wait for Accessibility permission before failing.
func SetCLIVisibility ¶
SetCLIVisibility configures post-action CLI visual feedback lingering.
func SetDiagnosticWriter ¶
SetDiagnosticWriter directs axmcp diagnostic output to w. Passing nil restores os.Stderr.
func WaitForVisualFeedback ¶
func WaitForVisualFeedback()
WaitForVisualFeedback sleeps briefly if a CLI command triggered visual feedback and visibility lingering is enabled.
Types ¶
type Command ¶
type Command string
Command identifies an embeddable axmcp CLI subcommand.
const ( CommandApps Command = "apps" CommandTree Command = "tree" CommandFind Command = "find" CommandPipe Command = "pipe" CommandClick Command = "click" CommandHover Command = "hover" CommandRightClick Command = "rightclick" CommandType Command = "type" CommandMenu Command = "menu" CommandMenuRead Command = "menu-read" CommandFocus Command = "focus" CommandFocusState Command = "focus-state" CommandScreenshot Command = "screenshot" CommandPermissions Command = "permissions" CommandAppshot Command = "appshot" )
func AllCommands ¶
func AllCommands() []Command
AllCommands returns all embeddable axmcp CLI subcommands in canonical order.
func ReadOnlyCommands ¶
func ReadOnlyCommands() []Command
ReadOnlyCommands returns the non-mutating axmcp CLI inspection and capture subcommands.
func ResolveCommands ¶
func ResolveCommands(opts ...CommandOption) ([]Command, error)
ResolveCommands returns the ordered, deduplicated list of CLI subcommands selected by opts. It returns an error if any command name is unknown.
type CommandOption ¶
type CommandOption func(*commandConfig)
CommandOption configures command selection and presentation for NewCommand and Commands.
func WithCommands ¶
func WithCommands(cmds ...Command) CommandOption
WithCommands restricts the returned set to the named CLI subcommands.
func WithExcludeCommands ¶
func WithExcludeCommands(cmds ...Command) CommandOption
WithExcludeCommands omits the named CLI subcommands from the returned set.
func WithUse ¶
func WithUse(use string) CommandOption
WithUse overrides the parent command Use string returned by NewCommand (default "axmcp").
type Tool ¶
type Tool string
Tool identifies an embeddable AX MCP tool.
const ( ToolApps Tool = "ax_apps" ToolTree Tool = "ax_tree" ToolSnapshot Tool = "ax_snapshot" ToolFind Tool = "ax_find" ToolPipe Tool = "ax_pipe" ToolClick Tool = "ax_click" ToolType Tool = "ax_type" ToolMenu Tool = "ax_menu" ToolMenuRead Tool = "ax_menu_read" ToolFocus Tool = "ax_focus" ToolListWindows Tool = "ax_list_windows" ToolScreenshot Tool = "ax_screenshot" ToolAppshot Tool = "ax_appshot" ToolOCR Tool = "ax_ocr" ToolOCRDiff Tool = "ax_ocr_diff" ToolScroll Tool = "ax_scroll" ToolDrag Tool = "ax_drag" ToolZoom Tool = "ax_zoom" ToolPinch Tool = "ax_pinch" ToolActionScreenshot Tool = "ax_action_screenshot" ToolOCRActionDiff Tool = "ax_ocr_action_diff" ToolOCRClick Tool = "ax_ocr_click" ToolOCRHover Tool = "ax_ocr_hover" ToolDoubleClick Tool = "ax_double_click" ToolSetValue Tool = "ax_set_value" ToolKeystroke Tool = "ax_keystroke" ToolPerformAction Tool = "ax_perform_action" ToolWindowClick Tool = "ax_window_click" ToolWindowHover Tool = "ax_window_hover" ToolWindowDrag Tool = "ax_window_drag" ToolWindowDragPath Tool = "ax_window_drag_path" ToolWindowMove Tool = "ax_window_move" ToolWindowRaise Tool = "ax_window_raise" ToolWindowAction Tool = "ax_window_action" )
func AllTools ¶
func AllTools() []Tool
AllTools returns every AX MCP tool in canonical registration order.
func GroupTools ¶
GroupTools returns the tools belonging to g, or nil if g is unknown.
func ResolveTools ¶
func ResolveTools(opts ...ToolOption) ([]Tool, error)
ResolveTools returns the ordered, deduplicated list of AX MCP tools selected by opts. It returns an error if any tool or group name is unknown.
type ToolOption ¶
type ToolOption func(*toolConfig)
ToolOption configures which AX MCP tools are registered by RegisterTools.
func WithExcludeTools ¶
func WithExcludeTools(tools ...Tool) ToolOption
WithExcludeTools omits the named tools from registration.
func WithGroups ¶
func WithGroups(groups ...Group) ToolOption
WithGroups restricts registration to tools in the named groups (combined with any tools selected by WithTools).
func WithTools ¶
func WithTools(tools ...Tool) ToolOption
WithTools restricts registration to the named tools (combined with any tools selected by WithGroups).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package appshot captures a running macOS application's accessibility context and an optional PNG of the same window.
|
Package appshot captures a running macOS application's accessibility context and an optional PNG of the same window. |
|
Package axcmd provides embeddable Cobra commands for macOS Accessibility API navigation, querying, and interaction.
|
Package axcmd provides embeddable Cobra commands for macOS Accessibility API navigation, querying, and interaction. |
|
cmd
|
|
|
appshot
command
Command appshot captures a running window as accessibility context and an optional image.
|
Command appshot captures a running window as accessibility context and an optional image. |
|
ascript
command
Command ascript is a CLI for exploring and running AppleScript commands against scriptable macOS applications.
|
Command ascript is a CLI for exploring and running AppleScript commands against scriptable macOS applications. |
|
ascriptmcp
command
Command ascriptmcp serves AppleScript commands as MCP tools on macOS.
|
Command ascriptmcp serves AppleScript commands as MCP tools on macOS. |
|
ax
command
Command ax is a CLI for macOS Accessibility API navigation with dynamic tab completion.
|
Command ax is a CLI for macOS Accessibility API navigation with dynamic tab completion. |
|
axmcp
command
Command axmcp is an MCP server for macOS Accessibility API automation.
|
Command axmcp is an MCP server for macOS Accessibility API automation. |
|
computer-use-mcp
command
Command computer-use-mcp serves macOS application observations and input actions over MCP.
|
Command computer-use-mcp serves macOS application observations and input actions over MCP. |
|
xc
command
Command xc builds Xcode projects and controls iOS simulators.
|
Command xc builds Xcode projects and controls iOS simulators. |
|
xcmcp
command
Command xcmcp is a MCP server that exposes various tools for interacting with Xcode projects, simulators, devices, and related resources.
|
Command xcmcp is a MCP server that exposes various tools for interacting with Xcode projects, simulators, devices, and related resources. |
|
Package ghostcursor draws transient cursor overlays on macOS.
|
Package ghostcursor draws transient cursor overlays on macOS. |
|
internal
|
|
|
altool
Package altool wraps xcrun altool for app upload and validation.
|
Package altool wraps xcrun altool for app upload and validation. |
|
appshot
Package appshot captures and formats immutable accessibility context with an optional exact-window PNG.
|
Package appshot captures and formats immutable accessibility context with an optional exact-window PNG. |
|
appshot/core
Package core implements capture, validation, and export for appshot.
|
Package core implements capture, validation, and export for appshot. |
|
appshot/testfixture
Package testfixture supplies Appshot image fixtures.
|
Package testfixture supplies Appshot image fixtures. |
|
appshotlex
Package appshotlex renders prepared, handle-free native appshot rows.
|
Package appshotlex renders prepared, handle-free native appshot rows. |
|
appshotmcp/wire
Package wire maps appshot attachments to MCP content blocks.
|
Package wire maps appshot attachments to MCP content blocks. |
|
asc
Package asc wraps the asc CLI for App Store Connect API operations.
|
Package asc wraps the asc CLI for App Store Connect API operations. |
|
axengine
Package axengine implements the macOS Accessibility, OCR, screenshot, appshot, pipeline, and MCP tool handlers used by package axmcp and cmd/axmcp.
|
Package axengine implements the macOS Accessibility, OCR, screenshot, appshot, pipeline, and MCP tool handlers used by package axmcp and cmd/axmcp. |
|
buildversion
Package buildversion reports the version of the module a binary was built from, for use as an MCP server's advertised version.
|
Package buildversion reports the version of the module a binary was built from, for use as an MCP server's advertised version. |
|
cmdflag
Package cmdflag reads command-line boolean flags before command initialization.
|
Package cmdflag reads command-line boolean flags before command initialization. |
|
computeruse
Package computeruse defines the shared model for the session-oriented computer-use server.
|
Package computeruse defines the shared model for the session-oriented computer-use server. |
|
computeruse/approval
Package approval coordinates app-control grants and revocation.
|
Package approval coordinates app-control grants and revocation. |
|
computeruse/appstate
Package appstate builds live app snapshots for the computer-use server.
|
Package appstate builds live app snapshots for the computer-use server. |
|
computeruse/appstate/textgen
command
Command textgen generates the fixed native text profile from pinned inputs.
|
Command textgen generates the fixed native text profile from pinned inputs. |
|
computeruse/coords
Package coords converts between computer-use coordinate spaces.
|
Package coords converts between computer-use coordinate spaces. |
|
computeruse/input
Package input provides reusable input helpers for the computer-use server.
|
Package input provides reusable input helpers for the computer-use server. |
|
computeruse/instruction
Package instruction provides app-specific hints for computer-use sessions.
|
Package instruction provides app-specific hints for computer-use sessions. |
|
computeruse/intervention
Package intervention detects recent physical user input.
|
Package intervention detects recent physical user input. |
|
computeruse/magnify
Package magnify resolves semantic zoom and pinch requests into concrete backend actions.
|
Package magnify resolves semantic zoom and pinch requests into concrete backend actions. |
|
computeruse/overlay
Package overlay draws labeled OCR matches on captured images.
|
Package overlay draws labeled OCR matches on captured images. |
|
computeruse/policy
Package policy enforces computer-use safety policies.
|
Package policy enforces computer-use safety policies. |
|
computeruse/session
Package session keeps native observations alive while actions hold leases.
|
Package session keeps native observations alive while actions hold leases. |
|
crash
Package crash lists and reads macOS crash reports.
|
Package crash lists and reads macOS crash reports. |
|
debugger
Package debugger manages LLDB sessions attached to macOS applications.
|
Package debugger manages LLDB sessions attached to macOS applications. |
|
devicectl
Package devicectl provides wrappers around xcrun devicectl for physical device management.
|
Package devicectl provides wrappers around xcrun devicectl for physical device management. |
|
focusless
Package focusless reports the window server's focus and Space state.
|
Package focusless reports the window server's focus and Space state. |
|
macosapp
Package macosapp discovers, launches and waits for macOS applications and windows.
|
Package macosapp discovers, launches and waits for macOS applications and windows. |
|
macsigning
Package macsigning configures signing defaults for macgo application bundles.
|
Package macsigning configures signing defaults for macgo application bundles. |
|
preview
Package preview prepares SwiftUI source and instructions for generating previews.
|
Package preview prepares SwiftUI source and instructions for generating previews. |
|
project
Package project discovers Xcode projects and reads their schemes and build settings.
|
Package project discovers Xcode projects and reads their schemes and build settings. |
|
purego/cfhandle
Package cfhandle operates on retained foreign CoreFoundation handles without converting their integer representation to Go pointers.
|
Package cfhandle operates on retained foreign CoreFoundation handles without converting their integer representation to Go pointers. |
|
purego/coresim
Package coresim provides purego bindings for CoreSimulator.framework.
|
Package coresim provides purego bindings for CoreSimulator.framework. |
|
screen
Package screen captures iOS simulator screenshots with optional scaling.
|
Package screen captures iOS simulator screenshots with optional scaling. |
|
sdef
Package sdef parses macOS scripting definition (sdef) XML and generates AppleScript runners from the parsed definitions.
|
Package sdef parses macOS scripting definition (sdef) XML and generates AppleScript runners from the parsed definitions. |
|
simctl
Package simctl manages iOS simulators, installed applications and recordings.
|
Package simctl manages iOS simulators, installed applications and recordings. |
|
ui
Package ui exposes accessibility elements and application control for macOS and simulators.
|
Package ui exposes accessibility elements and application control for macOS and simulators. |
|
ui/permissions
Package permissions checks and requests macOS automation permissions and displays onboarding status.
|
Package permissions checks and requests macOS automation permissions and displays onboarding status. |
|
xcmcp/resources
Package resources registers MCP resources for projects, applications and simulators.
|
Package resources registers MCP resources for projects, applications and simulators. |
|
xcodebuild
Package xcodebuild runs Xcode builds and tests and collects products and diagnostics.
|
Package xcodebuild runs Xcode builds and tests and collects products and diagnostics. |
|
xcodewizard
Package xcodewizard drives Xcode's File > New > Target wizard through the macOS Accessibility API.
|
Package xcodewizard drives Xcode's File > New > Target wizard through the macOS Accessibility API. |