Skip to main content
Glama
SQLite MCP Server

SQLite MCP Server

by aktnk
README.md
# sqlite-mcp-server

A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server that enables MCP-compatible clients (e.g., Claude Desktop) to query and visualize SQLite databases using natural language.

## Features

- **`list_data`** — Execute a SELECT query and return results as JSON
- **`export_csv`** — Execute a SELECT query and return results as CSV
- **`visualize_data`** — Execute a SELECT query and render a bar, line, or scatter chart as a PNG image

## Requirements

- Python 3.12+
- [uv](https://docs.astral.sh/uv/)

## Installation

```bash
git clone https://github.com/aktnk/sqlite-mcp-server.git
cd sqlite-mcp-server
uv sync
```

## MCP Client Setup

Copy `config.sample.json` to `config.json` and update the paths:

```json
{
  "mcpServers": {
    "sqlite-explorer": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/sqlite-mcp-server",
        "run",
        "main.py"
      ],
      "env": {
        "SQLITE_MCP_ALLOWED_DIRS": "/path/to/your/databases"
      }
    }
  }
}
```

Then add the contents to your MCP client's configuration file.

**Claude Desktop:**
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`

## Configuration

| Environment Variable | Default | Description |
|---|---|---|
| `SQLITE_MCP_ALLOWED_DIRS` | Current working directory | Colon-separated list of directories the server is allowed to access (e.g., `/data:/tmp/dbs`) |

## Development

```bash
# Create a sample database for testing
uv run setup_db.py

# Run the server directly
uv run main.py

# Run with MCP Inspector (interactive tool testing)
uv run mcp dev main.py
```

## Security

All database access is strictly read-only. The following protections are in place:

| Layer | What it prevents |
|---|---|
| Read-only connection (`?mode=ro`) | INSERT / UPDATE / DELETE / DROP |
| SQLite authorizer (`set_authorizer`) | ATTACH DATABASE, schema changes, `load_extension` |
| Path validation | Path traversal (`../`), access outside allowed directories, non-`.db` files |
| Row limit (10,000 rows) | Denial-of-service via large result sets |

## License

[MIT License](LICENSE) © 2026 Akira Tanaka

TDQS

A3.6/5.0

Scored across 3 tools

Disambiguation4/5

All three tools execute a SELECT query against the same database, but their output formats are clearly distinct: JSON list, CSV string, and chart image. An agent could still hesitate between list_data and export_csv for simple data retrieval, but the descriptions make the intended use cases reasonably clear.

Naming Consistency5/5

All tool names follow a consistent snake_case verb_noun pattern: list_data, export_csv, visualize_data. There are no mixed conventions or vague names.

Tool Count4/5

Three tools is on the low end but appropriate for a focused read/export/visualize SQLite server. Each tool has a distinct output role, though the surface is minimal.

Completeness3/5

The server covers querying, CSV export, and visualization, but lacks schema/table introspection and any write operations. Agents cannot discover table structures or modify data, which are notable gaps for a general SQLite server.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues