Plytix MCP服务器
A. 轻量级、无状态的模型上下文协议(MCP)服务器 它为AI助手提供了对Plytix PIM(产品信息管理)数据的实时访问。该服务器使人工智能工具(如Claude Desktop、Claude移动应用程序和其他MCP客户端)能够直接从Plytix API搜索、查找和检索产品信息。
注: 这是一个用于读写操作的无状态实时API工具。有关同步、缓存或ETL工作流,请参阅 补给线同步.
特性
- 47个MCP工具通过stdio,44个通过远程工作器
- 智能产品查找 具有自动标识符检测功能(SKU、MPN、GTIN、标签)
- 家庭与遗产追踪 具有overwriten_attributes支持
- 架构发现 用于属性和搜索筛选器
- 自动身份验证 使用令牌刷新
- 费率限制处理 指数回退
- 零持久性 --无状态,无需数据库
- 远程服务器支持 --部署到Cloudflare Workers以进行移动/web访问
安装
先决条件
- Node.js 18+ (推荐节点20+)
- Plytix个人信息管理账户 具有API访问权限
设置
- 克隆并安装:
git clone https://github.com/Supplyline/plytix-mcp.git
cd plytix-mcp
npm install- 配置凭据:
cp .env.example .env
# Edit .env with your Plytix API credentials- 构建项目:
npm run build用法
使用克劳德桌面
添加到您的Claude Desktop MCP配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"plytix": {
"command": "node",
"args": ["/path/to/plytix-mcp/dist/index.js"],
"env": {
"PLYTIX_API_KEY": "your_api_key_here",
"PLYTIX_API_PASSWORD": "your_api_password_here"
}
}
}
}独立
npm start # Production mode
npm run dev # Development with hot reload远程服务器(Cloudflare Workers)
部署为远程MCP服务器,以便从Claude移动应用程序、web客户端或共享团队访问。
快速部署
# Install dependencies (includes wrangler)
npm install
# Login to Cloudflare
wrangler login
# Deploy to Cloudflare Workers
npm run deploy使用远程服务器
部署后,使用部署的URL和您的Plytix凭据从任何MCP客户端连接:
# With Claude Desktop (using mcp-remote)
npx mcp-remote https://plytix-mcp.your-subdomain.workers.dev/mcp \
--header "X-Plytix-API-Key: YOUR_API_KEY" \
--header "X-Plytix-API-Password: YOUR_API_PASSWORD"远程工作者暴露了44个工具。它故意省略了三个仅限本地的标识符实用程序: identifier_detect, identifier_normalize,以及 match_score.
本地开发
npm run dev:worker # Start local worker at localhost:8787
npm run test:worker # Test the worker endpoints有关详细的设置说明,请参阅 docs/remote-setup.md.
可用工具
产品工具
| 工具 | 说明 |
|---|---|
products_lookup | 通过任何标识符进行智能查找(自动检测ID、SKU、MPN、GTIN、标签) |
products_get | 按ID获取单个产品,并提供完整的详细信息 overwritten_attributes |
products_get_full | 获取一个包含相关系列、变体、类别和资产的产品 |
products_search | 具有过滤器、分页和排序功能的高级搜索 |
products_find | 简单的多条件搜索(SKU、MPN、MNO、GTIN、标签、模糊) |
products_create | 创建新产品 |
products_update | 产品字段/属性的部分更新 |
products_assign_family | 分配或取消分配产品系列 |
products_set_attribute | 一个属性值的原子集 |
products_clear_attribute | 原子清除一个属性值 |
家庭工具
| 工具 | 说明 |
|---|---|
families_list | 列出或搜索产品系列 |
families_get | 获取具有链接属性的单个家庭 |
families_create | 创建新产品系列 |
families_link_attribute | 将一个或多个属性链接到族 |
families_unlink_attribute | 从族中取消链接一个或多个属性 |
families_list_attributes | 列出直接链接到族的属性 |
families_list_all_attributes | 列出直接和继承的族属性 |
属性和筛选工具
| 工具 | 说明 |
|---|---|
attributes_list | 列出所有属性(系统+自定义)及其类型和选项 |
attributes_get | 获取一个属性标签的完整元数据 |
attributes_get_options | 获取可选属性的允许值 |
attributes_filters | 已弃用的产品筛选器发现别名 |
products_filters | 获取产品搜索筛选器元数据 |
assets_filters | 获取资产搜索筛选器元数据 |
relationships_filters | 获取关系搜索筛选器元数据 |
资产工具
| 工具 | 说明 |
|---|---|
assets_get | 按ID获取一项资产 |
assets_search | 搜索帐户资产 |
assets_update | 更新资产元数据(filename, categories) |
assets_list | 列出链接到产品的资产(图像、视频、文档) |
assets_link | 将资产链接到产品 |
assets_unlink | 将资产与产品解除链接 |
分类工具
| 工具 | 说明 |
|---|---|
categories_search | 搜索现有类别 |
categories_list | 列出与产品关联的类别 |
categories_link | 将类别链接到产品 |
categories_unlink | 从产品中取消类别链接 |
变体工具
| 工具 | 说明 |
|---|---|
variants_create | 在父产品下创建变体 |
variants_link | 将现有产品链接为变体 |
variants_unlink | 在不删除变体的情况下,将其从父级中取消链接 |
variants_list | 列出产品的变体 |
variants_resync | 重置变量属性以继承父值 |
关系工具
| 工具 | 说明 |
|---|---|
relationships_get | 按ID获取关系定义 |
relationships_search | 搜索关系定义 |
relationships_link_product | 在关系中链接一个相关的产品行 |
relationships_unlink_product | 取消链接关系中的一个相关产品行 |
relationships_set_quantity | 更新一个相关产品行的数量 |
标识符实用程序(仅限Stdio)
| 工具 | 说明 |
|---|---|
identifier_detect | 从原始值中检测标识符类型 |
identifier_normalize | 规范标识符以进行匹配 |
match_score | 分数标识符产品匹配置信度 |
除了最后一节中的三个标识符实用程序外,远程工作器还公开了上述所有工具。
智能查询系统
这 products_lookup 该工具自动检测标识符类型并使用分阶段搜索策略:
检测优先级:
- MongoDB对象ID(24个字符十六进制)→
id(置信度:1.0) - GTIN(8/12/13/14位数字)→
gtin(置信度:0.95) - 包含空格→
label(置信度:0.9) - 虚线字母数字→
mpn(置信度:0.8) - 带分隔符的字母数字→
sku(置信度:0.7)
搜索策略(按顺序):
- 直接ID查找(如果检测为ID)
- 精确的字段匹配(SKU、GTIN、MPN、MNO)
- 跨多个字段的文本搜索
- 广泛的LIKE搜索(最后手段)
例子:
Input: "LMI-PD-123"
→ Detected as: sku (confidence: 0.7)
→ Tries: sku_eq, mpn fields, text_search, broad_like
→ Returns: best match with confidence score继承跟踪
产品退货 overwritten_attributes 数组列出了哪些属性是显式设置的(不是从族继承的)。将其与以下内容一起使用:
product_family_id--该产品所属的家族families_get--检索族级默认值- 比较以确定继承值与覆盖值
配置
环境变量
| 变量 | 必填 | 默认 | 描述 |
|---|---|---|---|
PLYTIX_API_KEY | ✅ | — | 您的Plytix API密钥 |
PLYTIX_API_PASSWORD | ✅ | — | 您的Plytix API密码 |
PLYTIX_API_BASE | ❌ | https://pim.plytix.com | Plytix API基础URL |
PLYTIX_AUTH_URL | ❌ | https://auth.plytix.com/auth/api/get-token | 身份验证端点 |
PLYTIX_MPN_LABELS | ❌ | ["attributes.mpn"] | MPN属性标签的JSON数组 |
PLYTIX_MNO_LABELS | ❌ | ["attributes.model_no"] | MNO属性标签的JSON数组 |
发展
脚本
| 命令 | 描述 |
|---|---|
npm run dev | 具有热重载功能的开发服务器(stdio) |
npm run dev:worker | Cloudflare Workers开发服务器 |
npm run build | 将TypeScript构建为JavaScript |
npm run deploy | 部署到Cloudflare Workers |
npm start | 启动生产服务器(stdio) |
npm test | 运行单元测试(vitest) |
npm run test:watch | 在监视模式下运行测试 |
npm run test:mcp | 测试MCP协议握手 |
npm run test:worker | 测试工作者端点 |
npm run test:all | 构建+单元+集成+MCP测试 |
npm run typecheck | 无建筑类型检查 |
建筑
src/
index.ts # MCP server entry point (stdio transport)
worker.ts # Cloudflare Worker entry point (HTTP transport)
client.ts # Plytix API client with auth & rate limiting
worker-client.ts # Worker-compatible client (BYOK credentials)
worker-lookup.ts # Worker-compatible smart lookup
types.ts # TypeScript types
lookup/
identifier.ts # Identifier type detection
lookup.ts # Smart lookup with staged search
tools/
products.ts # Product tools (lookup, get, search, find, write ops)
families.ts # Family tools (list, get, create, attribute membership)
attributes.ts # Attribute metadata + filter discovery tools
product-attributes.ts # Atomic product attribute write tools
assets.ts # Asset get/search/update + product asset link tools
categories.ts # Category search + product category link tools
variants.ts # Variant lifecycle tools
relationships.ts # Relationship discovery + product relationship write tools
supplyline/ # Supplyline-specific customizations
wrangler.toml # Cloudflare Workers configuration
docs/
remote-setup.md # Remote server setup guide设计原则
此MCP服务器是故意的 无状态和轻量级:
- 无数据库 -所有查询都直接进入Plytix API
- 无同步/缓存层 --每次请求都有新的数据
- 没有背景工作 --仅限请求/响应
- 临时内存缓存 --短暂(60秒)请求重复数据删除,重新启动时清除
对于ETL、同步或持久缓存需求,请使用单独的工具,如 补给线同步.
许可证
MIT许可证——见 许可证 文件以获取详细信息。
