这是一个用于管理 Roo 的自定义操作模式的 MCP 服务器,可对模式配置和管理进行编程控制,为用户提供便捷的模式管理体验。
本服务器提供了对自定义模式的完整管理功能。你可以通过一系列步骤完成安装、配置,并使用其提供的工具对模式进行操作。
# 克隆仓库
git clone https://github.com/mkc909/modes-mcp-server.git
cd modes-mcp-server
# 安装依赖项
npm install
# 构建项目
npm run build
复制 .env.example
到 .env
并根据需要调整:
cp .env.example .env
可用的环境变量:
MODES_CONFIG_PATH
:自定义模式配置文件路径(默认:%APPDATA%/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_custom_modes.json
)创建自定义模式的 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."
}
]
}
在 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
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/
src/
目录下。npm run build
npm start
服务器使用标准 MCP 错误码:
InvalidParams
:输入参数无效或未找到模式。MethodNotFound
:请求的工具未知。InternalError
:文件系统错误或其他内部问题。参考 TESTING.md 获取全面的测试用例和验证步骤。
本项目采用 MIT 许可证,详细信息见 LICENSE。