Skip to main content

MCP Server SQLite3

一个基于 Model Context Protocol (MCP) 的 SQLite 数据库浏览和查询工具。

功能特性

本服务提供了一组工具,允许大语言模型(LLM)与 SQLite 数据库进行交互:

  • 查询执行: 安全地执行 SQL SELECT 查询(支持 CTE)。
  • 表结构查看: 列出数据库中的所有表。
  • 模式描述: 查看特定表的详细字段信息(列名、类型、主键等)。
  • 安全机制: 默认开启只读模式,防止意外修改数据。
  • 高级特性: 自动开启 WAL 模式和外键支持,提升性能和数据完整性。

安装

确保你的环境中已安装 Python 3.13 或更高版本。

使用 uv 运行(推荐):

# 假设你在项目根目录
uv run mcp-server-sqlite3

或者安装依赖后直接运行:

pip install -e .
python mcp-server-sqlite3.py

配置

本服务通过环境变量进行配置:

环境变量 必填 默认值 描述
SQLITE_DB_PATH 是 :memory: SQLite 数据库文件的路径。
SQLITE_READ_ONLY 否 TRUE 是否开启只读模式。设置为 FALSE 可允许写入(如果工具代码允许,目前主要限制为 SELECT)。

示例用法

在 Claude Desktop 或其他 MCP 客户端中配置:

{
  "mcpServers": {
    "sqlite-explorer": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/mcp-server-sqlite3",
        "run",
        "mcp-server-sqlite3"
      ],
      "env": {
        "SQLITE_DB_PATH": "/path/to/your/database.db",
        "SQLITE_READ_ONLY":true
      }
    }
  }
}

可用工具

read_query

执行 SQL 查询。

  • 参数:
    • query: SELECT SQL 查询语句。
    • params: (可选) 查询参数列表。
    • fetch_all: (可选) 是否获取所有结果,默认为 True。
    • row_limit: (可选) 最大返回行数,默认 1000。

list_tables

列出数据库中的所有表名。

describe_table

获取指定表的详细模式信息。

  • 参数:
    • table_name: 表名。

开发

本项目使用 uv 进行包管理。

# 安装依赖
uv sync

# 运行服务
uv run mcp-server-sqlite3

Metadata

Release files for mcp-server-sqlite3 20260116

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-server-sqlite3 20260116
File Size Uploaded Provenance
mcp_server_sqlite3-20260116.tar.gz 32.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-server-sqlite3 20260116
File Interpreter ABI Platform
mcp_server_sqlite3-20260116-py3-none-any.whl Python 3 none any Details

Total release size: 36.9 kB

Release files / mcp_server_sqlite3-20260116.tar.gz

Download URL mcp_server_sqlite3-20260116.tar.gz
Size 32.2 kB
Tags Source
SHA-256 checksum
How to use checksums
340bb64e3e95e1a06a9ba80e8ab96b627f9f0040ae2c45f642c1029f99ccdf63
BLAKE2b-256 checksum
How to use checksums
efa7575ef4ac66648ea8877f00af64c01a17280740c734892f46ba2da8b704b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.4

Release files / mcp_server_sqlite3-20260116-py3-none-any.whl

Download URL mcp_server_sqlite3-20260116-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8a7689a626a4f31a471e5977558d0aab340eae1af4b323d816078f484aed069
BLAKE2b-256 checksum
How to use checksums
4ebb27f396ee05873451aa0519ee55a686fb0a9ff143c3a302f8d065b37ac524
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.4

Security for mcp-server-sqlite3 20260116

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

20260116 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page