# limiajayi/agent-harness architecture

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

- Interactive diagram: https://gitdiagram.com/limiajayi/agent-harness
- Repository: https://github.com/limiajayi/agent-harness
- Video tour (about a minute): https://gitdiagram.com/limiajayi/agent-harness/video

## Overview

Agent Harness is a terminal coding agent: a user submits a prompt, the selected model may request tools, the harness executes approved tools, and their results return to the model for a response. Built-in tools inspect and modify a workspace; optional MCP servers add GitHub and Exa capabilities through a stdio client. The graph reflects the README workflow and the sampled entry point, agent, provider, and MCP code; several tool implementations and MCP configuration details were not sampled, so their internal links are limited to documented relationships.

Main entry points: [`src/index.ts`](https://github.com/limiajayi/agent-harness/blob/main/src/index.ts) (CLI setup), [`src/agent.ts`](https://github.com/limiajayi/agent-harness/blob/main/src/agent.ts) (Agent loop), [`src/provider.ts`](https://github.com/limiajayi/agent-harness/blob/main/src/provider.ts) (Provider factory and types), [`src/tools/edit_file.ts`](https://github.com/limiajayi/agent-harness/blob/main/src/tools/edit_file.ts) (Edit file)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Agent orchestration"]
  node_entry["CLI setup<br/>[index.ts]"]
  node_agent["Agent loop<br/>[agent.ts]"]
  node_shared["Input and workspace config<br/>[shared.ts]"]
end

subgraph group_models["Model providers"]
  node_provider_api["Provider factory and types<br/>[provider.ts]"]
  node_ollama["Ollama model<br/>[ollama.ts]"]
  node_gemini["Gemini model<br/>[gemini.ts]"]
  node_claude["Claude model<br/>[claude.ts]"]
end

subgraph group_workspace_tools["Workspace tools"]
  node_read_file["Read file<br/>[read_file.ts]"]
  node_list_files["List files<br/>[list_files.ts]"]
  node_bash["Shell command<br/>[bash_tool.ts]"]
  node_edit_file["Edit file<br/>[edit_file.ts]"]
  node_code_search["Code search<br/>[code_search.ts]"]
  node_paths["Workspace path guard<br/>[paths.ts]"]
  node_workspace["Project files"]
end

subgraph group_mcp["MCP integrations"]
  node_mcp_config["Server configuration<br/>[config.ts]"]
  node_mcp_manager["Server manager<br/>[manager.ts]"]
  node_mcp_adapter["Tool adapter<br/>[adapter.ts]"]
  node_mcp_client["Stdio JSON-RPC client<br/>[client.ts]"]
end

node_user(("User"))
node_github{{"GitHub MCP server"}}
node_exa{{"Exa MCP server"}}

node_user -->|"starts session"| node_entry
node_entry -->|"creates model"| node_provider_api
node_provider_api -->|"selects provider"| node_ollama
node_provider_api -->|"selects provider"| node_gemini
node_provider_api -->|"selects provider"| node_claude
node_entry -->|"creates input reader"| node_shared
node_entry -->|"builds server configs"| node_mcp_config
node_entry -->|"starts servers"| node_mcp_manager
node_entry -->|"starts agent"| node_agent
node_entry -->|"registers tool"| node_read_file
node_entry -->|"registers tool"| node_list_files
node_entry -->|"registers tool"| node_bash
node_entry -->|"registers tool"| node_edit_file
node_entry -->|"registers tool"| node_code_search
node_entry -->|"passes MCP tools"| node_agent
node_user -->|"provides prompts"| node_agent
node_agent -->|"requests completion"| node_provider_api
node_agent -->|"executes tool"| node_read_file
node_agent -->|"executes tool"| node_list_files
node_agent -->|"executes tool"| node_bash
node_agent -->|"executes tool"| node_edit_file
node_agent -->|"executes tool"| node_code_search
node_read_file -->|"reads files"| node_workspace
node_list_files -->|"lists files"| node_workspace
node_bash -->|"runs commands"| node_workspace
node_edit_file -->|"validates paths"| node_paths
node_edit_file -->|"writes files"| node_workspace
node_code_search -->|"validates paths"| node_paths
node_code_search -->|"searches files"| node_workspace
node_mcp_manager -->|"starts and queries"| node_mcp_client
node_mcp_manager -->|"converts tools"| node_mcp_adapter
node_mcp_adapter -->|"calls remote tool"| node_mcp_client
node_mcp_client -->|"stdio JSON-RPC"| node_github
node_mcp_client -->|"stdio JSON-RPC"| node_exa
node_mcp_config -->|"configures launch"| node_github
node_mcp_config -->|"configures launch"| node_exa

click node_entry "https://github.com/limiajayi/agent-harness/blob/main/src/index.ts"
click node_agent "https://github.com/limiajayi/agent-harness/blob/main/src/agent.ts"
click node_shared "https://github.com/limiajayi/agent-harness/blob/main/src/shared.ts"
click node_provider_api "https://github.com/limiajayi/agent-harness/blob/main/src/provider.ts"
click node_ollama "https://github.com/limiajayi/agent-harness/blob/main/src/providers/ollama.ts"
click node_gemini "https://github.com/limiajayi/agent-harness/blob/main/src/providers/gemini.ts"
click node_claude "https://github.com/limiajayi/agent-harness/blob/main/src/providers/claude.ts"
click node_read_file "https://github.com/limiajayi/agent-harness/blob/main/src/tools/read_file.ts"
click node_list_files "https://github.com/limiajayi/agent-harness/blob/main/src/tools/list_files.ts"
click node_bash "https://github.com/limiajayi/agent-harness/blob/main/src/tools/bash_tool.ts"
click node_edit_file "https://github.com/limiajayi/agent-harness/blob/main/src/tools/edit_file.ts"
click node_code_search "https://github.com/limiajayi/agent-harness/blob/main/src/tools/code_search.ts"
click node_paths "https://github.com/limiajayi/agent-harness/blob/main/src/tools/paths.ts"
click node_mcp_config "https://github.com/limiajayi/agent-harness/blob/main/src/mcp/config.ts"
click node_mcp_manager "https://github.com/limiajayi/agent-harness/blob/main/src/mcp/manager.ts"
click node_mcp_adapter "https://github.com/limiajayi/agent-harness/blob/main/src/mcp/adapter.ts"
click node_mcp_client "https://github.com/limiajayi/agent-harness/blob/main/src/mcp/client.ts"

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_entry,node_agent,node_shared,node_user toneBlue
class node_provider_api,node_ollama,node_gemini,node_claude toneAmber
class node_read_file,node_list_files,node_bash,node_edit_file,node_code_search,node_paths,node_workspace,node_github,node_exa toneMint
class node_mcp_config,node_mcp_manager,node_mcp_adapter,node_mcp_client toneRose
```

## Components

### Agent orchestration

- [CLI setup](https://github.com/limiajayi/agent-harness/blob/main/src/index.ts): `src/index.ts`
- [Agent loop](https://github.com/limiajayi/agent-harness/blob/main/src/agent.ts): `src/agent.ts`
- [Input and workspace config](https://github.com/limiajayi/agent-harness/blob/main/src/shared.ts): `src/shared.ts`

### Model providers

- [Provider factory and types](https://github.com/limiajayi/agent-harness/blob/main/src/provider.ts): `src/provider.ts`
- [Ollama model](https://github.com/limiajayi/agent-harness/blob/main/src/providers/ollama.ts): `src/providers/ollama.ts`
- [Gemini model](https://github.com/limiajayi/agent-harness/blob/main/src/providers/gemini.ts): `src/providers/gemini.ts`
- [Claude model](https://github.com/limiajayi/agent-harness/blob/main/src/providers/claude.ts): `src/providers/claude.ts`

### Workspace tools

- [Read file](https://github.com/limiajayi/agent-harness/blob/main/src/tools/read_file.ts): `src/tools/read_file.ts`
- [List files](https://github.com/limiajayi/agent-harness/blob/main/src/tools/list_files.ts): `src/tools/list_files.ts`
- [Shell command](https://github.com/limiajayi/agent-harness/blob/main/src/tools/bash_tool.ts): `src/tools/bash_tool.ts`
- [Edit file](https://github.com/limiajayi/agent-harness/blob/main/src/tools/edit_file.ts): `src/tools/edit_file.ts`
- [Code search](https://github.com/limiajayi/agent-harness/blob/main/src/tools/code_search.ts): `src/tools/code_search.ts`
- [Workspace path guard](https://github.com/limiajayi/agent-harness/blob/main/src/tools/paths.ts): `src/tools/paths.ts`
- **Project files**

### MCP integrations

- [Server configuration](https://github.com/limiajayi/agent-harness/blob/main/src/mcp/config.ts): `src/mcp/config.ts`
- [Server manager](https://github.com/limiajayi/agent-harness/blob/main/src/mcp/manager.ts): `src/mcp/manager.ts`
- [Tool adapter](https://github.com/limiajayi/agent-harness/blob/main/src/mcp/adapter.ts): `src/mcp/adapter.ts`
- [Stdio JSON-RPC client](https://github.com/limiajayi/agent-harness/blob/main/src/mcp/client.ts): `src/mcp/client.ts`

### Other components

- **User**
- **GitHub MCP server**
- **Exa MCP server**

## Connections

- User → CLI setup: starts session (evidence: `README.md`)
- CLI setup → Provider factory and types: creates model (evidence: `src/index.ts`)
- Provider factory and types → Ollama model: selects provider (evidence: `src/provider.ts`)
- Provider factory and types → Gemini model: selects provider (evidence: `src/provider.ts`)
- Provider factory and types → Claude model: selects provider (evidence: `src/provider.ts`)
- CLI setup → Input and workspace config: creates input reader (evidence: `src/index.ts`)
- CLI setup → Server configuration: builds server configs (evidence: `src/index.ts`)
- CLI setup → Server manager: starts servers (evidence: `src/index.ts`)
- CLI setup → Agent loop: starts agent (evidence: `src/index.ts`)
- CLI setup → Read file: registers tool (evidence: `src/index.ts`)
- CLI setup → List files: registers tool (evidence: `src/index.ts`)
- CLI setup → Shell command: registers tool (evidence: `src/index.ts`)
- CLI setup → Edit file: registers tool (evidence: `src/index.ts`)
- CLI setup → Code search: registers tool (evidence: `src/index.ts`)
- CLI setup → Agent loop: passes MCP tools (evidence: `README.md`)
- User → Agent loop: provides prompts (evidence: `src/agent.ts`)
- Agent loop → Provider factory and types: requests completion (evidence: `src/agent.ts`)
- Agent loop → Read file: executes tool (evidence: `README.md`)
- Agent loop → List files: executes tool (evidence: `README.md`)
- Agent loop → Shell command: executes tool (evidence: `README.md`)
- Agent loop → Edit file: executes tool (evidence: `src/index.ts`)
- Agent loop → Code search: executes tool (evidence: `src/index.ts`)
- Read file → Project files: reads files (evidence: `README.md`)
- List files → Project files: lists files (evidence: `README.md`)
- Shell command → Project files: runs commands (evidence: `README.md`)
- Edit file → Workspace path guard: validates paths (evidence: `src/tools/edit_file.ts`)
- Edit file → Project files: writes files (evidence: `src/tools/edit_file.ts`)
- Code search → Workspace path guard: validates paths (evidence: `src/tools/code_search.ts`)
- Code search → Project files: searches files (evidence: `src/tools/code_search.ts`)
- Server manager → Stdio JSON-RPC client: starts and queries (evidence: `src/mcp/manager.ts`)
- Server manager → Tool adapter: converts tools (evidence: `src/mcp/manager.ts`)
- Tool adapter → Stdio JSON-RPC client: calls remote tool (evidence: `src/mcp/adapter.ts`)
- Stdio JSON-RPC client → GitHub MCP server: stdio JSON-RPC (evidence: `README.md`)
- Stdio JSON-RPC client → Exa MCP server: stdio JSON-RPC (evidence: `README.md`)
- Server configuration → GitHub MCP server: configures launch (evidence: `README.md`)
- Server configuration → Exa MCP server: configures launch (evidence: `README.md`)
