MCP Server 使用指南

让 Claude、Cursor、Windsurf 等 AI 编程助手直接调用 RoboParts 选型引擎,在对话中完成机器人零部件的智能选型与兼容性分析。

Model Context Protocol

📚 什么是 MCP Server

MCP (Model Context Protocol) 是 Anthropic 推出的开放协议,用于让 AI 模型与外部工具/数据源进行标准化交互。RoboParts MCP Server 将平台的选型引擎、零部件数据库、兼容性分析等能力封装为 MCP 工具,使 AI 编程助手能够在对话中直接调用这些能力。

接入后,您只需用自然语言描述需求(如"推荐人形机器人的执行器"),AI 助手便会自动调用 component_search 工具,返回匹配的零部件列表。无需手动构造 HTTP 请求,开发效率大幅提升。

当前 RoboParts MCP Server 提供 5 个工具,覆盖零部件搜索、详情查询、兼容性检查、智能推荐和 BOM 导出等核心场景。

🔧 工具列表

以下 5 个 MCP 工具可供 AI 编程助手调用,每个工具包含名称、功能描述和参数说明。

component_search
搜索零部件数据库,支持按品类、关键词、性能指标筛选。返回匹配的零部件列表,包含基础参数和评分。
querystring - 搜索关键词
categorystring - 品类(actuators/sensors/chips 等)
limitnumber - 返回数量(默认 10)
get_component_detail
获取指定零部件的详细信息,包含完整参数表、兼容协议、参考价格、供应商信息等。
component_idstring - 零部件 ID(如 ACT-001)
check_compatibility
检查两个或多个零部件之间的兼容性,分析通信协议、电气接口、物理尺寸等是否匹配,返回兼容性报告。
component_idsstring[] - 零部件 ID 数组
recommend_components
基于应用场景和需求参数进行智能推荐。根据性能匹配度、成本效益、生态兼容性、成熟度等维度综合评分排序。
applicationstring - 应用场景(humanoid/quadruped/robot_arm/amr/industrial)
requirementsobject - 需求参数(torque_min, weight_max, voltage 等)
categoriesstring[] - 品类筛选
count_per_categorynumber - 每品类返回数量
export_bom
将选定的零部件列表导出为 BOM(物料清单)格式,包含物料编码、名称、规格、数量、预估单价等,支持 JSON 和 CSV 格式。
component_idsstring[] - 零部件 ID 数组
formatstring - 输出格式(json/csv,默认 json)
project_namestring - 项目名称

配置指南

将 RoboParts MCP Server 添加到您的 AI 编程工具中,以下是各平台的配置方法。

claude_desktop_config.json
{
  "mcpServers": {
    "roboparts": {
      "command": "node",
      "args": ["/path/to/roboparts/mcp-server/index.js"],
      "env": {
        "ROBOPARTS_API_KEY": "gtk_your_api_key_here"
      }
    }
  }
}

配置文件路径:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
.cursor/mcp.json
{
  "mcpServers": {
    "roboparts": {
      "command": "node",
      "args": ["/path/to/roboparts/mcp-server/index.js"],
      "env": {
        "ROBOPARTS_API_KEY": "gtk_your_api_key_here"
      }
    }
  }
}

在项目根目录下创建 .cursor/mcp.json 文件,Cursor 会自动加载 MCP Server。

.windsurf/mcp.json
{
  "mcpServers": {
    "roboparts": {
      "command": "node",
      "args": ["/path/to/roboparts/mcp-server/index.js"],
      "env": {
        "ROBOPARTS_API_KEY": "gtk_your_api_key_here"
      }
    }
  }
}

在项目根目录下创建 .windsurf/mcp.json 文件,Windsurf 会自动识别并加载。

快速体验

输入自然语言查询,直接调用选型引擎 API 查看效果。需要有效的 API Key。

在线测试选型引擎

API Key *
应用场景
需求描述(自然语言)
本次调用将消耗 2 积分

🐍 Python SDK 示例

如果您更习惯使用 Python,可以通过 HTTP 直接调用选型引擎 API。以下是一个完整的示例。

selection_example.py
# RoboParts 智能选型引擎 - Python SDK 示例

import requests

API_BASE = "https://roboparts.cc"
API_KEY = "gtk_your_api_key_here"  # 替换为您的 API Key

# 1. 智能选型推荐
response = requests.post(
    f"{API_BASE}/api/selection/engine",
    headers={"Content-Type": "application/json"},
    json={
        "api_key": API_KEY,
        "application": "humanoid",
        "requirements": {
            "torque_min": 10,
            "weight_max": 500,
            "voltage": 48,
            "ros_required": True,
        },
        "categories": ["actuators", "sensors"],
        "count_per_category": 3,
    }
)
result = response.json()

if result.get("success"):
    for category, items in result.get("recommendations", {}).items():
        print(f"\n=== {category} ===")
        for item in items:
            print(f"  {item['name']} ({item['component_id']})")
            print(f"    评分: {item.get('score', 'N/A')} | 价格: {item.get('price', 'N/A')}")
else:
    print(f"Error: {result.get('error', 'Unknown')}")

# 2. 查询余额
balance_resp = requests.get(
    f"{API_BASE}/api/credits/balance?key={API_KEY}"
)
print(f"\n当前积分: {balance_resp.json().get('credits', 0)}")