OpsMCP
🚀 OpsMCP — 人工智能驱动的公司运营代理
一个由人工智能驱动的公司运营代理,使用 Model Context Protocol (MCP) 将自然语言 AI 交互与 PostgreSQL 数据库安全连接。
📌 概述
OpsMCP 允许用户使用自然语言与公司数据交互,而无需手动编写 SQL 查询或浏览复杂的后台管理面板。
该系统通过 MCP 工具将 AI 代理连接到 PostgreSQL 数据库,使代理能够检索信息、分析用户并执行授权的数据库操作。
对于敏感的写入操作,系统在修改数据库之前要求用户明确确认。
Related MCP server: Postgres MCP Server
🎯 问题
传统的内部公司系统通常要求用户:
浏览多个管理仪表板
理解数据库结构
编写 SQL 查询
手动执行重复性操作
单独跟踪数据库修改
这为日常公司运营带来了不必要的复杂性。
💡 解决方案
OpsMCP 为公司运营提供了自然语言界面。
无需编写:
SELECT id, name, email, role
FROM users
ORDER BY id;用户只需询问:
"显示所有用户。"
AI 确定需要哪个 MCP 工具,执行它,接收结果,并将其转换为用户友好的响应。
🧠 工作原理
┌──────────────────────┐
│ Web Dashboard │
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ AI Agent │
│ Natural Language │
└──────────┬───────────┘
│
MCP Tool Calling
│
▼
┌──────────────────────┐
│ MCP Server │
│ │
│ Tools • Resources │
│ Prompts • Security │
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ PostgreSQL │
│ Database │
└──────────────────────┘✨ 主要特性
🤖 自然语言数据库操作
用户可以使用日常语言与公司数据交互。
示例:
Show me all users.Find user with ID 2.Create a new user named Rahul with role developer.Change Rahul's role to manager.Analyze all users and tell me which role has the most users.🔧 MCP 工具
该项目将数据库操作暴露为 MCP 工具。
当前工具包括:
Tool | 用途 |
| 检索所有用户 |
| 检索特定用户 |
| 创建新用户 |
| 更新用户角色 |
| 分析用户分布 |
📚 MCP 资源
该项目还演示了 MCP 资源,用于向 AI 代理提供结构化上下文信息。
示例:
company://info该资源包含以下信息:
部门
公司角色
组织结构
🧩 MCP 提示词
项目包含可复用的 MCP 提示词,用于用户分析等结构化操作。
示例分析工作流:
1. Count total users
2. Group users by role
3. Identify unusual roles
4. Generate a summary🔐 安全性
安全性是项目的重要组成部分。
API 密钥认证
MCP 服务器支持使用 HTTP 授权标头进行 API 密钥认证。
实现了两个权限级别:
READ_ONLY
READ_WRITE授权
只读权限可以执行读取操作。
更改数据库的操作需要:
READ_WRITE权限。
⚠️ 写入操作前确认
在执行更改数据库的操作之前,AI 客户端会要求用户确认。
示例:
⚠️ WRITE OPERATION REQUIRES CONFIRMATION
Tool : update_user_role
Arguments : {
"user_id": 2,
"new_role": "manager"
}
Do you want to continue? (yes/no)只有在明确批准后才会修改数据库。
🛡️ 输入验证
用户输入在数据库操作之前进行验证。
例如,支持的角色有:
developer
designer
product manager
manager无效输入,例如:
aestronuot会被拒绝,而不会插入数据库。
📋 审计日志
更改数据库的操作会记录在审计日志中。
示例:
action | tool_name | status
----------------+------------------+---------
update_user_role| update_user_role | SUCCESS这为敏感操作提供了可追溯性。
🗂️ 项目结构
OPSMCP-AI-AGENNT/
│
├── server/
│ ├── auth/
│ ├── database/
│ │ └── connection.py
│ │
│ ├── prompts/
│ │ └── user_analysis.py
│ │
│ ├── resources/
│ │ └── company.py
│ │
│ └── tools/
│ ├── audit.py
│ └── user_tools.py
│
├── static/
│ ├── app.js
│ └── style.css
│
├── templates/
│ └── index.html
│
├── ai_client.py
├── web_app.py
├── run_server.py
├── requirements.txt
├── .gitignore
└── README.md🛠️ 技术栈
后端
Python
FastAPI
Uvicorn
AI
兼容 OpenAI 的 API
函数/工具调用
自然语言交互
协议
Model Context Protocol (MCP)
可流式 HTTP 传输
数据库
PostgreSQL
Psycopg
前端
HTML
CSS
JavaScript
安全性
API 密钥认证
读写授权
基于确认的数据库变更
输入验证
审计日志
⚙️ 本地设置
1. 克隆仓库
git clone https://github.com/Ayushsharma109/OPSMCP-AI-AGENNT.git
cd OPSMCP-AI-AGENNT2. 创建虚拟环境
Windows:
python -m venv .venv激活它:
.venv\Scripts\activate3. 安装依赖
pip install -r requirements.txt4. 配置环境变量
创建 .env 文件:
MCP_API_KEY=your_main_api_key
MCP_READONLY_KEY=your_readonly_api_key
OPENAI_API_KEY=your_api_key
OPENAI_BASE_URL=your_base_url
OPENAI_MODEL=your_model
DB_NAME=mcp_demo
DB_USER=postgres
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=5432切勿将
.env或 API 密钥提交到 GitHub。
5. 启动 PostgreSQL
确保 PostgreSQL 正在运行,并且所需的数据库/表已存在。
6. 启动 MCP 服务器
python run_server.pyMCP 服务器运行在:
http://127.0.0.1:80007. 启动 Web 应用程序
打开另一个终端:
python web_app.py仪表板将可在以下地址访问:
http://127.0.0.1:8080🧪 示例工作流
用户
Show me all users.AI 代理
确定需要 get_users。
MCP
执行:
get_users()PostgreSQL
返回用户记录。
AI
将数据库结果转换为自然语言响应。
🔄 写入操作工作流
User Request
↓
AI Agent
↓
MCP Tool Selection
↓
Permission Check
↓
User Confirmation
↓
Input Validation
↓
PostgreSQL Update
↓
Audit Log
↓
AI Response这种设计有助于防止意外修改数据库。
🏆 黑客马拉松 MVP
OpsMCP 作为一个专注的 MVP 开发,演示了如何使用 MCP 将 AI 代理与企业真实数据和受控后端操作连接起来。
项目专注于:
AI 工具调用
MCP 架构
安全的数据库交互
人工确认变更
可审计性
自然语言公司运营
🚀 未来改进
潜在的未来改进包括:
基于角色的仪表板访问
更多企业级 MCP 工具
高级分析
多数据库支持
更好的审计日志可视化
可部署的认证方案
企业 SSO 集成
更细粒度的权限
👨💻 作者
Ayush Sharma
作为个人黑客马拉松项目构建,探索:
AI 代理 + MCP + PostgreSQL + 安全工具执行
📄 许可证
该项目主要作为黑客马拉松和学习项目。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables AI assistants to interact with PostgreSQL databases using natural language queries, providing secure read-only access to database schemas and SQL translation capabilities.67
- FlicenseAqualityNot gradedmaintenanceEnables comprehensive PostgreSQL database management through natural language including queries, schema operations, user management, and administrative tasks. Features enterprise-grade connection pooling, transaction support, and full database administration capabilities.112251
- AlicenseNot gradedqualityDmaintenanceEnables natural language interaction with PostgreSQL databases, supporting query execution, schema management, data operations, user management, and database maintenance with secure remote access via HTTP/SSE transport.MIT
- AlicenseNot gradedqualityDmaintenanceEnables secure, read-only PostgreSQL database interaction through natural language, with automatic database discovery and connection management.2MIT
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
The grounded data layer for any LLM: governed SQL, metrics, lineage and catalog over your data.
GibsonAI MCP server: manage your databases with natural language
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/Ayushsharma109/OPSMCP-AI-AGENNT'
If you have feedback or need assistance with the MCP directory API, please join our Discord server