AppAgent Command System

November 12, 2025 · View on GitHub

AppAgent executes application-level commands through the MCP (Model-Context Protocol) system. Commands are dynamically provided by MCP servers and executed through the CommandDispatcher interface. This document describes the MCP configuration for AppAgent commands.


Command Execution Architecture

graph LR
    Agent[AppAgent] --> Dispatcher[CommandDispatcher]
    Dispatcher --> MCPClient[MCP Client]
    MCPClient --> UICollector[UICollector Server]
    MCPClient --> AppUIExecutor[AppUIExecutor Server]
    MCPClient --> COMExecutor[COM Executor Servers]
    MCPClient --> CLIExecutor[CommandLine Executor]
    
    UICollector --> DataCollection[Data Collection<br/>Commands]
    AppUIExecutor --> UIActions[UI Automation<br/>Commands]
    COMExecutor --> APIActions[Application API<br/>Commands]
    CLIExecutor --> ShellActions[Shell<br/>Commands]
    
    style Agent fill:#e3f2fd
    style Dispatcher fill:#fff3e0
    style MCPClient fill:#f1f8e9
    style UICollector fill:#c8e6c9
    style AppUIExecutor fill:#fff9c4
    style COMExecutor fill:#ffccbc
    style CLIExecutor fill:#d1c4e9

!!!note "Dynamic Commands" AppAgent commands are not hardcoded. They are dynamically discovered from configured MCP servers. The available commands depend on:

- **MCP server configuration** in `config/ufo/mcp.yaml`
- **Application context** (e.g., Word, Excel, PowerPoint)
- **Installed MCP servers** (local, HTTP, or stdio)

MCP Server Configuration

Configuration File

AppAgent commands are configured in config/ufo/mcp.yaml:

# Default configuration for all applications
AppAgent:
  default:
    data_collection:
      - namespace: UICollector
        type: local
        start_args: []
        reset: false
    action:
      - namespace: AppUIExecutor
        type: local
        start_args: []
        reset: false
      - namespace: CommandLineExecutor
        type: local
        start_args: []
        reset: false
  
  # Application-specific configurations
  WINWORD.EXE:
    action:
      - namespace: AppUIExecutor
        type: local
      - namespace: WordCOMExecutor
        type: local
        reset: true  # Reset on document switch
  
  EXCEL.EXE:
    action:
      - namespace: AppUIExecutor
        type: local
      - namespace: ExcelCOMExecutor
        type: local
        reset: true
  
  POWERPNT.EXE:
    action:
      - namespace: AppUIExecutor
        type: local
      - namespace: PowerPointCOMExecutor
        type: local
        reset: true
  
  explorer.exe:
    action:
      - namespace: AppUIExecutor
        type: local
      - namespace: PDFReaderExecutor
        type: local
        reset: true

MCP Servers Used by AppAgent

ServerNamespaceTypePurposeCommand Categories
UICollectorUICollectorLocalData collectionScreenshot capture, control detection, UI tree
AppUIExecutorAppUIExecutorLocalUI automationMouse clicks, keyboard input, text entry
CommandLineExecutorCommandLineExecutorLocalShell executionPowerShell, Bash commands
WordCOMExecutorWordCOMExecutorLocalWord automationDocument creation, text manipulation, formatting
ExcelCOMExecutorExcelCOMExecutorLocalExcel automationWorkbook creation, data entry, charts
PowerPointCOMExecutorPowerPointCOMExecutorLocalPowerPoint automationPresentation creation, slides, shapes
PDFReaderExecutorPDFReaderExecutorLocalPDF operationsText extraction, page navigation

When AppAgent works with specific applications (Word, Excel, PowerPoint), additional COM executor servers are automatically loaded to provide native API access alongside UI automation commands. These servers have reset: true to prevent state leakage between documents.


Command Discovery

Listing Available Commands

AppAgent dynamically discovers available commands from MCP servers:

# Get all available tools from MCP servers
result = await command_dispatcher.execute_commands([
    Command(tool_name="list_tools", parameters={})
])

tools = result[0].result
# Returns list of all available commands with their schemas

Command Categories

Commands are categorized by purpose:

CategoryServerExamples
Data CollectionUICollectorcapture_window_screenshot, get_app_window_controls_target_info, get_ui_tree
Mouse ActionsAppUIExecutorclick_input, click_on_coordinates, drag_on_coordinates, wheel_mouse_input
Keyboard ActionsAppUIExecutorset_edit_text, keyboard_input
Data RetrievalAppUIExecutortexts, get_text
Document APIWordCOMExecutorcreate_document, insert_text, save_document
Spreadsheet APIExcelCOMExecutorcreate_workbook, insert_data, create_chart
Presentation APIPowerPointCOMExecutorcreate_presentation, add_slide, insert_shape
Shell ExecutionCommandLineExecutorexecute_command

Command Execution

Execution Flow

sequenceDiagram
    participant Strategy
    participant Executor as ActionExecutor
    participant Dispatcher as CommandDispatcher
    participant MCP as MCP Server
    
    Strategy->>Executor: execute(action_info)
    Executor->>Dispatcher: execute_commands([Command(...)])
    Dispatcher->>MCP: Invoke tool
    MCP->>MCP: Execute command logic
    MCP-->>Dispatcher: Result
    Dispatcher-->>Executor: Result
    Executor-->>Strategy: Success/Error

Example: Execute UI Command

from aip.messages import Command

# Create command
command = Command(
    tool_name="click_input",
    parameters={
        "id": "12",
        "name": "Export",
        "button": "left",
        "double": False
    },
    tool_type="action",
)

# Execute command
results = await command_dispatcher.execute_commands([command])

# Check result
if results[0].status == "SUCCESS":
    print(f"Command executed: {results[0].result}")

Configuration Resources

For detailed MCP configuration, server setup, and command reference:

Quick References:

Configuration Guides:

Server Type Documentation:

Detailed Server Documentation

Each MCP server has comprehensive documentation:

ServerDocumentationCommand Details
UICollectorUICollector ServerScreenshot, control detection, UI tree commands
AppUIExecutorAppUIExecutor ServerUI automation commands with parameters
WordCOMExecutorWord COM ExecutorMicrosoft Word API commands
ExcelCOMExecutorExcel COM ExecutorMicrosoft Excel API commands
PowerPointCOMExecutorPowerPoint COM ExecutorMicrosoft PowerPoint API commands
PDFReaderExecutorPDF Reader ExecutorPDF reading commands
CommandLineExecutorCommandLine ExecutorShell command execution

!!!warning "Command Details Subject to Change" Specific command parameters, names, and behaviors may change as MCP servers evolve. Always refer to the server-specific documentation for the most up-to-date command reference.


Agent Configuration Settings

AppAgent Configuration

# config/ufo/app_agent_config.yaml
system:
  # Control detection backend
  control_backend:
    - "uia"  # Windows UI Automation
    - "omniparser"  # Vision-based detection
  
  # Screenshot settings
  save_full_screen: true  # Also capture desktop
  save_ui_tree: true  # Save UI tree JSON
  include_last_screenshot: true  # Include previous step
  concat_screenshot: true  # Concatenate clean + annotated
  
  # Window behavior
  maximize_window: false  # Maximize on selection
  show_visual_outline_on_screen: true  # Draw red outline

See Configuration Overview and System Configuration for complete configuration options.


Architecture & Design:

Core Features:


Summary

Key Takeaways:

MCP-Based: All commands provided by MCP servers configured in mcp.yaml
Dynamic Discovery: Commands discovered at runtime via list_tools
Application-Specific: COM executors auto-loaded for Word, Excel, PowerPoint
Hybrid Approach: UI automation + native API commands
Configurable: Extensive MCP server configuration options
Documented: Each server has detailed command reference

!!!warning "Command Details Subject to Change" Specific command parameters, names, and behaviors may change as MCP servers evolve. Always refer to the server-specific documentation for the most up-to-date command reference.

Next Steps:

  1. Review MCP Configuration: MCP Configuration Reference
  2. Explore Server Documentation: Click server links above for command details
  3. Understand Processing: Processing Strategy shows commands in action
  4. Learn State Machine: State Machine explains when commands execute