MCP Workflow Skill
Quick Reference
CODEBLOCK0
Overview
This skill implements workflow automation using the Model Context Protocol (MCP), enabling:
- - Prompt Chains: Multi-step prompt sequences
- Dynamic Workflows: Context-aware adaptation
- Resource Integration: File/data embedding
- Cross-Server Coordination: Multi-MCP orchestration
Workflow Patterns
1. Prompt Chain Pattern
CODEBLOCK1
2. Dynamic Prompt Pattern
CODEBLOCK2
3. Resource Embedding Pattern
CODEBLOCK3
4. External Trigger Pattern
CODEBLOCK4
Built-in Templates
| Template | Description | Use Case |
|---|
| INLINECODE0 | Weekly meal planning | Nutrition, shopping lists |
| INLINECODE1 |
Automated code review | PR analysis, quality checks |
|
weekly-report | Status report generation | Team updates, metrics |
|
documentation-generator | Doc generation | API docs, changelogs |
MCP Server Features
Resources
- -
file://{path} - File system access - INLINECODE5 - Memory storage
- INLINECODE6 - Configuration values
Tools
- -
workflow.run - Execute workflow - INLINECODE8 - List workflows
- INLINECODE9 - Validate workflow JSON
- INLINECODE10 - Render prompt template
Prompts
- -
chain:plan - Planning prompt - INLINECODE12 - Generation prompt
- INLINECODE13 - Review prompt
Example Usage
Meal Planner Workflow
CODEBLOCK5
Code Review Workflow
CODEBLOCK6
Weekly Report
CODEBLOCK7
Best Practices
1. Workflow Design
- - Keep steps atomic and focused
- Use clear input/output contracts
- Implement error handling at each step
- Version your workflows
2. Prompt Engineering
- - Use system prompts for context
- Provide examples in few-shot prompts
- Chain prompts for complex tasks
- Validate outputs before next step
3. Resource Management
- - Use URI patterns consistently
- Cache frequently accessed resources
- Clean up temporary resources
- Document resource schemas
4. Cross-Server Coordination
- - Define clear interfaces between servers
- Use standardized message formats
- Implement health checks
- Handle timeouts gracefully
Configuration
Create ~/.openclaw/mcp-workflow.json:
CODEBLOCK8
Integration with OpenClaw
Use in your OpenClaw session:
CODEBLOCK9
References
MCP 工作流技能
快速参考
bash
启动 MCP 服务器
node scripts/mcp-server.js
运行工作流
./scripts/workflow-engine.sh run <工作流名称> [--input
]
列出可用工作流
./scripts/workflow-engine.sh list
从模板创建新工作流
./scripts/workflow-engine.sh create <名称> --from <模板>
验证工作流
./scripts/workflow-engine.sh validate <工作流文件>
概述
本技能使用模型上下文协议(MCP)实现工作流自动化,支持:
- - 提示链:多步骤提示序列
- 动态工作流:上下文感知自适应
- 资源集成:文件/数据嵌入
- 跨服务器协调:多 MCP 编排
工作流模式
1. 提示链模式
计划 → 生成 → 执行 → 验证
2. 动态提示模式
上下文 → 适配 → 生成 → 输出
3. 资源嵌入模式
resource://{类型}/{ID} → 加载 → 嵌入 → 处理
4. 外部触发模式
触发 → 验证 → 调度 → 执行
内置模板
| 模板 | 描述 | 用例 |
|---|
| meal-planner | 每周膳食计划 | 营养、购物清单 |
| code-review |
自动化代码审查 | PR 分析、质量检查 |
| weekly-report | 状态报告生成 | 团队更新、指标 |
| documentation-generator | 文档生成 | API 文档、变更日志 |
MCP 服务器功能
资源
- - file://{路径} - 文件系统访问
- memory://{键} - 内存存储
- config://{部分} - 配置值
工具
- - workflow.run - 执行工作流
- workflow.list - 列出工作流
- workflow.validate - 验证工作流 JSON
- prompt.render - 渲染提示模板
提示
- - chain:plan - 计划提示
- chain:generate - 生成提示
- chain:review - 审查提示
使用示例
膳食计划工作流
bash
./scripts/workflow-engine.sh run meal-planner \
--input {diet:素食,days:7,budget:50}
代码审查工作流
bash
./scripts/workflow-engine.sh run code-review \
--input {repo:myapp,pr:123}
每周报告
bash
./scripts/workflow-engine.sh run weekly-report \
--input {project:dashboard,week:2024-W01}
最佳实践
1. 工作流设计
- - 保持步骤原子化和聚焦
- 使用清晰的输入/输出契约
- 在每个步骤实现错误处理
- 对工作流进行版本控制
2. 提示工程
- - 使用系统提示提供上下文
- 在少样本提示中提供示例
- 为复杂任务链式组合提示
- 在下一步之前验证输出
3. 资源管理
- - 一致使用 URI 模式
- 缓存频繁访问的资源
- 清理临时资源
- 记录资源模式
4. 跨服务器协调
- - 定义服务器间的清晰接口
- 使用标准化消息格式
- 实现健康检查
- 优雅处理超时
配置
创建 ~/.openclaw/mcp-workflow.json:
json
{
servers: [
{
name: local,
command: node scripts/mcp-server.js,
env: {}
}
],
workflowsDir: ./workflows,
templatesDir: ./scripts/templates,
defaultTimeout: 30000
}
与 OpenClaw 集成
在 OpenClaw 会话中使用:
bash
加载技能
openclaw skill load mcp-workflow
运行工作流
openclaw workflow run meal-planner --input {days:5}
参考