Skip to main content
Glama

streamlit-dashboard-mcpserver

QueryForge — 与你的数据库对话,看着它变成仪表盘。

一个统一的模型上下文协议(MCP)服务器,让 Claude 能够查询任何 SQLite 数据库、从知识库中检索企业特定的业务逻辑,并构建实时的 Streamlit 仪表盘——全部通过一次对话完成。

项目结构

streamlit-dashboard-mcpserver/
├── .venv/                  # Python virtual environment (managed by uv)
├── data/
│   ├── seed.py             # Generates the sample CRM database
│   └── database.db         # SQLite database (generated by seed.py)
├── knowledge_base/
│   ├── docs/                # Source documents (formulas, business rules, definitions)
│   ├── ingest.py             # Chunks + embeds docs into the vector store
│   └── index/                 # Persisted vector store (generated by ingest.py)
├── .python-version         # Pinned Python version for uv
├── dashboard.py            # Auto-generated by Claude at runtime
├── server.py               # The MCP server
├── uv.lock                 # Dependency lock file
└── README.md

Related MCP server: TheMCP-server

功能

工具

描述

list_tables

列出数据库中的所有表

describe_table

显示表的列、类型和约束

sample_table

返回任意表的前 N 行

query_database

运行只读的 SELECT 查询

query_knowledge_base

从企业文档中检索相关片段(自定义计算公式、业务规则、指标定义),帮助 Claude 编写正确的查询和仪表盘逻辑

create_dashboard

编写 Streamlit 应用,自动安装依赖并启动

stop_dashboard

停止正在运行的 Streamlit 进程

get_dashboard_status

检查仪表盘是否正在运行以及运行在哪个端口

read_dashboard

读取当前 dashboard.py 的源代码

强制只读。 INSERT、UPDATE、DELETE、DROP 以及所有其他写操作都在服务器级别被阻止。知识库仅用于检索——Claude 无法通过此服务器向其中写入内容。

query_knowledge_base 是让仪表盘 正确 而非仅仅看似合理的关键。Claude 不会猜测你的组织如何定义“净收入”或“活跃客户”等概念,而是在编写 SQL 或仪表盘代码之前,从分块的企业文档中检索实际记录在案的公式。

screenshot1-dashboard screenshot2-chat

前提条件

  • Python 3.11+(通过 .python-version 固定)

  • uv — 本项目已使用(参见 uv.lock

  • Claude Desktop

  • 一个用于知识库的源文档文件夹(PDF、Markdown 或纯文本——例如你的内部公式表、指标术语表或标准操作流程)

安装

1. 安装 Claude Desktop

下载并安装适用于你操作系统的 Claude Desktop: Windows / macOS:https://claude.ai/download 安装后使用你的 Anthropic 账户登录。

2. 克隆仓库

HTTPS:

git clone https://github.com/your-username/streamlit-dashboard-mcpserver.git
cd streamlit-dashboard-mcpserver

SSH:

git clone git@github.com:your-username/streamlit-dashboard-mcpserver.git
cd streamlit-dashboard-mcpserver

GitHub CLI:

gh repo clone your-username/streamlit-dashboard-mcpserver
cd streamlit-dashboard-mcpserver

3. 使用 uv 设置环境

本项目使用 uv 进行环境管理。.python-versionuv.lock 文件已提交,因此只需一条命令即可完成设置。

如果你还没有安装 uv:

# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

从锁文件创建虚拟环境并安装所有依赖:

uv sync

激活环境:

# Windows PowerShell
.venv\Scripts\Activate.ps1
# Windows CMD
.venv\Scripts\activate.bat

激活后,你会在提示符中看到项目名称:

(streamlit-dashboard-mcpserver) PS C:\Users\benij\ds_project\streamlit-dashboard-mcpserver>

验证关键包是否已安装:

pip list | findstr "mcp streamlit"

如果缺少任何内容:

uv pip install mcp streamlit pandas plotly

4. 生成数据库

data/ 中的 seed.py 脚本会生成一个真实的 CRM 数据库,包含 10,000+ 条记录,覆盖完整的雪花模式。

cd data
python seed.py
cd ..

这将创建 data/database.db,即 MCP 服务器读取的数据库。

5. 构建知识库索引

将你的企业文档(公式表、指标定义、业务规则——PDF、Markdown 或 .txt)放入 knowledge_base/docs/,然后运行:

python knowledge_base/ingest.py

该脚本会对文档进行分块和嵌入,并将生成的向量存储写入 knowledge_base/index/。这就是 query_knowledge_base 在运行时读取的内容——每当源文档发生变化时,请重新运行此脚本。

6. 配置 Claude Desktop

Claude Desktop 从 JSON 配置文件中读取 MCP 服务器定义。

打开配置文件:

notepad $env:APPDATA\Claude\claude_desktop_config.json

如果文件尚不存在,记事本会询问是否创建——点击“是”。

粘贴以下配置,如果不同,请将 benij 替换为你的 Windows 用户名:

{
  "mcpServers": {
    "sqlite-dashboard": {
      "command": "C:\\Users\\benij\\ds_project\\streamlit-dashboard-mcpserver\\.venv\\Scripts\\python.exe",
      "args": [
        "C:\\Users\\benij\\ds_project\\streamlit-dashboard-mcpserver\\server.py"
      ],
      "env": {
        "DB_PATH": "C:\\Users\\benij\\ds_project\\streamlit-dashboard-mcpserver\\data\\database.db",
        "DASHBOARD_PORT": "8501",
        "KB_INDEX_PATH": "C:\\Users\\benij\\ds_project\\streamlit-dashboard-mcpserver\\knowledge_base\\index"
      }
    }
  }
}

要确认你的确切 Python 路径,请在激活 venv 后运行:

where.exe python

预期输出:

C:\Users\benij\ds_project\streamlit-dashboard-mcpserver\.venv\Scripts\python.exe

使用该确切字符串作为配置中的 command 值。

始终使用绝对路径。 Claude Desktop 会从不可预测的工作目录启动 MCP 服务器子进程——相对路径将无法正确解析。

7. 重启 Claude Desktop

保存配置后,完全退出 Claude Desktop——右键单击系统托盘图标 → 退出。然后重新打开。

重新启动后,点击聊天输入框左下角的 🔨 锤子图标。你应该会看到列出的所有 9 个工具,确认服务器已连接。

使用方法

连接后,自然地与 Claude 对话:

"What tables are in my database?"

"How do we define 'net revenue' internally?"

"Show me the top 10 customers by total revenue, using our
 company's official revenue formula"

"Build a dashboard with monthly sales trends, a bar chart
 by product category, and a salesperson leaderboard"

Claude 将探索模式,在需要时从知识库中提取相关业务逻辑,运行查询,编写 Streamlit 代码,安装任何缺失的依赖,并返回一个可在浏览器中打开的 URL——默认为 http://localhost:8501

环境变量

在你的 claude_desktop_config.jsonenv 块中设置这些变量:

变量

默认值

描述

DB_PATH

./database.db

你的 SQLite 数据库的绝对路径

DASHBOARD_PORT

8501

Streamlit 将监听的端口

KB_INDEX_PATH

./knowledge_base/index

ingest.py 构建的向量存储的绝对路径

故障排除

🔨 锤子图标未显示在 Claude Desktop 中 配置 JSON 可能无效——尾随逗号和括号不匹配是常见错误。将其粘贴到 jsonlint.com 进行验证。任何配置更改后,务必完全退出并重新打开 Claude Desktop。

“找不到数据库”错误 确认 DB_PATH 是绝对路径,并且 database.db 存在于 data/ 文件夹中。如果尚未生成,请运行 seed.py

query_knowledge_base 返回无结果 / 索引为空 确认 knowledge_base/docs/ 中确实有文档,然后重新运行 python knowledge_base/ingest.py。确认配置中的 KB_INDEX_PATH 指向 knowledge_base/index/

Streamlit 页面无法加载 询问 Claude“仪表盘是否正在运行?”以调用 get_dashboard_status。如果未运行,请让 Claude 再次执行 create_dashboard。同时检查端口 8501 是否已被其他进程占用。

uv sync 失败 确保你安装的 Python 版本与 .python-version 匹配。运行 python --version 检查,如有需要,请从 python.org 安装正确的版本。

激活 .venv 时出现 PowerShell ExecutionPolicy 错误

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

然后重新激活。

关于

一个 MCP 服务器,将自然语言转化为 SQL 查询和实时的、感知业务逻辑的 Streamlit 仪表盘,由 Claude 和包含企业特定规则与公式的检索增强知识库驱动。

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    One config, one CLI that turns your databases (Postgres, MySQL, SQLite, MongoDB) into MCP servers for Claude, GPT, Cursor, and any MCP-compatible agent.
    1
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables interaction with SQLite databases, filesystem, AWS IAM, and Gmail through a master MCP server with a Streamlit UI optimized for Claude.
    1
    -
  • A
    license
    A
    quality
    B
    maintenance
    MCP server for Claude that connects to MySQL, MariaDB, and SQLite databases. Query your databases using natural language.
    3
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    A database-agnostic MCP server that enables natural language queries to your database through Claude or Copilot, automatically writing and executing SQL.
    8
    16
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Mikebenisberchmans/Queryforge'

If you have feedback or need assistance with the MCP directory API, please join our Discord server