Modes Mcp Server

Modes Mcp Server

🚀 模式 MCP 服务器

这是一个用于管理 Roo 的自定义操作模式的 MCP 服务器,可对模式配置和管理进行编程控制,为用户提供便捷的模式管理体验。

🚀 快速开始

本服务器提供了对自定义模式的完整管理功能。你可以通过一系列步骤完成安装、配置,并使用其提供的工具对模式进行操作。

✨ 主要特性

  • 支持对自定义模式进行完整的增删改查操作。
  • 运用 Zod 进行模式验证,确保数据的准确性。
  • 可监控文件系统的变更,及时响应配置文件的修改。
  • 处理标准 MCP 错误码,便于问题排查。
  • 采用原子文件操作,保证数据的一致性。

📦 安装指南

# 克隆仓库
git clone https://github.com/mkc909/modes-mcp-server.git
cd modes-mcp-server

# 安装依赖项
npm install

# 构建项目
npm run build

📚 详细文档

配置步骤

1. 环境变量配置

复制 .env.example.env 并根据需要调整:

cp .env.example .env

可用的环境变量:

  • MODES_CONFIG_PATH:自定义模式配置文件路径(默认:%APPDATA%/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_custom_modes.json

2. 自定义模式配置

创建自定义模式的 JSON 配置文件。参考 examples/modes.example.json 的格式:

{
"customModes": [
{
"slug": "example-mode",
"name": "Example Mode",
"roleDefinition": "Example role definition describing the mode's capabilities and responsibilities.",
"groups": [
"read",
["edit", {
"fileRegex": "\\.md$",
"description": "Can edit markdown files only"
}],
"write"
],
"customInstructions": "These are additional instructions for using this mode."
}
]
}

3. MCP 工具配置

config/mcp-tools.json 中添加以下内容:

{
"modeManager": {
"class": "FileModeManager",
"args": {
"configPath": "%MODES_CONFIG_PATH%",
"schema": {
"type": "object",
"required": ["slug", "name", "roleDefinition"],
"properties": {
"slug": {"type": "string"},
"name": {"type": "string"},
"roleDefinition": {"type": "string"},
"groups": {
"type": "array",
"items": [
{"type": "string"},
{
"type": "array",
"minLength": 2,
"items": [
{"type": "string"},
{
"type": "object",
"required": ["fileRegex", "description"],
"properties": {
"fileRegex": {"type": "string"},
"description": {"type": "string"}
}
}
]
}
]
},
"customInstructions": {"type": "string", "nullable": true}
}
}
}
}
}

操作模式框架

标准模式

  • 默认模式default-mode
    • 显示名称:Default Mode
    • 角色定义:提供通用的文件操作功能,适用于多种任务。
    • 工具组:基本文件操作 (read, edit, write)

自定义模式

开发人员可以创建自定义模式以满足特定需求。例如:

{
"slug": "my-custom-mode",
"name": "My Custom Mode",
"roleDefinition": "A custom mode for specialized tasks.",
"groups": [
["custom-task", {
"fileRegex": "\\.custom$",
"description": "Handles files with .custom extension"
}]
],
"customInstructions": "Use this mode only for specific operations."
}

可用工具

基础用法

以下是一些常用的模式操作命令:

创建模式

POST /modes
Content-Type: application/json

{
"mode": {
"slug": "new-mode",
"name": "New Mode",
"roleDefinition": "Description of new mode.",
"groups": ["read", "write"]
}
}

获取所有模式

GET /modes

更新模式

PUT /modes/
Content-Type: application/json

{
"mode": {
"name": "Updated Mode",
"roleDefinition": "Updated description.",
"groups": ["read", "write"]
}
}

删除模式

DELETE /modes/

开发指南

  1. 修改源代码位于 src/ 目录下。
  2. 构建项目:
npm run build
  1. 启动服务器:
npm start

最佳实践

模式选择

  • 根据任务选择合适的模式。
  • 遵循特定模式的工作流程。
  • 使用指定的工具组。

模式转换

  • 按照自然转换流程操作。
  • 完成当前模式的任务。
  • 在模式之间保留上下文。

配置管理

  • 验证变更后再保存。
  • 保持清晰的角色定义。
  • 文档化模式能力。

错误处理

服务器使用标准 MCP 错误码:

  • InvalidParams:输入参数无效或未找到模式。
  • MethodNotFound:请求的工具未知。
  • InternalError:文件系统错误或其他内部问题。

测试指南

参考 TESTING.md 获取全面的测试用例和验证步骤。

贡献指南

  1. 叉分仓库。
  2. 创建功能分支。
  3. 提交拉取请求。
  4. 遵循编码标准。

📄 许可证

本项目采用 MIT 许可证,详细信息见 LICENSE。

  • 0 关注
  • 0 收藏,9 浏览
  • system 提出于 2025-09-29 16:12

相似服务问题