SQLite

@modelcontextprotocol/sqlite
33 Stars 1.1w 次浏览 modelcontextprotocol 更新于 2026-08-23

一种模型上下文协议(MCP)服务器实现,通过SQLite提供数据库交互和商业智能功能。该服务器支持运行SQL查询、分析业务数据以及自动生成业务洞察备忘录。

该服务暂未提供标准配置,请参考 README 手动接入

可用工具 (6 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

read_query 1 个参数 需填 1 项

Execute a SELECT query on the SQLite database

必填参数:query

write_query 1 个参数 需填 1 项

Execute an INSERT, UPDATE, or DELETE query on the SQLite database

必填参数:query

create_table 1 个参数 需填 1 项

Create a new table in the SQLite database

必填参数:query

list_tables

List all tables in the SQLite database

该工具无需必填参数,直接调用即可

describe_table 1 个参数 需填 1 项

Get the schema information for a specific table

必填参数:table_name

append_insight 1 个参数 需填 1 项

Add a business insight to the memo

必填参数:insight

服务介绍

SQLite MCP 服务器

概述

这是一个通过 SQLite 提供数据库交互和商业智能功能的模型上下文协议(MCP)服务器实现。该服务器支持运行 SQL 查询、分析业务数据,并自动生成业务洞察备忘录。

组件

资源

服务器公开了一个动态资源:

  • memo://insights: 一个持续更新的业务洞察备忘录,汇总了在分析过程中发现的所有洞察
    • 通过 append-insight 工具发现新的洞察时自动更新

提示

服务器提供了一个演示提示:

  • mcp-demo: 交互式提示,指导用户完成数据库操作
    • 必需参数:topic - 要分析的业务领域
    • 生成适当的数据库模式和示例数据
    • 引导用户进行分析并生成洞察
    • 与业务洞察备忘录集成

工具

服务器提供了六个核心工具:

查询工具

  • read_query

    • 执行 SELECT 查询以从数据库中读取数据
    • 输入:
      • query (字符串): 要执行的 SELECT SQL 查询
    • 返回: 作为对象数组的查询结果
  • write_query

    • 执行 INSERT, UPDATE 或 DELETE 查询
    • 输入:
      • query (字符串): SQL 修改查询
    • 返回: { affected_rows: number }
  • create_table

    • 在数据库中创建新表
    • 输入:
      • query (字符串): CREATE TABLE SQL 语句
    • 返回: 表创建确认

模式工具

  • list_tables

    • 获取数据库中所有表的列表
    • 不需要输入
    • 返回: 表名称数组
  • describe-table

    • 查看特定表的模式信息
    • 输入:
      • table_name (字符串): 要描述的表名
    • 返回: 包含名称和类型的列定义数组

分析工具

  • append_insight
    • 将新的业务洞察添加到备忘录资源
    • 输入:
      • insight (字符串): 从数据分析中发现的业务洞察
    • 返回: 洞察添加确认
    • 触发 memo://insights 资源的更新

使用 Claude Desktop

uv

# Add the server to your claude_desktop_config.json
"mcpServers": {
  "sqlite": {
    "command": "uv",
    "args": [
      "--directory",
      "parent_of_servers_repo/servers/src/sqlite",
      "run",
      "mcp-server-sqlite",
      "--db-path",
      "~/test.db"
    ]
  }
}

Docker

# Add the server to your claude_desktop_config.json
"mcpServers": {
  "sqlite": {
    "command": "docker",
    "args": [
      "run",
      "--rm",
      "-i",
      "-v",
      "mcp-test:/mcp",
      "mcp/sqlite",
      "--db-path",
      "/mcp/test.db"
    ]
  }
}

构建

Docker:

docker build -t mcp/sqlite .

许可证

此 MCP 服务器根据 MIT 许可证许可。这意味着您可以在遵守 MIT 许可证条款和条件的前提下自由使用、修改和分发软件。更多详情,请参阅项目仓库中的 LICENSE 文件。

相关 MCP 服务