使用说明
🧊 MCP演示:冰箱库存管理
A. 演示工程 展示了使用 模型上下文协议(MCP) 框架。它提供 库存管理 通过人工智能模型回答查询,为冰箱提供功能,并由 PostgreSQL 数据库。
🛠️ 技术栈
- Java/Spring引导
- MCP服务器/客户端
- PostgreSQL/NeonDB
- 奥拉玛与
llama3.2(本地法学硕士) - Swagger UI(用于测试端点)
🚀 项目设置
1.设置PostgreSQL
您可以:
- 在本地运行PostgreSQL
- 使用Docker启动PostgreSQL容器
- 通过托管的数据库服务连接,如 NeonDB
确保您的数据库已正确配置并正在运行。
2.与Olama建立本地LLM
安装并运行 没有 对于本地LLM支持:
> ollama list
> ollama pull llama3.2:latest
> ollama run llama3.2
💡
llama3.2大约2GB,本地运行免费无需API密钥!
3.运行应用程序
一定要跑 所有这三个 组件:
refrigerator-inventory-coremcp-servermcp-client
每个都应该正确配置,以便与数据库和彼此通信。
✅ 使用本地数据验证MCP
🔍 步骤1:测试AI模型正在运行
转到Swagger UI:
http://localhost:8082/swagger-ui/index.html#/ai-chat-controller
-
点击 试试看 在
chat端点 -
输入:
{ "message": "What is the capital of India?" } -
您应该看到:
New Delhi
✔️ 确认本地
llama3.2是向上和整合的。
🔍 步骤2:验证来自本地数据库的响应
导航到:
http://localhost:8082/swagger-ui/index.html#/mcp-chat-controller/chat
-
点击 试试看 并输入:
{ "message": "Product below 100 rupees" } -
示例响应:
Here are some products available below 100 rupees: 1. Eggs - priced at 10.0 rupees 2. Cucumber - priced at 40.0 rupees 3. Spinach - priced at 19.99 rupees 4. Gulaab Jamun - priced at 99.0 rupees
✔️ 这确认了MCP服务器使用以下命令检索和响应 您自己的数据库不是互联网数据。
📸 截图
🧾 结论
这 MCP客户端 连接到 MCP服务器,它与 refrigerator-inventory-core 应用程序和 根据您的本地数据库提供人工智能生成的答案.
🎯 一个本地AI系统与Spring Boot和PostgreSQL设置实时工作的实际演示!