OpenClaw的RapidAPI MCP技能
通过模型上下文协议(MCP)访问RapidAPI端点的AI驱动集成
 
概述
此技能可帮助OpenClaw AI助手访问RapidAPI的MCP(模型上下文协议)服务器。它提供了一个模板和指南,用于配置任何RapidAPI MCP端点,而不是为特定API预先配置。
这是一个模板技能 -使用您自己的RapidAPI订阅进行配置。
特性
- 基于模板 -添加任何RapidAPI MCP端点
- 直接JSON-RPC访问 -通过直接HTTP调用绕过mcporter stdio问题
- 灵活的API支持 -适用于Twitter、YouTube或任何支持RapidAPI MCP的端点
- 兼容OpenClaw -与OpenClaw AI助手无缝集成
安装
- 将此技能克隆到您的OpenClaw技能目录
- 配置您的RapidAPI凭据(见下文)
- 重新启动OpenClaw
快速开始
步骤1:获取您的RapidAPI密钥
- 创建一个 无效账户
- 订阅所需的API(推特、YouTube等)
- 从仪表板复制API密钥
步骤2:在Playground中启用MCP
- 在RapidAPI上访问您想要的API
- 打开 操场
- 测试一个有效的端点
- 点击“MCP”按钮 启用MCP访问
- 复制所示的MCP配置
步骤3:配置您的API
将您的API添加到技能中:
# Using mcporter
mcporter config add "My-API" --command npx --args '["mcp-remote","https://mcp.rapidapi.com","--header","x-api-host: YOUR_HOST.p.rapidapi.com","--header","x-api-key: YOUR_KEY"]'或者使用直接JSON-RPC(推荐):
# Base URL
URL="https://mcp.rapidapi.com/"
# Your API credentials
HOST="YOUR_HOST.p.rapidapi.com"
KEY="your-rapidapi-key"
# Initialize connection
curl -s -X POST "$URL" \
-H "Content-Type: application/json" \
-H "x-api-host: $HOST" \
-H "x-api-key: $KEY" \
-d '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"openclaw","version":"1.0"}},"id":0}'步骤4:列出可用工具
curl -s -X POST "https://mcp.rapidapi.com/" \
-H "Content-Type: application/json" \
-H "x-api-host: YOUR_HOST.p.rapidapi.com" \
-H "x-api-key: YOUR_KEY" \
-d '{"jsonrpc":"2.0","method":"tools/list","params":{},"id":1}'第五步:调用工具
curl -s -X POST "https://mcp.rapidapi.com/" \
-H "Content-Type: application/json" \
-H "x-api-host: YOUR_HOST.p.rapidapi.com" \
-H "x-api-key: YOUR_KEY" \
-d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"TOOL_NAME","arguments":{"param":"value"}},"id":2}'配置
查找您的API主机
在Playground中启用MCP后,您的配置将显示:
{
"mcpServers": {
"API Name": {
"command": "npx",
"args": [
"mcp-remote",
"https://mcp.rapidapi.com",
"--header",
"x-api-host: YOUR_HOST.p.rapidapi.com",
"--header",
"x-api-key: YOUR_KEY"
]
}
}
}这 YOUR_HOST.p.rapidapi.com 部分是您的API主机。
与Mcporter一起使用
# Add your API
mcporter config add "My-Twitter-API" \
--command npx --args '["mcp-remote","https://mcp.rapidapi.com","--header","x-api-host: twitter241.p.rapidapi.com","--header","x-api-key: YOUR_KEY"]'
# List tools
mcporter list "My-Twitter-API" --schema故障排除
“终结点不存在”错误
- ✅ 确保RapidAPI Playground中启用了MCP
- ✅ 点击API游乐场中的“MCP”按钮激活
- ✅ 验证您的API密钥是否有权访问终结点
身份验证问题
- 检查您的RapidAPI订阅是否处于活动状态
- 验证API密钥是否正确
- 确保您已订阅特定的API
常见API主机
| API | 主机 |
|---|---|
| 推特/X | twitter241.p.rapidapi.com |
油管 yt-api.p.rapidapi.com | |
| 流媒体可用性 | streaming-availability.p.rapidapi.com |
需求
curl命令行工具- 具有活动订阅的RapidAPI帐户
- OpenClaw人工智能助手
关键词
RapidAPI、MCP、OpenClaw、API集成、JSON-RPC、AI助手、ChatGPT、Claude、LLM工具、Twitter API、YouTube API、API自动化
许可证
MIT许可证-有关详细信息,请参阅许可证文件。
