# latentforce-ai/latentgraph-mcp-server architecture

> Architecture diagram of the GitHub repository latentforce-ai/latentgraph-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/latentforce-ai/latentgraph-mcp-server
- Repository: https://github.com/latentforce-ai/latentgraph-mcp-server

## Overview

Latentgraph is a code-intelligence CLI and MCP server: users initialize or update a project index, then AI coding tools can obtain dependency, implicit-coupling, and change-impact context. The map includes the documented DRG, Wiki, implicit-dependency, file-enrichment, and analysis capabilities, plus daemon-driven tool execution and editor integrations. Several subsystems are represented by their exact enclosing directories because their implementation was not sampled; edges are limited to documented or excerpt-supported wiring.

Main entry points: [`src/mcp-server.ts`](https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/mcp-server.ts) (MCP server), [`src/cli/commands`](https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/cli/commands) (CLI commands), [`src/cli/commands/context.ts`](https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/cli/commands/context.ts) (Context retrieval), [`src/index.ts`](https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/index.ts) (CLI dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflows"]
  node_cli["CLI dispatcher<br/>[index.ts]"]
  node_commands["CLI commands"]
  node_context["Context retrieval<br/>[context.ts]"]
end

subgraph group_analysis["Indexing and insights"]
  node_scanner["Project scanning<br/>[tree-scanner.ts]"]
  node_git["Git change detection<br/>[git-changes.ts]"]
  node_analysis_commands["Index and analysis workflows"]
end

subgraph group_runtime["Daemon and MCP"]
  node_daemon_manager["Daemon lifecycle<br/>[daemon-manager.ts]"]
  node_daemon["Background daemon<br/>[daemon.ts]"]
  node_websocket["WebSocket client"]
  node_executor["MCP tool execution<br/>[tools-executor.ts]"]
  node_mcp["MCP server<br/>[mcp-server.ts]"]
end

subgraph group_integrations["Coding-tool integrations"]
  node_claude["Claude integration"]
  node_copilot["Copilot integration"]
  node_cursor["Cursor integration"]
  node_kiro["Kiro integration"]
  node_codex["Codex integration"]
  node_latent_code["latent-code integration"]
  node_opencode["OpenCode integration"]
end

subgraph group_shared["Shared utilities"]
  node_api["Backend API client<br/>[api-client.ts]"]
  node_formatter["Context formatting"]
end

node_user(("Project user"))
node_backend["Latentgraph backend"]
node_assistant(("AI coding assistant"))

node_user -->|"runs commands"| node_cli
node_cli -->|"dispatches"| node_commands
node_commands -->|"invokes workflows"| node_analysis_commands
node_analysis_commands -->|"scans project"| node_scanner
node_analysis_commands -->|"detects changes"| node_git
node_analysis_commands -->|"sends analysis"| node_api
node_api -->|"sends requests"| node_backend
node_commands -->|"invokes context"| node_context
node_context -->|"requests file insights"| node_backend
node_context -->|"formats responses"| node_formatter
node_commands -->|"starts or stops"| node_daemon_manager
node_daemon_manager -->|"launches process"| node_daemon
node_daemon -->|"maintains connection"| node_websocket
node_websocket -->|"dispatches tool requests"| node_executor
node_assistant -->|"requests tools"| node_mcp
node_claude -->|"configures access"| node_mcp
node_copilot -->|"configures access"| node_mcp
node_cursor -->|"configures access"| node_mcp
node_kiro -->|"configures access"| node_mcp
node_codex -->|"configures access"| node_mcp
node_latent_code -->|"configures access"| node_mcp
node_opencode -->|"configures access"| node_mcp

click node_cli "https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/index.ts"
click node_commands "https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/cli/commands"
click node_scanner "https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/utils/tree-scanner.ts"
click node_git "https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/utils/git-changes.ts"
click node_analysis_commands "https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/cli/commands"
click node_api "https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/utils/api-client.ts"
click node_context "https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/cli/commands/context.ts"
click node_formatter "https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/utils/context-formatter.ts"
click node_daemon_manager "https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/daemon/daemon-manager.ts"
click node_daemon "https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/daemon/daemon.ts"
click node_websocket "https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/daemon/websocket-client.ts"
click node_executor "https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/daemon/tools-executor.ts"
click node_mcp "https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/mcp-server.ts"
click node_claude "https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/integration/claude"
click node_copilot "https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/integration/copilot"
click node_cursor "https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/integration/cursor"
click node_kiro "https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/integration/kiro"
click node_codex "https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/integration/codex"
click node_latent_code "https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/integration/latent-code"
click node_opencode "https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/integration/opencode"

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_commands,node_context,node_user toneBlue
class node_scanner,node_git,node_analysis_commands toneAmber
class node_daemon_manager,node_daemon,node_websocket,node_executor,node_mcp toneMint
class node_claude,node_copilot,node_cursor,node_kiro,node_codex,node_latent_code,node_opencode toneRose
class node_api,node_formatter,node_backend,node_assistant toneIndigo
```

## Components

### CLI workflows

- [CLI dispatcher](https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/index.ts): `src/index.ts`
- [CLI commands](https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/cli/commands): `src/cli/commands`
- [Context retrieval](https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/cli/commands/context.ts): `src/cli/commands/context.ts`

### Indexing and insights

- [Project scanning](https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/utils/tree-scanner.ts): `src/utils/tree-scanner.ts`
- [Git change detection](https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/utils/git-changes.ts): `src/utils/git-changes.ts`
- [Index and analysis workflows](https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/cli/commands): `src/cli/commands`

### Daemon and MCP

- [Daemon lifecycle](https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/daemon/daemon-manager.ts): `src/daemon/daemon-manager.ts`
- [Background daemon](https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/daemon/daemon.ts): `src/daemon/daemon.ts`
- [WebSocket client](https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/daemon/websocket-client.ts): `src/daemon/websocket-client.ts`
- [MCP tool execution](https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/daemon/tools-executor.ts): `src/daemon/tools-executor.ts`
- [MCP server](https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/mcp-server.ts): `src/mcp-server.ts`

### Coding-tool integrations

- [Claude integration](https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/integration/claude): `src/integration/claude`
- [Copilot integration](https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/integration/copilot): `src/integration/copilot`
- [Cursor integration](https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/integration/cursor): `src/integration/cursor`
- [Kiro integration](https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/integration/kiro): `src/integration/kiro`
- [Codex integration](https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/integration/codex): `src/integration/codex`
- [latent-code integration](https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/integration/latent-code): `src/integration/latent-code`
- [OpenCode integration](https://github.com/latentforce-ai/latentgraph-mcp-server/tree/main/src/integration/opencode): `src/integration/opencode`

### Shared utilities

- [Backend API client](https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/utils/api-client.ts): `src/utils/api-client.ts`
- [Context formatting](https://github.com/latentforce-ai/latentgraph-mcp-server/blob/main/src/utils/context-formatter.ts): `src/utils/context-formatter.ts`

### Other components

- **Project user**
- **Latentgraph backend**
- **AI coding assistant**

## Connections

- Project user → CLI dispatcher: runs commands
- CLI dispatcher → CLI commands: dispatches
- CLI commands → Index and analysis workflows: invokes workflows
- Index and analysis workflows → Project scanning: scans project
- Index and analysis workflows → Git change detection: detects changes
- Index and analysis workflows → Backend API client: sends analysis
- Backend API client → Latentgraph backend: sends requests
- CLI commands → Context retrieval: invokes context
- Context retrieval → Latentgraph backend: requests file insights
- Context retrieval → Context formatting: formats responses
- CLI commands → Daemon lifecycle: starts or stops
- Daemon lifecycle → Background daemon: launches process
- Background daemon → WebSocket client: maintains connection
- WebSocket client → MCP tool execution: dispatches tool requests
- AI coding assistant → MCP server: requests tools
- Claude integration → MCP server: configures access
- Copilot integration → MCP server: configures access
- Cursor integration → MCP server: configures access
- Kiro integration → MCP server: configures access
- Codex integration → MCP server: configures access
- latent-code integration → MCP server: configures access
- OpenCode integration → MCP server: configures access
