MCP Host Client Server SSE
About
MCP Host Client Server SSE is a natural language SQL database query system built on the Model Context Protocol (MCP). It integrates with OpenAI to convert natural language questions into SQL queries, using Server-Sent Events (SSE) for real-time communication between the host and…
Details
- Author
- HanShan006
- GitHub stars
- 4
- Downloads
- 345
- Categories
- Other
Jump to
- MCP protocol-based server-client architecture
- Natural language to SQL query translation via OpenAI
- Real-time communication using Server-Sent Events (SSE)
- SQLite database integration with sample tables (users, orders)
- OpenAI/DeepSeek API integration
- Asynchronous support and full logging system
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
MCP Host Client Server SSECommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
1. Clone the repository, install dependencies (openai, mcp-framework, starlette, uvicorn).
2. Create a config.ini file with your OpenAI API key.
3. Initialize the SQLite database: python create_database.py.
4. Start the MCP server: python mcp_server.py.
5. Run the host application: python mcp_host.py.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"mcp host client server sse": {
"MCP_Host_Client_Server_SSE": {
"command": "python",
"args": [
"create_database.py"
]
}
}
}
}
McpServers
{
"MCP_Host_Client_Server_SSE": {
"command": "python",
"args": [
"create_database.py"
]
}
}
MCP Host Client Server SSE
基于MCP(Model Context Protocol)协议实现的自然语言SQL数据库查询系统,支持通过大语言模型将自然语言转换为SQL查询。本项目展示了如何使用MCP协议构建服务器-客户端架构,并集成OpenAI实现智能查询功能。
功能特点
- 🚀 基于MCP协议的服务器-客户端架构
- 📝 支持自然语言转SQL查询
- 🔄 使用SSE(Server-Sent Events)实现实时通信
- 📊 SQLite数据库集成
- 🤖 OpenAI/DeepSeek接口集成
- 📝 完整的日志记录系统
- ⚡ 异步操作支持
系统架构
graph TD
A[用户] -->|自然语言问题| B[MCP Host]
B -->|API调用| C[OpenAI]
C -->|SQL查询| B
B -->|MCP请求| D[MCP Server]
D -->|查询| E[SQLite DB]
E -->|结果| D
D -->|SSE响应| B
B -->|自然语言解释| A
快速开始
前置要求
- Python 3.8+
- pip包管理器
- OpenAI API密钥
安装步骤
1. 克隆仓库:
git clone https://github.com/HanShan006/MCP_Host_Client_Server_SSE.git
cd MCP_Host_Client_Server_SSE
2. 安装依赖:
pip install openai mcp-framework starlette uvicorn
3. 配置API密钥:
创建config.ini文件并添加以下内容:
[secrets]
API_KEY=your_api_key_here
4. 创建示例数据库:
python create_database.py
运行服务
1. 启动MCP服务器:
python mcp_server.py
2. 运行客户端应用:
python mcp_host.py
数据库结构
users表
| 字段 | 类型 | 说明 | |------|------|------| | id | INTEGER | 用户ID(主键)| | name | TEXT | 用户名 | | age | INTEGER | 年龄 | | email | TEXT | 邮箱地址 |orders表
| 字段 | 类型 | 说明 | |------|------|------| | id | INTEGER | 订单ID(主键)| | user_id | INTEGER | 用户ID(外键)| | product_name | TEXT | 商品名称 | | price | REAL | 价格 | | order_date | TEXT | 订单日期 |示例查询
系统支持多种自然语言查询,例如:
1. "查询所有用户的信息"
2. "显示张三的所有订单"
3. "统计每个用户的消费总额"
4. "查询订单金额超过5000元的用户信息"
项目结构
MCP_Host_Client_Server_SSE/
├── mcp_server.py # MCP服务器实现
├── mcp_client.py # MCP客户端实现
├── mcp_host.py # 主机程序(集成OpenAI)
├── create_database.py # 数据库初始化脚本
├── database.db # SQLite数据库文件
├── config.ini # 配置文件
└── README.md # 项目文档
技术栈
- Python 3.8+
- MCP Framework
- SQLite
- OpenAI API
- Starlette
- Server-Sent Events (SSE)
- Async/Await
版本历史
v1.0.0 (2025-05-07)
- ✨ 初始版本发布 - 🎉 实现基础MCP服务器功能 - 🎉 完成客户端通信模块 - 🎉 集成OpenAI自然语言处理 - 🎉 添加SQLite数据库支持 - 📝 完善项目文档贡献者
- 程序员寒山 (@HanShan006)
开源协议
本项目采用 MIT 协议开源,详情请参见 LICENSE 文件。
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



