MCP客户端工具

OpenClaw MCP客户端是一个通用MCP客户端,用于连接和管理多种MCP服务器,支持HTTP MCP协议和OAuth 2.0认证,适用于食品订购、杂货配送等多种服务。

  • by ImrKhn03
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 ImrKhn03/openclaw-mcp-client

使用说明

OpenClaw MCP客户端

快速开始

  1. 运行安装脚本:

    ./install.sh
    
  2. 检查OAuth状态:

    npm run oauth:status
    
  3. 配置任何需要OAuth的服务器:

    npm run oauth <server-name>
    
  4. 测试已安装的工具:

    node index.js # List all MCP servers
    npm run list-tools # List available tools
    

故障排除

  • Node.js版本: 确保安装了Node.js≥18。
  • 服务器问题: 检查以下配置 servers/ 目录。
  • 依赖性问题: 跑 npm install 再次或检查 package.json 依赖性。
   ___                   _____ _                  __  __  _____ _____  
  / _ \ _ __   ___ _ __ / ____| |                |  \/  |/ ____|  __ \ 
 | | | | '_ \ / _ \ '_ | |    | | __ ___      __ | \  / | |    | |__) |
 | |_| | |_) |  __/ | || |____| |/ _` \ \ /\ / / | |\/| | |    |  ___/ 
  \___/| .__/ \___|_| | \_____|_|\__,_|\ V  V /  |_|  |_|\___|_|     
       | |                               \_/\_/                        
       |_|                                                             

🦞 由Toki建造 -将OpenClaw连接到任何MCP服务器!

将您的OpenClaw助手连接到整个MCP(模型上下文协议)生态系统-Swiggy、Zomato、GitHub、Slack、数据库和数百个其他服务!

📚 文档

🚀 这是什么?

这是一个 通用MCP客户端 OpenClaw允许您:

  • 🍛 从Swiggy和Zomato订购食物
  • 🛒 通过Swiggy Instamart购买杂货
  • 🍽️ 通过Swiggy Dineout预订餐厅餐桌
  • 🔌 连接到任何MCP服务器(GitHub、Slack、数据库、API等)
  • 🤖 使用自然语言与所有这些服务进行交互

✨ 特性

  • ✅ HTTP MCP协议 -全面实施MCP 2024-11-05
  • ✅ OAuth 2.0支持 -为需要它的服务提供安全身份验证
  • ✅ 多服务器管理 -同时连接到无限制的MCP服务器
  • ✅ 动态工具发现 -自动查找并注册所有可用工具
  • ✅ 优雅的错误处理 -即使在某些服务器需要身份验证时也能工作
  • ✅ 易于配置 -只需将JSON文件放入 servers/ 目录
  • ✅ OpenClaw集成 -与自然语言无缝集成技能

📦 安装

# Clone into your OpenClaw skills directory
cd ~/.openclaw/workspace/skills
git clone https://github.com/ImrKhn03/openclaw-mcp-client.git
cd openclaw-mcp-client

# Install dependencies
npm install

# Test it
node index.js

🎯 快速开始

1.测试安装

node index.js

您应该看到:

🦞 OpenClaw MCP Client v1.0.0
   Built by Toki

[MCP Manager] Loading 3 server configs...
...
✨ Initialization complete!

2.查看可用工具

node examples/list-tools.js

3.尝试一个示例(需要OAuth)

node examples/order-food.js

🔧 配置

预配置服务器

三台服务器开箱即用:

  • Swiggy Food (servers/swiggy-food.json)-点餐
  • Swiggy Instamart (servers/swiggy-instamart.json)-杂货配送
  • 佐马托 (servers/zomato.json)-食品订购和发现

添加新服务器

在中创建JSON文件 servers/:

{
  "name": "my-server",
  "type": "http",
  "url": "https://mcp.example.com",
  "enabled": true,
  "description": "My custom MCP server",
  "oauth": {
    "required": false
  }
}

使用OAuth:

{
  "name": "github",
  "type": "http",
  "url": "https://mcp.github.com",
  "enabled": true,
  "oauth": {
    "required": true,
    "clientId": "your_client_id",
    "clientSecret": "your_client_secret",
    "authUrl": "https://github.com/login/oauth/authorize",
    "tokenUrl": "https://github.com/login/oauth/access_token",
    "scopes": ["repo", "user"]
  }
}

重新启动OpenClaw-新服务器会自动被发现!

🔐 OAuth设置

对于需要身份验证的服务器(Swiggy、Zomato):

const OpenClawMCPClient = require('./index');

const client = new OpenClawMCPClient();
await client.initialize();

// Setup OAuth for Swiggy Food
await client.setupOAuth('swiggy-food', {
  clientId: 'your_client_id',
  clientSecret: 'your_client_secret',
  authUrl: 'https://mcp.swiggy.com/food/oauth/authorize',
  tokenUrl: 'https://mcp.swiggy.com/food/oauth/token',
  scopes: ['food.read', 'food.order']
});

该技能将:

  1. 打印授权URL
  2. 打开本地回调服务器
  3. 等待您在浏览器中授权
  4. 自动保存访问令牌
  5. 重新连接身份验证

📚 使用示例

搜索餐厅(Swiggy)

const result = await client.callTool('swiggy-food', 'search_restaurants', {
  location: { lat: 12.9351929, lng: 77.62448069999999 },
  query: 'biryani'
});

浏览菜单

const menu = await client.callTool('swiggy-food', 'get_menu', {
  restaurantId: '12345',
  location: { lat: 12.9351929, lng: 77.62448069999999 }
});

杂货搜索(Instamart)

const products = await client.callTool('swiggy-instamart', 'search_products', {
  location: { lat: 12.9351929, lng: 77.62448069999999 },
  query: 'milk'
});

看 examples/ 完整工作示例目录!

🤖 OpenClaw集成

一旦作为技能安装,请使用自然语言:

"Order biryani from Swiggy"
→ Searches restaurants, shows menu, helps order

"Find Italian restaurants near me on Zomato"
→ Uses Zomato MCP to search

"Add milk to my Instamart cart"
→ Uses Swiggy Instamart MCP

技能自动:

  • 检测要使用的MCP服务器
  • 如果需要,处理身份验证
  • 调用适当的工具
  • 自然格式化结果
  • 完成请求的操作

📊 项目结构

openclaw-mcp-client/
├── lib/
│   ├── http-transport.js    # HTTP MCP protocol implementation
│   ├── mcp-client.js         # Single server client
│   ├── mcp-manager.js        # Multi-server manager
│   └── oauth.js              # OAuth 2.0 handler
├── servers/
│   ├── swiggy-food.json      # Swiggy Food config
│   ├── swiggy-instamart.json # Instamart config
│   └── zomato.json           # Zomato config
├── examples/
│   ├── list-tools.js         # List all available tools
│   └── order-food.js         # Food ordering example
├── index.js                  # Main entry point
├── SKILL.md                  # OpenClaw skill definition
├── package.json              # Dependencies
└── README.md                 # This file

🧪 测试

# List all tools from all servers
node examples/list-tools.js

# Test food ordering (requires OAuth)
node examples/order-food.js

# Run main CLI
node index.js

🛠️ 发展

添加功能

  1. 克隆该仓库
  2. 创建要素分支
  3. 进行更改
  4. 添加测试
  5. 提交拉取请求

运行测试

npm test

(测试即将到来!)

📖 技术细节

MCP协议支持

  • 版本:药品监督管理委员会2024-11-05
  • 运输:HTTP(计划使用stdio和SSE)
  • 特性:工具、资源、提示
  • 认证:OAuth 2.0

HTTP传输

HTTP传输层通过HTTPS/HTTP实现MCP协议:

  • JSON-RPC风格的请求
  • 正确的错误处理
  • 基于令牌的身份验证
  • 超时管理

多服务器架构

管理器可以处理无限制的并发MCP服务器:

  • 每台服务器独立运行
  • 共享工具注册表
  • 集中错误处理
  • 适度降级(服务器可以在不损坏其他服务器的情况下发生故障)

🤝 贡献

由...建造 国 感谢@ImrKhn03和OpenClaw社区!

欢迎捐款:

  • 🐛 错误报告
  • ✨ 功能请求
  • 📝 文档改进
  • 🧪 测试
  • 🔌 新的MCP服务器配置

📜 许可证

MIT许可证-请参阅 许可证 文件

版权所有(c)2026托基(OpenClaw助理)和伊姆兰·汗

🔗 链接

  • GitHub: https://github.com/ImrKhn03/openclaw-mcp-client
  • 爪毂:(即将出版!)
  • MCP规范: https://spec.modelcontextprotocol.io/
  • 开爪: https://github.com/openclaw/openclaw
  • 旋转MCP: https://github.com/Swiggy/swiggy-mcp-server-manifest
  • Zomato MCP: https://github.com/Zomato/mcp-server-manifest

💬 支持

  • 在GitHub上打开一个问题
  • 检查示例目录
  • 阅读SKILL.md了解OpenClaw集成的详细信息

🙏 致谢

  • 内置于❤️ 通过 国 (OpenClaw助理)
  • 创建于 伊姆兰汗 (@ImrKhn03)
  • 受到不断发展的MCP生态系统的启发
  • 感谢Swiggy和Zomato提供MCP服务器

状态: ✅ 功能齐全(某些服务器需要OAuth设置)
版本: 1.0.0
最后更新:2026年2月3日
由...建造托基:🦞

让OpenClaw更加强大,一次一个MCP服务器!