🎨 RL MCP服务器电缆
训练人工智能自主创作艺术
](https://www.npmjs.com/package/cables-rl-mcp)   
*集成了以下功能的MCP服务器 Cables.gl 使用强化学习进行可视化编程,用于自主视觉参数优化和生成艺术探索。*
______________________________________________________________________
🌟 什么是RL电缆?
电缆RL连接 克劳德代码 和 Cables.gl (强大的视觉着色器系统)和 强化学习,允许AI代理:
- 🎯 发现 自动生成美观的着色器参数
- 🔄 优化 基于奖励学习的视觉输出
- 🖼️ 生成 探索参数空间的独特生成艺术
- 📊 学习 通过审美奖励功能看起来“好”的东西
将其视为 自主视觉艺术家 探索您的Cables.gl补丁的创造性可能性。
✨ 特性
| 特性 | 描述 |
|---|---|
| 🎮 实时控制 | 通过浏览器自动化修改Cables.gl参数 |
| 🧠 RL集成 | 支持PPO、SAC和TD3算法 |
| 🎨 审美奖励 | 多分量奖励函数(熵、色彩和谐、运动连贯性) |
| 🔍 新奇探索 | 发现新视觉领域的额外奖励 |
| 💾 会话保持 | 保存/恢复探索会话 |
| 📸 自动捕获 | 自动保存高奖励帧 |
| ⚡ 高性能 | \<0.01ms奖励计算,\<0.02ms动作生成 |
🏗️ 建筑
┌─────────────────────────────────────────────────────────────┐
│ Claude Code (Client) │
│ │
│ Your prompts ←→ cables-rl MCP ←→ Playwright MCP │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────┼─────────────┐
▼ ▼ ▼
┌───────────┐ ┌───────────┐ ┌───────────┐
│ RL │ │ Cables.gl │ │ Reward │
│ Agent │ │ Browser │ │ System │
│(PPO/SAC) │ │ Control │ │(Aesthetic)│
└───────────┘ └───────────┘ └───────────┘📦 安装
先决条件
- Node.js 18+
- Python 3.8+
- 克劳德代码 命令行界面
快速安装
# Clone the repository
git clone https://github.com/adkr1989/cables-rl-mcp.git
cd cables-rl-mcp
# Install Node.js dependencies
npm install
# Install Python dependencies
pip install numpy
# Build the project
npm run build配置Claude代码
添加到您的Claude Code MCP设置中(~/.claude.json 或项目设置):
{
"mcpServers": {
"cables-rl": {
"type": "stdio",
"command": "node",
"args": ["/path/to/cables-rl-mcp/dist/index.js"],
"env": {
"PYTHON_PATH": "python",
"OUTPUT_DIR": "/path/to/cables-rl-mcp/output"
}
},
"playwright": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@playwright/mcp@latest"]
}
}
}🚀 快速开始
1.加载Cables.gl补丁
在克劳德代码中,问:
Load the Anomaly patch from Cables.gl and show me what parameters are available2.探索参数
Change the blur amount to 15 and the chromatic aberration to 8, then take a screenshot3.初始化RL代理
Initialize an SAC agent to optimize the Timer speed (0-5) and Blur amount (0-20) for aesthetic visuals4.自主探索
Run autonomous exploration for 5 minutes, saving any interesting frames🛠️ MCP工具
Cables.gl控制
| 工具 | 说明 |
|---|---|
cables_load_patch | 在浏览器中加载Cables.gl补丁 |
cables_set_parameter | 实时设置参数值 |
cables_get_parameters | 获取所有可用参数 |
cables_batch_set_parameters | 高效地设置多个参数 |
cables_get_frame_metrics | 捕获帧并计算视觉指标 |
RL代理
| 工具 | 说明 |
|---|---|
rl_init_agent | 初始化RL代理(PPO/SAC/TD3) |
rl_get_action | 从代理获取下一步操作 |
rl_update_reward | 向代理发送奖励信号 |
rl_training_step | 执行培训步骤 |
rl_save_checkpoint | 保存代理状态 |
rl_load_checkpoint | 加载代理状态 |
自主探索
| 工具 | 说明 |
|---|---|
rl_autonomous_explore | 运行自主视觉探索 |
rl_stop_exploration | 停止运行探索 |
rl_get_exploration_status | 获取探索状态 |
🎨 奖励系统
审美奖励功能结合了多个组成部分:
reward = (
0.3 * entropy_score + # Visual complexity
0.2 * color_harmony + # Color distribution
0.2 * motion_coherence + # Smooth motion
0.2 * novelty_bonus - # Exploration bonus
0.1 * fps_penalty # Performance penalty
)| 组件 | 描述 |
|---|---|
| 熵分数 | 奖励平衡的视觉复杂性(不太简单,不嘈杂) |
| 色彩和谐 | 奖励均衡的颜色分布 |
| 运动一致性 | 奖励平稳、有意的运动而不是抖动 |
| 新奇奖励 | 探索新参数区域的奖励 |
| FPS处罚 | 惩罚损害性能的参数组合 |
📊 演出
| 度量 | 结果 |
|---|---|
| 奖励计算 | 0.007毫秒 |
| 动作生成 | 0.14毫秒 |
| 理论训练速度 | 150+步/秒 |
| Cables.gl FPS | 145 FPS |
📁 项目结构
cables-rl-mcp/
├── src/
│ ├── index.ts # MCP server entry point
│ ├── types.ts # TypeScript definitions
│ ├── tools/
│ │ ├── cables-control.ts # Cables.gl browser automation
│ │ ├── rl-agent.ts # RL agent bridge
│ │ ├── reward-system.ts # Visual metrics & rewards
│ │ └── training-loop.ts # Autonomous training
│ └── bridge/
│ └── python-bridge.ts # Python process communication
├── python/
│ ├── agent_wrapper.py # RL agent wrapper
│ ├── reward_functions.py # Aesthetic reward calculations
│ └── env_cables.py # Gym environment
├── package.json
├── tsconfig.json
└── README.md🤝 贡献
欢迎投稿!请随时提交拉取请求。
- 克隆该仓库
- 创建功能分支(
git checkout -b feature/AmazingFeature) - 提交您的更改(
git commit -m 'Add some AmazingFeature') - 推到分支(
git push origin feature/AmazingFeature) - 打开拉取请求
📜 许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
🙏 致谢
______________________________________________________________________
由以下材料制成❤️ 通过 A_开发
*通过视觉探索赋予人工智能创造力*
