购物助手MCP服务器

一个用于购物助手的模型上下文协议(MCP)服务器,提供搜索、读取、写入工具和提示,用于与购物系统交互。

  • by heldiapriadi
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 heldiapriadi/example-mcp-server-n8n-retail

使用说明

n8n购物助手MCP服务器

这是购物助理的模型上下文协议(MCP)服务器实现。它提供了工具和提示,可供Claude等MCP客户端与购物系统交互。

特性

搜索工具

  • search_products –按关键字搜索产品
  • list_categories –列出所有可用的产品类别
  • list_recommendations –返回人工智能生成的产品推荐

阅读工具

  • get_product_detail –获取单个产品的详细信息
  • get_cart_contents –返回当前用户的购物车
  • get_chat_history –返回用户会话中的先前消息

写入工具

  • create_cart –为用户会话启动新购物车
  • add_to_cart –将产品添加到购物车
  • update_cart_item –更改购物车中商品的数量
  • create_order –完成结账并创建订单
  • save_user_message –将用户消息记录到聊天记录中

提示

  • 产品推荐:为给定的用户输入或产品建议相关或互补的项目
  • 购物车摘要:用自然语言总结用户购物车中的内容
  • 订单确认:生成包含总价、交货信息等的确认摘要。

入门指南

先决条件

  • Node.js 18或更高版本
  • npm或纱线

安装

  1. 克隆存储库
git clone https://github.com/yourusername/n8n-mcp-server.git
cd n8n-mcp-server
  1. 安装依赖项
npm install
  1. 构建项目
npm run build
  1. 启动服务器
npm start

默认情况下,服务器将在端口3000上启动。您可以通过设置来更改端口 PORT 环境变量。

端点

  • 现代MCP端点(流式HTTP): http://localhost:3000/mcp
  • 传统MCP端点(SSE): http://localhost:3000/sse
  • 健康检查: http://localhost:3000/health

与克劳德一起使用

要将此MCP服务器与Claude一起使用,您可以通过Claude Desktop应用程序或使用MCP TypeScript SDK客户端的Claude API进行连接。

通过克劳德桌面连接

  1. 启动服务器
  2. 在Claude Desktop中,转到“设置”>“模型上下文协议”
  3. 使用URL添加新服务器 http://localhost:3000/mcp

Claude使用示例

I'd like to search for some snacks. Can you show me what's available?

[Claude will use the search_products tool to look for snacks]

I'd like to add some Oreo cookies to my cart.

[Claude will use the create_cart and add_to_cart tools]

Can you show me what's in my cart?

[Claude will use the get_cart_contents tool and the cart-summary prompt]

I'd like to checkout now.

[Claude will use the create_order tool and the order-confirmation prompt]

发展

要在开发模式下运行服务器并自动重启,请执行以下操作:

npm run dev

项目结构

  • src/index.ts -主服务器实现
  • src/models.ts -数据模型和函数