# shivangbhatt10/mysql-automation-mcp-server architecture

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

- Interactive diagram: https://gitdiagram.com/shivangbhatt10/mysql-automation-mcp-server
- Repository: https://github.com/shivangbhatt10/mysql-automation-mcp-server

## Overview

This repository is a FastMCP server that exposes MySQL administration, schema exploration, guarded SQL execution, exports, and query-history tools to agent clients. The main workflow is an MCP request handled by the server, which applies safety checks where relevant and uses the connection pool to operate on MySQL; schema inspection and query auditing add supporting paths. README documents additional tools, resources, prompts, caching, and runtime reconfiguration. Some server sections were omitted, so edges for documented capabilities rely on the README rather than unsampled implementation details.

Main entry points: [`src/mysql_mcp/server.py`](https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/server.py) (MCP tools and resources), [`src/mysql_mcp/db.py`](https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/db.py) (Connection pool and transactions), [`src/mysql_mcp/config.py`](https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/config.py) (Runtime configuration), [`src/mysql_mcp/audit.py`](https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/audit.py) (Query history)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["MCP interface"]
  node_server["MCP tools and resources<br/>[server.py]"]
  node_prompts["SQL prompts<br/>[server.py]"]
end

subgraph group_query["Query controls"]
  node_safety["SQL safety rules<br/>[safety.py]"]
  node_diagnostics["Error diagnostics<br/>[errors.py]"]
end

subgraph group_state["Configuration and history"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_audit[("Query history<br/>[audit.py]")]
end

subgraph group_mysql["MySQL access"]
  node_schema["Schema introspection and cache<br/>[schema.py]"]
  node_pool["Connection pool and transactions<br/>[db.py]"]
end

node_client(("Agent client"))
node_database[("MySQL instance")]

node_client -->|"invokes tools"| node_server
node_client -->|"requests prompts"| node_prompts
node_server -->|"validates queries"| node_safety
node_server -->|"executes queries"| node_pool
node_server -->|"requests schema"| node_schema
node_server -->|"records queries"| node_audit
node_server -->|"reconfigures settings"| node_config
node_pool -->|"queries and mutates"| node_database
node_schema -->|"introspects database"| node_pool
node_audit -->|"reads log settings"| node_config
node_pool -->|"loads connection settings"| node_config
node_pool -->|"translates errors"| node_diagnostics
node_server -.->|"reports database errors"| node_diagnostics

click node_server "https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/server.py"
click node_prompts "https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/server.py"
click node_safety "https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/safety.py"
click node_diagnostics "https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/errors.py"
click node_config "https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/config.py"
click node_audit "https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/audit.py"
click node_schema "https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/schema.py"
click node_pool "https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/db.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_prompts,node_client toneBlue
class node_safety,node_diagnostics,node_database toneAmber
class node_config,node_audit toneMint
class node_schema,node_pool toneRose
```

## Components

### MCP interface

- [MCP tools and resources](https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/server.py): `src/mysql_mcp/server.py`
- [SQL prompts](https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/server.py): `src/mysql_mcp/server.py`

### Query controls

- [SQL safety rules](https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/safety.py): `src/mysql_mcp/safety.py`
- [Error diagnostics](https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/errors.py): `src/mysql_mcp/errors.py`

### Configuration and history

- [Runtime configuration](https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/config.py): `src/mysql_mcp/config.py`
- [Query history](https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/audit.py): `src/mysql_mcp/audit.py`

### MySQL access

- [Schema introspection and cache](https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/schema.py): `src/mysql_mcp/schema.py`
- [Connection pool and transactions](https://github.com/shivangbhatt10/mysql-automation-mcp-server/blob/main/src/mysql_mcp/db.py): `src/mysql_mcp/db.py`

### Other components

- **Agent client**
- **MySQL instance**

## Connections

- Agent client → MCP tools and resources: invokes tools (evidence: `README.md`)
- Agent client → SQL prompts: requests prompts (evidence: `README.md`)
- MCP tools and resources → SQL safety rules: validates queries (evidence: `src/mysql_mcp/server.py`)
- MCP tools and resources → Connection pool and transactions: executes queries (evidence: `src/mysql_mcp/server.py`)
- MCP tools and resources → Schema introspection and cache: requests schema (evidence: `README.md`)
- MCP tools and resources → Query history: records queries (evidence: `src/mysql_mcp/server.py`)
- MCP tools and resources → Runtime configuration: reconfigures settings (evidence: `README.md`)
- Connection pool and transactions → MySQL instance: queries and mutates (evidence: `src/mysql_mcp/db.py`)
- Schema introspection and cache → Connection pool and transactions: introspects database (evidence: `src/mysql_mcp/schema.py`)
- Query history → Runtime configuration: reads log settings (evidence: `src/mysql_mcp/audit.py`)
- Connection pool and transactions → Runtime configuration: loads connection settings (evidence: `src/mysql_mcp/db.py`)
- Connection pool and transactions → Error diagnostics: translates errors (evidence: `src/mysql_mcp/db.py`)
- MCP tools and resources → Error diagnostics: reports database errors (evidence: `src/mysql_mcp/server.py`)
