SQLite Explorer MCP Server

SQLite Explorer MCP Server

通过模型上下文协议(MCP)提供对SQLite数据库的安全、只读访问的MCP服务器。该服务器基于FastMCP框架构建,使LLM能够利用内置的安全特性和查询验证来探索和查询SQLite数据库。

简介

SQLite Explorer MCP 服务器让大语言模型(LLM)能够安全、只读地访问和查询 SQLite 数据库,基于 FastMCP 框架构建,提供内置安全特性。

系统要求

  • Python 3.6+
  • SQLite 数据库文件

快速开始

  1. 克隆仓库

    git clone https://github.com/hannesrudolph/sqlite-explorer-fastmcp-mcp-server.git
    cd sqlite-explorer-fastmcp-mcp-server
    
  2. 安装依赖

    pip install -r requirements.txt
    
  3. 选择安装方式

    方式一:Claude Desktop 安装

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

    方式二:Cline VSCode 插件安装

    1. 在 VSCode 中点击 Cline 插件侧边栏中的服务器图标(☰)
    2. 点击"编辑 MCP 设置"(✎)
    3. 添加配置:
      {
        "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"
          }
        }
      }
      

核心功能

  • read_query: 执行带安全验证的 SELECT 查询
  • list_tables: 列出数据库中所有表
  • describe_table: 获取表的详细模式信息

环境变量

  • SQLITE_DB_PATH:SQLite 数据库文件的完整路径(必需

安全特性

  • 只读访问
  • 查询验证和清理
  • 参数绑定支持
  • 行数限制执行
  • 格式化的结果输出