POS MCP服务器导入工具

将预构建的POS MCP服务器导入watsonx Orchestrate平台,实现零售场景下的产品查询、销售报告、库存警报和终端状态管理。

  • by Nniol
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 Nniol/pos-mcp-server

使用说明

实验室:将POS MCP服务器导入Watson Orchestrate

级别: 媒介介绍


概述

在这个实验室里,你将导入一个现成的 销售点(POS)MCP服务器 进入Watson Orchestrate。服务器在PyPI上作为公共包发布,并使用以下命令按需拉取 uvx --无需手动克隆, pip install,或需要访问令牌。

服务器使用 stdio传输:watsonx Orchestrate通过运行 uvx 命令。不需要网络端口或隧道。

提供POS工具

工具 代理可以做什么
pos_list_products 列出所有产品,可选择按类别筛选
pos_get_product 按ID获取一种产品的价格和库存详细信息
pos_sales_report 按日期范围和/或出纳筛选的收入汇总
pos_inventory_alerts 标记达到或低于可配置库存阈值的产品
pos_terminal_status 显示所有POS终端及其在线/离线状态

第1部分——在Watson Orchestrate中注册服务器

使用GUI

  1. 在浏览器中打开您的Watson Orchestrate实例。

  2. 点击 ☰ menu → 构建→ 所有工具→ 创建工具+→ MCP 服务器→ 添加MCP服务器+->本地MCP服务器→ Next.

  3. 填写表格:

    字段 值
    服务器名称 pos-mcp
    描述 pos-mcp
    安装命令 uvx --from pos-mcp-server pos-mcp-server
    选择连接(可选) 留空
  4. 点击 导入 --等待一段时间后,所有5个工具都应该出现。


第2部分——为代理分配工具

  1. 导航菜单(☰左上角)→ 构建→ 创建代理+→ 从头开始创建
  2. 名称:简易POS查询代理
  3. 描述:回答咖啡店的基本问题和产品、销售业绩、库存水平和终端状态
  4. 创建
  5. 工具集(左侧)→ 添加工具+→ 本地实例
  6. 选择您刚刚导入的5个工具,它们将开始: pos-mcp:
  7. 添加到代理
  8. 行为(左侧)→ 将以下内容粘贴到 Instructions

    你是一家连锁咖啡店的零售助理。使用POS工具回答 关于产品、销售业绩、库存水平和终端状态的问题。


第3部分——测试代理

在 聊天 尝试下面的每个提示。每个目标都针对不同的工具。

提示 工具已调用
“列出饮料类别中的所有产品” pos_list_products
“P003产品的价格和库存水平是多少?” pos_get_product
“显示Anna在2025年6月1日的销售额” pos_sales_report
“哪些商品的库存少于25件?” pos_inventory_alerts
“当前所有POS终端都在线吗?” pos_terminal_status

第4部分——构建一个ReAct风格的代理

什么是ReAct?

交互式推理与行动 (Reason+Act)是一种提示模式,代理人明确地在以下两种模式之间交替:

  • 思想 --关于已知和仍需的推理
  • 行动 --调用工具
  • 观察 --读取工具结果
  • …重复直到收集到足够的信息。..
  • 最终答案 --对用户的综合响应

这比多工具问题的默认样式更好,因为代理决定其 下一个 工具基于什么 以前的 工具返回,而不是预先计划所有调用或在调用后停止。

User question
    │
    ▼
Thought: what do I know? what do I need?
    │
    ▼
Action: call tool A
    │
    ▼
Observation: result from tool A
    │
    ▼
Thought: what does this tell me? do I need more data?
    │
    ▼
Action: call tool B  ◄─── decision driven by Observation above
    │
    ▼
Observation: result from tool B
    │
    ▼
Thought: I have enough to answer.
    │
    ▼
Final Answer: synthesised response

创建代理

  1. 导航菜单(☰左上角)→ 构建→ 创建代理+→ 从头开始创建
  2. 姓名: POS ReAct Agent
  3. 说明: Uses step-by-step reasoning to answer complex operational questions by chaining multiple POS tools
  4. 创建
  5. 向下滚动以查找 代理风格.
  6. 选择 ReAct
  7. 工具集(左侧)→ 添加工具+→ 本地实例
  8. 选择全部5个工具(pos_list_products, pos_get_product, pos_sales_report, pos_inventory_alerts, pos_terminal_status)
  9. 添加到代理
  10. 行为(左侧)→ 将以下内容粘贴到 Instructions
You are an operations assistant for a coffee shop chain. You reason step by step
before acting, following the ReAct pattern strictly.

Available tools:
  - pos_list_products    — browse the product catalogue, optionally by category
  - pos_get_product      — get price and stock for a specific product ID
  - pos_sales_report     — revenue and transaction data, filterable by date and cashier
  - pos_inventory_alerts — products at or below a stock threshold (default: 20 units)
  - pos_terminal_status  — current online/offline status of all POS terminals

For every user question, work through this loop until you have enough information:

  Thought: <reason about what you know and what you still need>
  Action: <name of tool to call>
  Action Input: <parameters to pass>
  Observation: <result returned by the tool>

Repeat Thought / Action / Observation as many times as needed.
When you have enough information, write:

  Thought: I now have enough information to answer.
  Final Answer: <clear, concise response to the user>

Rules:
- Never skip the Thought step — always reason before acting.
- Only call a tool when the Thought step identifies a genuine need for it.
- Base each Action on the Observations you have already collected, not assumptions.
- If a single tool is sufficient, use only that tool — do not make unnecessary calls.

测试ReAct代理(多工具提示)

这些提示要求代理根据中间结果链接工具。

记住 每次您在“”上运行提示时钟后_重置聊天_右上角的图标,几乎是圆形的,一个防晕染的箭头。..

提示 预期重新激活链
“给我做一次全面的商店健康检查” pos_terminal_status → 观察离线终端→ pos_inventory_alerts → 将两者合并为摘要
“哪些低库存商品卖得最多?” pos_inventory_alerts → 提取产品ID→ pos_sales_report → 将股票与收入相关联
“安娜在6月1日卖了什么,这些东西有没有卖完?” pos_sales_report (安娜,6月1日)→ 提取产品ID→ pos_get_product 对于每一个→ 标记低库存
“列出所有烘焙产品并显示其最近的销售情况” pos_list_products (面包店)→ pos_sales_report → 使产品与收入相匹配

第5部分——构建多代理系统

为什么是多智能体?

单个ReAct代理工作良好,但它有局限性:一个代理连续处理所有事情,它的上下文随着每次工具调用而增长,并且没有关注点分离。真实的生产系统将工作分解为 专业代理商 由a协调 主管.

在本部分中,您将围绕第4部分中的商店健康检查场景构建一个三代理系统:

User
  │
  ▼
Store Manager Agent  ◄── supervisor: receives the question, delegates, synthesises
  │              │
  ▼              ▼
Inventory       Operations
Agent           Agent
(stock &        (terminals &
 products)       sales)

商店经理从不直接调用POS工具。它委托给它的两个子代理,等待他们的响应,然后将它们组合成一个答案。

代理风格选择

并非每个代理都需要相同的推理风格。在这个系统中,每个代理都有不同的角色,因此每个代理都具有不同的风格:

代理 风格 为什么
库存代理 默认 从经理那里收到一个有重点的子问题——通常是一两个没有分支的工具调用。ReAct开销在这里没有增加任何东西。
运营代理 默认 同样的推理——一个狭窄的委托问题,很少需要两次以上的连续工具调用。
门店经理代理 交互式推理与行动 这就是编排发生的地方。经理必须决定联系哪些专家,阅读他们的回复,判断是否需要跟进,并综合多个观察结果。这正是我的想法→ 行动→ 观测回路ReAct的设计目的是。

经验法则: 专家做,主管说。



步骤1——创建库存代理

  1. 导航菜单(☰)→构建→ 创建代理+→ 从头开始创建
  2. 姓名: POS Inventory Agent
  3. 说明: Specialist agent for product catalogue, stock levels, and inventory alerts
  4. 创建
  5. 工具集→ 添加工具+→ 本地实例 --选择:
    • pos_list_products
    • pos_get_product
    • pos_inventory_alerts
  6. 添加到代理
  7. 行为→ 说明 --粘贴:
You are an inventory specialist for a coffee shop chain.

You have access to three tools:
  - pos_list_products    — browse the full product catalogue, optionally by category
  - pos_get_product      — get price and current stock for a specific product ID
  - pos_inventory_alerts — list products at or below a stock threshold (default: 20 units)

Answer only inventory and product questions. Be concise. Always include:
  - Which products are critically low or out of stock
  - Current stock levels for any product mentioned
  - Product IDs where relevant so other agents can reference them

步骤2——创建操作代理

  1. 导航菜单(☰)→构建→ 创建代理+→ 从头开始创建
  2. 姓名: POS Operations Agent
  3. 说明: Specialist agent for terminal status and sales performance
  4. 创建
  5. 工具集→ 添加工具+→ 本地实例 --选择:
    • pos_terminal_status
    • pos_sales_report
  6. 添加到代理
  7. 行为→ 说明 --粘贴:
You are an operations specialist for a coffee shop chain.

You have access to two tools:
  - pos_terminal_status  — current online/offline status of all POS terminals
  - pos_sales_report     — revenue and transaction data, filterable by date and cashier

Answer only operations and sales questions. Be concise. Always include:
  - Which terminals are offline and their location
  - Revenue totals and top-performing cashiers when asked about sales
  - Any anomalies that an operations manager should act on

步骤3--创建Store Manager代理

  1. 导航菜单(☰)→构建→ 创建代理+→ 从头开始创建
  2. 姓名: POS Store Manager Agent
  3. 说明: Supervisor agent that coordinates the Inventory and Operations specialists to produce unified store health reports
  4. 创建
  5. 向下滚动以查找 代理风格.
  6. 选择 ReAct
  7. 工具集→ 添加代理+→ 本地实例 --选择:
    • POS Inventory Agent
    • POS Operations Agent
  8. 添加到代理
  9. 行为→ 说明 --粘贴:
You are the store manager for a coffee shop chain. You coordinate two specialist agents
to answer operational questions.

Your specialists:
  - POS Inventory Agent   — handles product catalogue, stock levels, and inventory alerts
  - POS Operations Agent  — handles terminal status and sales performance

For every question:
1. Decide which specialist(s) can answer it.
2. Delegate to them — send a clear, specific sub-question to each.
3. Wait for their responses.
4. Synthesise the results into a single, well-structured answer for the user.

You do NOT call POS tools directly. You delegate entirely to your specialists.

When producing a store health check, always cover:
  - Terminal status (any offline?)
  - Inventory alerts (any items critically low or out of stock?)
  - A recommended action for each issue found

步骤4——测试多智能体系统

打开 门店经理代理 在聊天中,尝试这些提示。观察主管如何委派,然后合并结果。

提示 应该发生什么
“给我做一次全面的商店健康检查” 经理同时委派两名专家;结合终端与库存报告
“本周哪些低库存商品卖得最多?” 经理向库存代理询问低库存商品,然后向运营代理询问这些产品的销售数据
“T3重新上线了吗?我们有足够的库存重新开放吗?” 经理向运营代理询问T3的情况,向库存代理询问库存水平,并合并成一份准备情况报告

观察内容:

  • 门店经理的推理轨迹显示,它向专业客服发出了子问题
  • 每位专家只使用自己的工具,没有交叉污染
  • 最终的答案比任何单个代理单独产生的答案都要丰富

接下来是什么?走得更远

您刚刚构建了一个跨多个工具推理的代理,这是当今生产中每个严肃的代理系统的基础。

现在再往前推。试着制作自己的提示。交换指令。看看你是否可以打破或改进ReAct循环。理解代理人工智能的最佳方法是通过实验建立直觉——现在你有了一个实时系统可以进行实验。

当你准备好了, 进入下一个挑战:

编排Hackthon。....

您将使用由合成医院数据集(患者记录、生命体征、处方、药物相互作用等)支持的更丰富的MCP服务器。你的挑战:从头开始设计和构建一个多代理系统。没有护栏,没有分步说明。只是工具,需要解决的问题,以及你在这里学到的一切。

这就是建筑师成为人工智能工程师的地方。


快速参考——虚假数据

产品

ID 名称 类别 价格 库存
P001 浓缩混合咖啡 饮料 12.99美元 142
P002 燕麦牛奶(1升) 乳制品替代品 2.49美元 38
P003 牛角面包 面包房 3.50美元 24
P004 绿茶抹茶 饮料 9.99美元 76
P005 苏打水(500毫升) 饮料 1.20美元 200美元
P006 蓝莓松饼 面包房 3.99美元 18 ⚠
P007 全脂牛奶(1升) 乳制品 1.89美元 55美元
P008 黑巧克力棒 零食 4.50美元 90
P009 格兰诺拉麦片吧 小吃 2.20美元 11 ⚠
P010 橙汁(1升) 饮料 3.75美元 0 🚫

收银台和终端

终端 位置 收银台 状态
T1 前台 安娜 在线
T2 驾车穿越 Ben 在线
T3 自助服务 克拉拉 离线