# varunsood189/a27-directory-agent architecture

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

- Interactive diagram: https://gitdiagram.com/varunsood189/a27-directory-agent
- Repository: https://github.com/varunsood189/a27-directory-agent

## Overview

This is a rule-based AgentSwitch Directory agent, not a general CRM: a user request is classified, then the agent either refuses out-of-seat work, identifies duplicate customer-name clusters, or finds an organization and reports people connected through PartyRelationship rows. The CLI supplies configuration and creates an MCP client; the client handles authentication and tool calls to the external Directory service. The README also describes local and official task harnesses, which journal agent results and evaluate them against live MCP data. Edges reflect only shown calls or documented behavior; unsampled branches and harness internals are represented conservatively.

Main entry points: [`src/mcp_client.py`](https://github.com/varunsood189/a27-directory-agent/blob/main/src/mcp_client.py) (MCP client), [`src/directory_agent.py`](https://github.com/varunsood189/a27-directory-agent/blob/main/src/directory_agent.py) (Request handling), [`src/run_agent.py`](https://github.com/varunsood189/a27-directory-agent/blob/main/src/run_agent.py) (Agent CLI), [`harness/run.py`](https://github.com/varunsood189/a27-directory-agent/blob/main/harness/run.py) (Local task runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request entry"]
  node_cli["Agent CLI<br/>[run_agent.py]"]
  node_config["Book settings<br/>[settings.py]"]
end

subgraph group_agent["Directory agent"]
  node_agent_core["Request handling<br/>[directory_agent.py]"]
  node_dedupe["Duplicate matching<br/>[directory_agent.py]"]
  node_company["Organization lookup<br/>[directory_agent.py]"]
  node_relationships["Relationship lookup<br/>[directory_agent.py]"]
end

subgraph group_transport["MCP access"]
  node_mcp["MCP client<br/>[mcp_client.py]"]
end

subgraph group_evaluation["Task evaluation"]
  node_local_harness["Local task runner<br/>[run.py]"]
  node_official_harness["Official runner<br/>[runner.py]"]
  node_predicates["Live-data predicates<br/>[predicates.py]"]
end

node_user(("User"))
node_directory[("AgentSwitch Directory")]

node_user -->|"submits request"| node_cli
node_cli -->|"loads settings"| node_config
node_cli -->|"handles request"| node_agent_core
node_cli -->|"creates client"| node_mcp
node_agent_core -->|"matches names"| node_dedupe
node_agent_core -->|"finds organization"| node_company
node_agent_core -->|"finds contacts"| node_relationships
node_agent_core -->|"calls tools"| node_mcp
node_dedupe -->|"reads parties"| node_mcp
node_company -->|"searches parties"| node_mcp
node_relationships -->|"lists relationships"| node_mcp
node_mcp -->|"sends MCP calls"| node_directory
node_local_harness -->|"runs task"| node_agent_core
node_local_harness -->|"creates client"| node_mcp
node_local_harness -->|"scores results"| node_predicates
node_predicates -->|"checks live rows"| node_mcp
node_official_harness -->|"scores tasks"| node_predicates
node_official_harness -->|"uses client"| node_mcp

click node_cli "https://github.com/varunsood189/a27-directory-agent/blob/main/src/run_agent.py"
click node_config "https://github.com/varunsood189/a27-directory-agent/blob/main/src/settings.py"
click node_agent_core "https://github.com/varunsood189/a27-directory-agent/blob/main/src/directory_agent.py"
click node_dedupe "https://github.com/varunsood189/a27-directory-agent/blob/main/src/directory_agent.py"
click node_company "https://github.com/varunsood189/a27-directory-agent/blob/main/src/directory_agent.py"
click node_relationships "https://github.com/varunsood189/a27-directory-agent/blob/main/src/directory_agent.py"
click node_mcp "https://github.com/varunsood189/a27-directory-agent/blob/main/src/mcp_client.py"
click node_local_harness "https://github.com/varunsood189/a27-directory-agent/blob/main/harness/run.py"
click node_official_harness "https://github.com/varunsood189/a27-directory-agent/blob/main/harness/runner.py"
click node_predicates "https://github.com/varunsood189/a27-directory-agent/blob/main/harness/predicates.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_cli,node_config,node_user toneBlue
class node_agent_core,node_dedupe,node_company,node_relationships,node_directory toneAmber
class node_mcp toneMint
class node_local_harness,node_official_harness,node_predicates toneRose
```

## Components

### Request entry

- [Agent CLI](https://github.com/varunsood189/a27-directory-agent/blob/main/src/run_agent.py): `src/run_agent.py`
- [Book settings](https://github.com/varunsood189/a27-directory-agent/blob/main/src/settings.py): `src/settings.py`

### Directory agent

- [Request handling](https://github.com/varunsood189/a27-directory-agent/blob/main/src/directory_agent.py): `src/directory_agent.py`
- [Duplicate matching](https://github.com/varunsood189/a27-directory-agent/blob/main/src/directory_agent.py): `src/directory_agent.py`
- [Organization lookup](https://github.com/varunsood189/a27-directory-agent/blob/main/src/directory_agent.py): `src/directory_agent.py`
- [Relationship lookup](https://github.com/varunsood189/a27-directory-agent/blob/main/src/directory_agent.py): `src/directory_agent.py`

### MCP access

- [MCP client](https://github.com/varunsood189/a27-directory-agent/blob/main/src/mcp_client.py): `src/mcp_client.py`

### Task evaluation

- [Local task runner](https://github.com/varunsood189/a27-directory-agent/blob/main/harness/run.py): `harness/run.py`
- [Official runner](https://github.com/varunsood189/a27-directory-agent/blob/main/harness/runner.py): `harness/runner.py`
- [Live-data predicates](https://github.com/varunsood189/a27-directory-agent/blob/main/harness/predicates.py): `harness/predicates.py`

### Other components

- **User**
- **AgentSwitch Directory**

## Connections

- User → Agent CLI: submits request (evidence: `README.md`)
- Agent CLI → Book settings: loads settings (evidence: `src/run_agent.py`)
- Agent CLI → Request handling: handles request (evidence: `src/run_agent.py`)
- Agent CLI → MCP client: creates client (evidence: `src/run_agent.py`)
- Request handling → Duplicate matching: matches names (evidence: `src/directory_agent.py`)
- Request handling → Organization lookup: finds organization (evidence: `src/directory_agent.py`)
- Request handling → Relationship lookup: finds contacts (evidence: `src/directory_agent.py`)
- Request handling → MCP client: calls tools (evidence: `src/directory_agent.py`)
- Duplicate matching → MCP client: reads parties (evidence: `src/directory_agent.py`)
- Organization lookup → MCP client: searches parties (evidence: `src/directory_agent.py`)
- Relationship lookup → MCP client: lists relationships (evidence: `src/directory_agent.py`)
- MCP client → AgentSwitch Directory: sends MCP calls (evidence: `src/mcp_client.py`)
- Local task runner → Request handling: runs task (evidence: `harness/run.py`)
- Local task runner → MCP client: creates client (evidence: `harness/run.py`)
- Local task runner → Live-data predicates: scores results (evidence: `harness/run.py`)
- Live-data predicates → MCP client: checks live rows (evidence: `harness/predicates.py`)
- Official runner → Live-data predicates: scores tasks (evidence: `harness/runner.py`)
- Official runner → MCP client: uses client (evidence: `harness/runner.py`)
