Skip to main content
Glama
Diluksha-Upeka

Enterprise Data MCP Server

企业数据代理 🗄️

一个企业员工数据库的自然语言接口,由 Groq LLM 工具调用和本地 SQLite 数据库驱动,配备 Streamlit 前端和 模型上下文协议 (MCP) 服务器后端。


架构

flowchart TD
    %% Styling
    classDef client fill:#2d3748,stroke:#94a3b8,stroke-width:1px,color:#f8fafc,rx:10px
    classDef core fill:#0f172a,stroke:#3b82f6,stroke-width:2px,color:#eff6ff,rx:6px
    classDef db fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#ecfdf5,rx:6px
    classDef ai fill:#312e81,stroke:#8b5cf6,stroke-width:2px,color:#eef2ff,rx:6px

    %% Nodes
    User(["👤 User Browser"]):::client
    ExtAI(["🤖 MCP Client (Claude, Cursor)"]):::client

    App["⚡ Streamlit App"]:::core
    Server["🔌 MCP Server"]:::core
    DBLayer["⚙️ Shared DB Layer"]:::core

    Groq{"🧠 Groq LLM"}:::ai
    SQLite[("💾 SQLite Database")]:::db

    %% Connections
    User <-->|"Chat Interface"| App
    App <-->|"Prompts & Tools"| Groq
    App -->|"Execute Tools"| DBLayer

    ExtAI <-->|"MCP / stdio"| Server
    Server -->|"Execute Tools"| DBLayer

    DBLayer <-->|"SQL Operations"| SQLite

Related MCP server: OCP AI Custom HR MCP Server

快速入门

1. 前置要求

2. 克隆与设置

git clone <your-repo-url>
cd mcp_project

# Create and activate a virtual environment
python -m venv venv
venv\Scripts\activate        # Windows
# source venv/bin/activate   # macOS/Linux

# Install dependencies
pip install -r requirements.txt

3. 配置环境

在项目根目录 (F:\PROJECTS\MCP\.env) 创建一个 .env 文件:

GROQ_API_KEY=gsk_your_key_here
GROQ_MODEL=llama-3.3-70b-versatile   # optional, this is the default

4. 初始化数据库

# From the project root (F:\PROJECTS\MCP\)
sqlite3 enterprise_data.db < schema.sql

5. 运行应用

# From F:\PROJECTS\MCP\
streamlit run mcp_project/app.py

在浏览器中打开 http://localhost:8501。


可用工具

LLM 可以根据您的查询自动调用以下工具:

工具

描述

get_active_users

列出所有活跃用户及其角色

add_user

添加新用户(姓名 + 角色)

deactivate_user

按姓名停用活跃用户

get_user_stats

获取总数、活跃用户数和非活跃用户数

search_users

按姓名片段搜索用户


查询示例

  • “谁是我们的活跃用户?”

  • “添加 Jane Doe 为经理”

  • “我们总共有多少用户?”

  • “搜索名为 Alice 的用户”

  • “停用 Bob Jones”

  • “显示用户统计信息”


运行 MCP 服务器(独立模式)

server.py 通过 模型上下文协议 (Model Context Protocol) 公开相同的工具。它支持本地 stdio 连接和基于 HTTP 的 sse 传输!

它现在公开了:

  • 工具:数据库查询和更新操作

  • 资源:通过 MCP 公开 schema.sql

  • 提示词:提供预配置的提示词,如 hr-assistant

若要为 AI 桌面应用(如 Claude Desktop / Cursor)本地运行:

python mcp_project/server.py --transport stdio

若要作为 HTTP SSE 服务器在 8000 端口运行:

python mcp_project/server.py --transport sse --port 8000

项目结构

F:\PROJECTS\MCP\
├── .env                    # ← API key (never commit this!)
├── .gitignore
├── requirements.txt
├── schema.sql              # DB schema — use to recreate the database
├── enterprise_data.db      # SQLite database (gitignored)
└── mcp_project\
    ├── app.py              # Streamlit frontend
    ├── server.py           # MCP stdio server
    └── db.py               # Shared database access layer

安全说明

  • 切勿提交您的 .env 文件。 .gitignore 已将其排除。

  • 切勿提交 enterprise_data.db。 请使用 schema.sql 重新创建它。

  • 如果您的 Groq API 密钥已泄露,请在 console.groq.com 进行轮换。

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    An open-source MCP server that imports HR CSV data into an in-memory SQLite database for structured querying and metadata retrieval. It enables users to perform read-only SQL queries and structured searches on employee data through natural language.
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    An MCP server for interacting with an HR database, enabling querying employee data and HR operations via natural language.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    A comprehensive MCP server that enables database operations, schema management, and statistics via natural language through SQL queries and resources.
    18 npm
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    MCP server for managing users in PostgreSQL, enabling CRUD operations and search via natural language commands.
    -