MCP HubMCP Hub
hannesrudolph

sqlite-explorer-fastmcp-mcp-server

by: hannesrudolph

An MCP server that provides safe, read-only access to SQLite databases through Model Context Protocol (MCP). This server is built with the FastMCP framework, which enables LLMs to explore and query SQLite databases with built-in safety features and query validation.

39created 15/12/2024
Visit
SQLite
FastMCP

📌Overview

Purpose: To provide safe, read-only access to SQLite databases through the Model Context Protocol (MCP) using the FastMCP framework.

Overview: The SQLite Explorer MCP Server facilitates interaction with SQLite databases for large language models (LLMs) by allowing secure querying and exploration while ensuring data integrity through safety features and validations.

Key Features:

  • read_query: Executes SELECT queries with built-in safety measures including validation, parameter binding, row limiting, and results formatted as dictionaries, ensuring secure and controlled database interactions.

  • list_tables: Lists all available tables in the database, enabling users to quickly identify data structures.

  • describe_table: Provides detailed schema information for specific tables, including column names, types, NULL constraints, default values, and primary key information, aiding users in understanding the database layout.


SQLite Explorer MCP Server

An MCP server that provides safe, read-only access to SQLite databases through Model Context Protocol (MCP). Built with the FastMCP framework, this server enables LLMs to explore and query SQLite databases with built-in safety features and query validation.

System Requirements

  • Python 3.6+
  • SQLite database file (path specified via environment variable)

Dependencies

Install all required dependencies:

pip install -r requirements.txt

Required Packages

  • fastmcp: Framework for building Model Context Protocol servers

All dependencies are listed in requirements.txt.

MCP Tools

The server exposes the following tools to LLMs:

read_query

Execute a SELECT query on the database with built-in safety validations, including:

  • Query validation and sanitization
  • Parameter binding support
  • Row limit enforcement
  • Results formatted as dictionaries

list_tables

List all available tables in the database by name.

describe_table

Get detailed schema information for a specific table, including:

  • Column names and types
  • NULL constraints
  • Default values
  • Primary key information

Getting Started

Clone the repository:

git clone https://github.com/hannesrudolph/sqlite-explorer-fastmcp-mcp-server.git
cd sqlite-explorer-fastmcp-mcp-server

Installation Options

Option 1: Install for Claude Desktop

Install using FastMCP:

fastmcp install sqlite_explorer.py --name "SQLite Explorer" -e SQLITE_DB_PATH=/path/to/db

Replace /path/to/db with the path to your SQLite database file.

Option 2: Install for Cline VSCode Plugin

To use this server with the Cline VSCode plugin:

  1. In VSCode, click the server icon (☰) in the Cline plugin sidebar
  2. Click the "Edit MCP Settings" button (✎)
  3. Add the following configuration to the settings file:
{
  "sqlite-explorer": {
    "command": "uv",
    "args": [
      "run",
      "--with",
      "fastmcp",
      "--with",
      "uvicorn",
      "fastmcp",
      "run",
      "/path/to/repo/sqlite_explorer.py"
    ],
    "env": {
      "SQLITE_DB_PATH": "/path/to/your/database.db"
    }
  }
}

Replace:

  • /path/to/repo with the full path where you cloned this repository
  • /path/to/your/database.db with the full path to your SQLite database file

Safety Features

  • Read-only access to SQLite databases
  • Query validation and sanitization
  • Parameter binding for safe query execution
  • Row limit enforcement
  • Progress output suppression for clean JSON responses

Development Documentation

The repository includes development documentation:

  • mcp-documentation.txt: Comprehensive documentation about the MCP server implementation and FastMCP framework usage.

This documentation serves as context when developing features and can assist when using LLMs for development.

Environment Variables

The following environment variable must be set:

  • SQLITE_DB_PATH: Full path to the SQLite database file you want to explore