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"| SQLiteRelated MCP server: OCP AI Custom HR MCP Server
快速入门
1. 前置要求
Python 3.11+
一个 Groq API 密钥
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.txt3. 配置环境
在项目根目录 (F:\PROJECTS\MCP\.env) 创建一个 .env 文件:
GROQ_API_KEY=gsk_your_key_here
GROQ_MODEL=llama-3.3-70b-versatile # optional, this is the default4. 初始化数据库
# From the project root (F:\PROJECTS\MCP\)
sqlite3 enterprise_data.db < schema.sql5. 运行应用
# From F:\PROJECTS\MCP\
streamlit run mcp_project/app.py在浏览器中打开 http://localhost:8501。
可用工具
LLM 可以根据您的查询自动调用以下工具:
工具 | 描述 |
| 列出所有活跃用户及其角色 |
| 添加新用户(姓名 + 角色) |
| 按姓名停用活跃用户 |
| 获取总数、活跃用户数和非活跃用户数 |
| 按姓名片段搜索用户 |
查询示例
“谁是我们的活跃用户?”
“添加 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 进行轮换。
This server cannot be deployed
Maintenance
Related MCP Connectors
- mcpOAuthcom.gibsonai
GibsonAI MCP server: manage your databases with natural language
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
- mcp-serverOAuthio.klokin
MCP server exposing klokin time-tracking operations (employees, time entries, stores) to AI clients.
MCP server unifying ERPs, CRMs, APIs and knowledge base for Claude, ChatGPT and Gemini.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn 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
- FlicenseNot gradedqualityDmaintenanceAn MCP server for interacting with an HR database, enabling querying employee data and HR operations via natural language.-
- FlicenseNot gradedqualityDmaintenanceA comprehensive MCP server that enables database operations, schema management, and statistics via natural language through SQL queries and resources.18 npm-
- FlicenseNot gradedqualityDmaintenanceMCP server for managing users in PostgreSQL, enabling CRUD operations and search via natural language commands.-