# ccarrott/read-only-sqlite-mcp-server architecture

> Architecture diagram of the GitHub repository ccarrott/read-only-sqlite-mcp-server, 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/ccarrott/read-only-sqlite-mcp-server
- Repository: https://github.com/ccarrott/read-only-sqlite-mcp-server

## Overview

This is a read-only SQLite exploration server exposed to MCP clients over stdio. A client invokes table listing, table description, or bounded SQL-query tools; it can also request a live schema resource or an analysis prompt. FastMCP registration is the runtime entry point, and DatabaseManager performs database access while security checks enforce read-only behavior. The README documents these capabilities and safeguards; sampled source shows registration and database calls, but not every connection or serialization detail.

Main entry points: [`src/sqlite_mcp/db.py`](https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/db.py) (Database Manager), [`src/sqlite_mcp/server.py`](https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/server.py) (Stdio Server), [`src/sqlite_mcp/tools.py`](https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/tools.py) (Inspection Tools), [`src/sqlite_mcp/resources.py`](https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/resources.py) (Schema Resource)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["MCP Runtime"]
  node_server["Stdio Server<br/>[server.py]"]
end

subgraph group_access["Safe Database Access"]
  node_database_manager["Database Manager<br/>[db.py]"]
  node_query_safety["Query Safeguards<br/>[security.py]"]
end

subgraph group_surfaces["Exploration Interfaces"]
  node_tool_api["Inspection Tools<br/>[tools.py]"]
  node_schema_resource["Schema Resource<br/>[resources.py]"]
  node_analysis_prompt["Schema Prompt<br/>[prompts.py]"]
end

node_client(("MCP Client"))
node_sqlite_file[("SQLite Database")]

node_client -->|"connects via stdio"| node_server
node_server -->|"registers tools"| node_tool_api
node_server -->|"registers resource"| node_schema_resource
node_server -->|"registers prompt"| node_analysis_prompt
node_tool_api -->|"calls database operations"| node_database_manager
node_schema_resource -->|"requests schema Markdown"| node_database_manager
node_analysis_prompt -->|"requests schema Markdown"| node_database_manager
node_database_manager -->|"uses SQL validation"| node_query_safety
node_database_manager -->|"reads schema and data"| node_sqlite_file

click node_server "https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/server.py"
click node_tool_api "https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/tools.py"
click node_schema_resource "https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/resources.py"
click node_analysis_prompt "https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/prompts.py"
click node_database_manager "https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/db.py"
click node_query_safety "https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/security.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_server,node_client toneBlue
class node_database_manager,node_query_safety,node_sqlite_file toneAmber
class node_tool_api,node_schema_resource,node_analysis_prompt toneMint
```

## Components

### MCP Runtime

- [Stdio Server](https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/server.py): `src/sqlite_mcp/server.py`

### Safe Database Access

- [Database Manager](https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/db.py): `src/sqlite_mcp/db.py`
- [Query Safeguards](https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/security.py): `src/sqlite_mcp/security.py`

### Exploration Interfaces

- [Inspection Tools](https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/tools.py): `src/sqlite_mcp/tools.py`
- [Schema Resource](https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/resources.py): `src/sqlite_mcp/resources.py`
- [Schema Prompt](https://github.com/ccarrott/read-only-sqlite-mcp-server/blob/main/src/sqlite_mcp/prompts.py): `src/sqlite_mcp/prompts.py`

### Other components

- **MCP Client**
- **SQLite Database**

## Connections

- MCP Client → Stdio Server: connects via stdio (evidence: `README.md`)
- Stdio Server → Inspection Tools: registers tools (evidence: `src/sqlite_mcp/server.py`)
- Stdio Server → Schema Resource: registers resource (evidence: `src/sqlite_mcp/server.py`)
- Stdio Server → Schema Prompt: registers prompt (evidence: `src/sqlite_mcp/server.py`)
- Inspection Tools → Database Manager: calls database operations (evidence: `src/sqlite_mcp/tools.py`)
- Schema Resource → Database Manager: requests schema Markdown (evidence: `src/sqlite_mcp/resources.py`)
- Schema Prompt → Database Manager: requests schema Markdown (evidence: `src/sqlite_mcp/prompts.py`)
- Database Manager → Query Safeguards: uses SQL validation (evidence: `src/sqlite_mcp/db.py`)
- Database Manager → SQLite Database: reads schema and data (evidence: `README.md`)
