# Local Ecommerce Ai Agent

> 基于 Dify + Ollama + MCP 实现的全本地化电商客服智能体

- **Type:** MCP server
- **Install:** `agentstack add mcp-tonysmm-local-ecommerce-ai-agent`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [TonySMM](https://agentstack.voostack.com/s/tonysmm)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [TonySMM](https://github.com/TonySMM)
- **Source:** https://github.com/TonySMM/local-ecommerce-ai-agent

## Install

```sh
agentstack add mcp-tonysmm-local-ecommerce-ai-agent
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

## 全本地化电商客服智能体 (Fully Local E-commerce AI Agent)

> *核心特性*：完全离线 | 数据隐私 | MCP 架构 

### 项目简介

本项目是一个基于 Dify Chatflow 构建的电商客服系统。与传统的云端 AI 不同，本项目实现了**全链路本地化部署**：

1.  模型：用 Ollama 运行 Qwen 8B (LLM) 和 Qwen-embedding 4B (Embedding)，确保数据不出本地
2.  工具：自主开发 Python MCP Server，模拟电商后台系统
3.  数据：库存和订单数据存储于独立的两个 JSON 文件中

### 文件结构说明

```text
📁 Project_Root
├── 📜 README.md              # 项目说明文档
├── 🐍 ecommerce_server.py    # MCP 服务器代码 (基于 fastmcp)
├── 📦 inventory.json         # 库存数据库 (独立数据文件)
├── 🚚 orders.json            # 订单数据库 (独立数据文件)
├── 📚 shop_knowledge.txt     # RAG 知识库源文件 (产品参数/售后/技术支持)
└── ⚙️ 电商客服智能体.yml      # Dify DSL 导出文件 (导入即可复现完整Chatflow)
```

### 技术栈与架构

*   编排引擎: [Dify](https://dify.ai/) (Docker Local Version)
*   大语言模型: Qwen 8B (via Ollama)
*   向量模型: Qwen-embedding 4B (via Ollama)
*   工具协议: Model Context Protocol (MCP)
*   后端开发: Python 3.10+, `fastmcp` 库
*   架构模式: RAG (检索增强) + Tool Use (工具调用) + Chatflow (多轮对话)

### 功能场景与实现逻辑

将用户需求分发至四个核心场景：

#### 1. 咨询 (Consulting) - [RAG + MCP]
*   产品咨询：知识库获取产品参数信息，mcp工具实时读取数据库查询库存
*   物流咨询：自动提取订单号，mcp工具读取数据库获取物流状态
*   店铺政策：如退换货、售后政策

#### 2. 投诉 (Complaint) - [RAG]
*   基于知识库，不管有无相关内容LLM都会进行人性化回复并安抚

#### 3. 技术支持 (Tech Support) - [Pure RAG]
*   基于知识库的专家问答和llm本身知识，检索维修手册，解决问题

#### 4. 闲聊模式 (Chitchat)
*   处理非业务类对话（如打招呼），展现客服的人格化设定

### 启动

#### 1. 启动模型服务 Ollama
win+r cmd输入以下命令，确保本地Ollama服务启动：
```bash
ollama run qwen:8b              # 用于对话和逻辑处理
ollama pull qwen-embedding:4b   # 用于知识库索引
```

#### 2. 启动 MCP 服务器
在项目根目录下运行Python：
```bash
pip install fastmcp
python ecommerce_server.py # 启动服务 (默认端口 3002, SSE模式)
```
*注意：保持终端窗口开启。Dify 将通过 `http://host.docker.internal:3002/sse` 连接此服务。*

#### 3. 部署 Dify 应用
1.  **知识库**：新建知识库，上传 `shop_knowledge.txt`，Embedding 模型选择本地的 `qwen-embedding:4b`
2.  **工具配置**：在 Dify 工具页 -> MCP 工具 -> 添加自定义工具，填入上面的 SSE 地址
3.  **导入 DSL**：创建空白 Chatflow，导入 `电商客服智能体.yml`
4.  **关联资源**：进入编排页面，检查 LLM 节点和知识库检索节点是否已正确关联本地模型

---
*Created by TonySMM | 2026*

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [TonySMM](https://github.com/TonySMM)
- **Source:** [TonySMM/local-ecommerce-ai-agent](https://github.com/TonySMM/local-ecommerce-ai-agent)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-tonysmm-local-ecommerce-ai-agent
- Seller: https://agentstack.voostack.com/s/tonysmm
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
