# hkuds/anytool architecture

> Architecture diagram of the GitHub repository hkuds/anytool, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hkuds/anytool
- Repository: https://github.com/hkuds/anytool

## Overview

AnyTool is a universal tool-use layer for AI agents: a task enters through the tool layer, is turned into tool retrieval and execution across available backends, and returns a response. Its major branches include MCP, shell, GUI, and web automation, plus quality-aware selection, recording, and optional remote shell/GUI execution through the local server. The README establishes the product workflow and execution modes; several orchestration and backend files were not excerpted, so those connections are shown as unverified where needed.

Main entry points: [`anytool/grounding/core/grounding_client.py`](https://github.com/hkuds/anytool/blob/main/anytool/grounding/core/grounding_client.py) (Grounding Client), [`anytool/local_server/main.py`](https://github.com/hkuds/anytool/blob/main/anytool/local_server/main.py) (Local Server), [`anytool/tool_layer.py`](https://github.com/hkuds/anytool/blob/main/anytool/tool_layer.py) (Tool Layer), [`anytool/grounding/backends/shell/session.py`](https://github.com/hkuds/anytool/blob/main/anytool/grounding/backends/shell/session.py) (Shell Backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Agent Orchestration"]
  node_layer["Tool Layer<br/>[tool_layer.py]"]
  node_search["Tool Retrieval<br/>[search_tools.py]"]
end

subgraph group_grounding["Grounding Runtime"]
  node_client["Grounding Client"]
  node_session["Session Runtime<br/>[session.py]"]
  node_toolbase["Tool Execution<br/>[base.py]"]
end

subgraph group_backends["Tool Backends"]
  node_mcp["MCP Servers<br/>[client.py]"]
  node_mcpsession["MCP Session<br/>[session.py]"]
  node_installer["MCP Installer<br/>[installer.py]"]
  node_shell["Shell Backend<br/>[session.py]"]
  node_shelllocal["Local Shell<br/>[local_connector.py]"]
  node_gui["GUI Backend"]
  node_web["Web Backend"]
end

subgraph group_operations["Quality and Recording"]
  node_quality["Quality Manager<br/>[manager.py]"]
  node_qualitystore[("Quality Store<br/>[store.py]")]
  node_recording["Recording Manager<br/>[manager.py]"]
  node_recorder["Recorder<br/>[recorder.py]"]
  node_video["Video Capture<br/>[video.py]"]
end

subgraph group_remote["Remote Execution"]
  node_localserver["Local Server<br/>[main.py]"]
  node_health["Server Health<br/>[health_checker.py]"]
  node_features["Feature Checks<br/>[feature_checker.py]"]
  node_platforms["Platform Adapters"]
  node_screenshots["Screenshot Utilities<br/>[screenshot.py]"]
end

node_agent(("Agent or User"))

node_agent -->|"submits task"| node_layer
node_layer -.->|"retrieves tools"| node_search
node_layer -.->|"orchestrates tools"| node_client
node_client -->|"requests candidates"| node_search
node_client -->|"manages sessions"| node_session
node_client -->|"dispatches calls"| node_toolbase
node_search -->|"ranks tools"| node_toolbase
node_client -.->|"selects provider"| node_mcp
node_mcp -->|"creates sessions"| node_mcpsession
node_mcp -->|"checks dependencies"| node_installer
node_mcpsession -->|"extends runtime"| node_session
node_client -.->|"selects provider"| node_shell
node_shell -->|"extends runtime"| node_session
node_shell -->|"runs scripts"| node_shelllocal
node_client -.->|"selects provider"| node_gui
node_client -.->|"selects provider"| node_web
node_quality -->|"persists records"| node_qualitystore
node_search -->|"adjusts ranking"| node_quality
node_toolbase -.->|"records execution"| node_quality
node_layer -.->|"configures recording"| node_recording
node_recording -->|"records steps"| node_recorder
node_recording -->|"controls capture"| node_video
node_agent -->|"starts service"| node_localserver
node_localserver -->|"checks health"| node_health
node_localserver -->|"checks features"| node_features
node_localserver -->|"routes platform work"| node_platforms
node_screenshots -->|"uses adapters"| node_platforms
node_shell -.->|"uses HTTP mode"| node_localserver
node_gui -.->|"uses HTTP mode"| node_localserver

click node_layer "https://github.com/hkuds/anytool/blob/main/anytool/tool_layer.py"
click node_search "https://github.com/hkuds/anytool/blob/main/anytool/grounding/core/search_tools.py"
click node_client "https://github.com/hkuds/anytool/blob/main/anytool/grounding/core/grounding_client.py"
click node_session "https://github.com/hkuds/anytool/blob/main/anytool/grounding/core/session.py"
click node_toolbase "https://github.com/hkuds/anytool/blob/main/anytool/grounding/core/tool/base.py"
click node_mcp "https://github.com/hkuds/anytool/blob/main/anytool/grounding/backends/mcp/client.py"
click node_mcpsession "https://github.com/hkuds/anytool/blob/main/anytool/grounding/backends/mcp/session.py"
click node_installer "https://github.com/hkuds/anytool/blob/main/anytool/grounding/backends/mcp/installer.py"
click node_shell "https://github.com/hkuds/anytool/blob/main/anytool/grounding/backends/shell/session.py"
click node_shelllocal "https://github.com/hkuds/anytool/blob/main/anytool/grounding/backends/shell/transport/local_connector.py"
click node_gui "https://github.com/hkuds/anytool/tree/main/anytool/grounding/backends/gui"
click node_web "https://github.com/hkuds/anytool/tree/main/anytool/grounding/backends/web"
click node_quality "https://github.com/hkuds/anytool/blob/main/anytool/grounding/core/quality/manager.py"
click node_qualitystore "https://github.com/hkuds/anytool/blob/main/anytool/grounding/core/quality/store.py"
click node_recording "https://github.com/hkuds/anytool/blob/main/anytool/recording/manager.py"
click node_recorder "https://github.com/hkuds/anytool/blob/main/anytool/recording/recorder.py"
click node_video "https://github.com/hkuds/anytool/blob/main/anytool/recording/video.py"
click node_localserver "https://github.com/hkuds/anytool/blob/main/anytool/local_server/main.py"
click node_health "https://github.com/hkuds/anytool/blob/main/anytool/local_server/health_checker.py"
click node_features "https://github.com/hkuds/anytool/blob/main/anytool/local_server/feature_checker.py"
click node_platforms "https://github.com/hkuds/anytool/tree/main/anytool/local_server/platform_adapters"
click node_screenshots "https://github.com/hkuds/anytool/blob/main/anytool/local_server/utils/screenshot.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_layer,node_search,node_agent toneBlue
class node_client,node_session,node_toolbase toneAmber
class node_mcp,node_mcpsession,node_installer,node_shell,node_shelllocal,node_gui,node_web toneMint
class node_quality,node_qualitystore,node_recording,node_recorder,node_video toneRose
class node_localserver,node_health,node_features,node_platforms,node_screenshots toneIndigo
```

## Components

### Agent Orchestration

- [Tool Layer](https://github.com/hkuds/anytool/blob/main/anytool/tool_layer.py): `anytool/tool_layer.py`
- [Tool Retrieval](https://github.com/hkuds/anytool/blob/main/anytool/grounding/core/search_tools.py): `anytool/grounding/core/search_tools.py`

### Grounding Runtime

- [Grounding Client](https://github.com/hkuds/anytool/blob/main/anytool/grounding/core/grounding_client.py): `anytool/grounding/core/grounding_client.py`
- [Session Runtime](https://github.com/hkuds/anytool/blob/main/anytool/grounding/core/session.py): `anytool/grounding/core/session.py`
- [Tool Execution](https://github.com/hkuds/anytool/blob/main/anytool/grounding/core/tool/base.py): `anytool/grounding/core/tool/base.py`

### Tool Backends

- [MCP Servers](https://github.com/hkuds/anytool/blob/main/anytool/grounding/backends/mcp/client.py): `anytool/grounding/backends/mcp/client.py`
- [MCP Session](https://github.com/hkuds/anytool/blob/main/anytool/grounding/backends/mcp/session.py): `anytool/grounding/backends/mcp/session.py`
- [MCP Installer](https://github.com/hkuds/anytool/blob/main/anytool/grounding/backends/mcp/installer.py): `anytool/grounding/backends/mcp/installer.py`
- [Shell Backend](https://github.com/hkuds/anytool/blob/main/anytool/grounding/backends/shell/session.py): `anytool/grounding/backends/shell/session.py`
- [Local Shell](https://github.com/hkuds/anytool/blob/main/anytool/grounding/backends/shell/transport/local_connector.py): `anytool/grounding/backends/shell/transport/local_connector.py`
- [GUI Backend](https://github.com/hkuds/anytool/tree/main/anytool/grounding/backends/gui): `anytool/grounding/backends/gui`
- [Web Backend](https://github.com/hkuds/anytool/tree/main/anytool/grounding/backends/web): `anytool/grounding/backends/web`

### Quality and Recording

- [Quality Manager](https://github.com/hkuds/anytool/blob/main/anytool/grounding/core/quality/manager.py): `anytool/grounding/core/quality/manager.py`
- [Quality Store](https://github.com/hkuds/anytool/blob/main/anytool/grounding/core/quality/store.py): `anytool/grounding/core/quality/store.py`
- [Recording Manager](https://github.com/hkuds/anytool/blob/main/anytool/recording/manager.py): `anytool/recording/manager.py`
- [Recorder](https://github.com/hkuds/anytool/blob/main/anytool/recording/recorder.py): `anytool/recording/recorder.py`
- [Video Capture](https://github.com/hkuds/anytool/blob/main/anytool/recording/video.py): `anytool/recording/video.py`

### Remote Execution

- [Local Server](https://github.com/hkuds/anytool/blob/main/anytool/local_server/main.py): `anytool/local_server/main.py`
- [Server Health](https://github.com/hkuds/anytool/blob/main/anytool/local_server/health_checker.py): `anytool/local_server/health_checker.py`
- [Feature Checks](https://github.com/hkuds/anytool/blob/main/anytool/local_server/feature_checker.py): `anytool/local_server/feature_checker.py`
- [Platform Adapters](https://github.com/hkuds/anytool/tree/main/anytool/local_server/platform_adapters): `anytool/local_server/platform_adapters`
- [Screenshot Utilities](https://github.com/hkuds/anytool/blob/main/anytool/local_server/utils/screenshot.py): `anytool/local_server/utils/screenshot.py`

### Other components

- **Agent or User**

## Connections

- Agent or User → Tool Layer: submits task (evidence: `README.md`)
- Tool Layer → Tool Retrieval: retrieves tools
- Tool Layer → Grounding Client: orchestrates tools
- Grounding Client → Tool Retrieval: requests candidates (evidence: `anytool/grounding/core/grounding_client.py`)
- Grounding Client → Session Runtime: manages sessions (evidence: `anytool/grounding/core/grounding_client.py`)
- Grounding Client → Tool Execution: dispatches calls (evidence: `anytool/grounding/core/grounding_client.py`)
- Tool Retrieval → Tool Execution: ranks tools (evidence: `anytool/grounding/core/search_tools.py`)
- Grounding Client → MCP Servers: selects provider
- MCP Servers → MCP Session: creates sessions (evidence: `anytool/grounding/backends/mcp/client.py`)
- MCP Servers → MCP Installer: checks dependencies (evidence: `anytool/grounding/backends/mcp/client.py`)
- MCP Session → Session Runtime: extends runtime (evidence: `anytool/grounding/backends/mcp/session.py`)
- Grounding Client → Shell Backend: selects provider
- Shell Backend → Session Runtime: extends runtime (evidence: `anytool/grounding/backends/shell/session.py`)
- Shell Backend → Local Shell: runs scripts (evidence: `anytool/grounding/backends/shell/session.py`)
- Grounding Client → GUI Backend: selects provider
- Grounding Client → Web Backend: selects provider
- Quality Manager → Quality Store: persists records (evidence: `anytool/grounding/core/quality/manager.py`)
- Tool Retrieval → Quality Manager: adjusts ranking (evidence: `anytool/grounding/core/search_tools.py`)
- Tool Execution → Quality Manager: records execution
- Tool Layer → Recording Manager: configures recording
- Recording Manager → Recorder: records steps (evidence: `anytool/recording/manager.py`)
- Recording Manager → Video Capture: controls capture
- Agent or User → Local Server: starts service (evidence: `README.md`)
- Local Server → Server Health: checks health (evidence: `anytool/local_server/main.py`)
- Local Server → Feature Checks: checks features (evidence: `anytool/local_server/main.py`)
- Local Server → Platform Adapters: routes platform work (evidence: `anytool/local_server/main.py`)
- Screenshot Utilities → Platform Adapters: uses adapters (evidence: `anytool/local_server/utils/screenshot.py`)
- Shell Backend → Local Server: uses HTTP mode (evidence: `README.md`)
- GUI Backend → Local Server: uses HTTP mode (evidence: `README.md`)
