# narayanan1208/mcp-multi-agent-ai-assistant architecture

> Architecture diagram of the GitHub repository narayanan1208/mcp-multi-agent-ai-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/narayanan1208/mcp-multi-agent-ai-assistant
- Repository: https://github.com/narayanan1208/mcp-multi-agent-ai-assistant

## Overview

1. **Repository shape**
   - This is primarily a **Python backend** for an AI assistant, with a **prebuilt static frontend** bundled under `backend/static`.
   - The architecture is centered on a **multi-agent orchestration layer** plus a **tool/data layer** backed by **SQLite**.

2. **Primary request entrypoint**
   - `backend/main.py` is the runtime entrypoint and likely the HTTP application entry used by `uvicorn`.
   - The README shows a single conversational API surface: **`POST /chat`**, which is the main inbound boundary for user requests.

3. **High-level control flow**
   - The intended flow is: **User input → Main Agent → MCP Client → MCP Server → Tool → Database**.
   - This creates a clean separation between **language/intent handling**, **tool invocation**, and **persistent storage**.

4. **Agent orchestration boundary**
   - `backend/agents/main_agent.py` is the coordinator that routes requests to specialized behavior.
   - `backend/agents/planner_agent.py` handles **multi-step workflows**, especially the “plan my day” type of request that combines multiple data sources into one response.

5. **Intent handling**
   - `backend/services/intent_service.py` suggests a dedicated intent-routing layer that classifies or normalizes user messages before agent dispatch.
   - This is the decision point that likely distinguishes task, schedule/calendar, note, and planning requests.

6. **MCP layer as the tool boundary**
   - `backend/mcp/client.py`, `server.py`, and `setup.py` implement a lightweight **Model Context Protocol** style boundary.
   - The purpose of this layer is to keep agents from calling storage/tools directly; instead they invoke structured actions through MCP, improving modularity and making new tools easier to add.

7. **Tooling and persistence**
   - `backend/tools/db_tool.py` is the concrete execution layer for storage operations.
   - The README indicates **SQLite** is the persistent store for tasks, events, and notes, so this tool is the main bridge from assistant actions to durable state.

8. **Session/state management**
   - `backend/state/session_store.py` provides per-session or conversation state, which matters for multi-turn interactions and planning workflows.
   - This likely complements the database by storing ephemeral conversation context separate from persisted user content.

9. **Supported data domains**
   - The system is organized around three user data types: **tasks**, **schedules/events**, and **notes**.
   - The planner agent combines these domains, so the diagram should show them as separate logical sources feeding a higher-level planning workflow.

10. **Frontend delivery**
   - `backend/static/index.html` plus hashed JS/CSS bundles indicate a **compiled frontend app** served by the backend.
   - The backend therefore acts as both an API server and a static asset host, not just a pure JSON service.

11. **Runtime and deployment**
   - The presence of `Dockerfile`, `requirements.txt`, and the README’s `uvicorn main:app --reload` indicate a standard Python ASGI deployment.
   - The project is designed to be container-friendly and deployable to environments like **Docker** or **Cloud Run**.

12. **What to emphasize in an architecture diagram**
   - Show three clear boundaries: **UI**, **Agent Orchestration**, and **Tool/Data Access**.
   - Highlight the **MCP client/server split** as the decoupling mechanism between decision-making and database operations.
   - Make the **planner agent** a special multi-step path that reads from multiple sources before producing a synthesized response.

Main entry points: [`backend/agents/planner_agent.py`](https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/agents/planner_agent.py) (Planner), [`backend/agents/main_agent.py`](https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/agents/main_agent.py) (Main agent), [`backend/main.py`](https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/main.py) (Main app), [`backend/mcp/client.py`](https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/mcp/client.py) (MCP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["UI"]
  node_frontend["Frontend<br/>static app<br/>[index.html]"]
end

subgraph group_app["Backend"]
  node_main_app["Main app<br/>ASGI app<br/>[main.py]"]
  node_intent_service["Intent router<br/>routing service<br/>[intent_service.py]"]
  node_main_agent["Main agent<br/>orchestrator<br/>[main_agent.py]"]
  node_planner_agent["Planner<br/>workflow agent<br/>[planner_agent.py]"]
end

subgraph group_mcp["MCP"]
  node_mcp_client["MCP client<br/>tool client<br/>[client.py]"]
  node_mcp_server["MCP server<br/>tool server<br/>[server.py]"]
  node_mcp_setup["MCP setup<br/>bootstrap<br/>[setup.py]"]
end

subgraph group_data["Data"]
  node_session_store[("Session store<br/>conversation state<br/>[session_store.py]")]
  node_db_tool["DB tool<br/>storage tool<br/>[db_tool.py]"]
  node_sqlite_store[("SQLite store<br/>database")]
  node_tasks["Tasks<br/>data domain"]
  node_events["Events<br/>data domain"]
  node_notes["Notes<br/>data domain"]
end

node_frontend -->|"chat UI"| node_main_app
node_main_app -->|"route"| node_intent_service
node_intent_service -->|"dispatch"| node_main_agent
node_main_app -->|"state"| node_session_store
node_main_agent -->|"context"| node_session_store
node_main_agent -->|"tools"| node_mcp_client
node_planner_agent -->|"tools"| node_mcp_client
node_main_agent -.->|"plan flow"| node_planner_agent
node_mcp_client -->|"call"| node_mcp_server
node_mcp_setup -->|"bootstrap"| node_mcp_server
node_mcp_server -->|"invoke"| node_db_tool
node_db_tool -->|"persist"| node_sqlite_store
node_sqlite_store -->|"stores"| node_tasks
node_sqlite_store -->|"stores"| node_events
node_sqlite_store -->|"stores"| node_notes
node_planner_agent -.->|"reads"| node_tasks
node_planner_agent -.->|"reads"| node_events
node_planner_agent -.->|"reads"| node_notes

click node_frontend "https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/static/index.html"
click node_main_app "https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/main.py"
click node_intent_service "https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/services/intent_service.py"
click node_main_agent "https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/agents/main_agent.py"
click node_planner_agent "https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/agents/planner_agent.py"
click node_session_store "https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/state/session_store.py"
click node_mcp_client "https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/mcp/client.py"
click node_mcp_server "https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/mcp/server.py"
click node_mcp_setup "https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/mcp/setup.py"
click node_db_tool "https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/tools/db_tool.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_frontend toneBlue
class node_main_app,node_intent_service,node_main_agent,node_planner_agent toneAmber
class node_mcp_client,node_mcp_server,node_mcp_setup toneMint
class node_session_store,node_db_tool,node_sqlite_store,node_tasks,node_events,node_notes toneRose
```

## Components

### UI

Prebuilt static frontend served by the backend

- [Frontend](https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/static/index.html): static app · Compiled UI bundle served from backend/static · `backend/static/index.html`

### Backend

HTTP entrypoint and agent orchestration

- [Main app](https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/main.py): ASGI app · Runtime entrypoint and HTTP surface for chat requests · `backend/main.py`
- [Intent router](https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/services/intent_service.py): routing service · Classifies and normalizes user requests before agent dispatch · `backend/services/intent_service.py`
- [Main agent](https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/agents/main_agent.py): orchestrator · Primary conversational coordinator · `backend/agents/main_agent.py`
- [Planner](https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/agents/planner_agent.py): workflow agent · Handles multi-step planning and synthesis across sources · `backend/agents/planner_agent.py`

### MCP

Structured tool boundary between agents and execution

- [MCP client](https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/mcp/client.py): tool client · Agent-side client for structured tool calls · `backend/mcp/client.py`
- [MCP server](https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/mcp/server.py): tool server · Server-side boundary for invoking tools · `backend/mcp/server.py`
- [MCP setup](https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/mcp/setup.py): bootstrap · Initializes the MCP tool boundary · `backend/mcp/setup.py`

### Data

Persistent and conversational state

- [Session store](https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/state/session_store.py): conversation state · Per-session or per-conversation ephemeral state · `backend/state/session_store.py`
- [DB tool](https://github.com/narayanan1208/mcp-multi-agent-ai-assistant/blob/main/backend/tools/db_tool.py): storage tool · Concrete execution layer for persistence actions · `backend/tools/db_tool.py`
- **SQLite store**: database · Persistent store for tasks, events, and notes
- **Tasks**: data domain · Task records and task-related state
- **Events**: data domain · Schedule and calendar records
- **Notes**: data domain · Note records and captured content

## Connections

- Frontend → Main app: chat UI · User actions reach the backend via the conversational API
- Main app → Intent router: route · Incoming requests are normalized and classified
- Intent router → Main agent: dispatch · Intent classification selects the main conversational path
- Main app → Session store: state · Conversation state is loaded and updated per session
- Main agent → Session store: context · The agent reads and updates dialogue context
- Main agent → MCP client: tools · The agent invokes external actions through MCP
- Planner → MCP client: tools · Planning workflows use the same structured tool boundary
- Main agent → Planner: plan flow · Specialized planning requests are delegated to the planner
- MCP client → MCP server: call · Client-server split decouples reasoning from execution
- MCP setup → MCP server: bootstrap · MCP wiring prepares the tool server at runtime
- MCP server → DB tool: invoke · Structured actions are translated into storage operations
- DB tool → SQLite store: persist · Tool writes to and reads from SQLite-backed storage
- SQLite store → Tasks: stores · Task domain data is persisted in the database
- SQLite store → Events: stores · Event and schedule data is persisted in the database
- SQLite store → Notes: stores · Notes are persisted in the database
- Planner → Tasks: reads · Planning combines task state with other sources
- Planner → Events: reads · Planning considers schedule availability
- Planner → Notes: reads · Planning can incorporate note content
