调试mcp提示
⚠️ 原型-仅用于测试和讨论目的
______________________________________________________________________
Symfony开发的代码生成提示,为创建控制台命令和其他组件提供结构化模板。
目的
提供MCP提示,指导LLM生成高质量的Symfony代码:
- Symfony命令提示:使用最佳实践创建控制台命令的模板
- 结构化生成:遵循Symfony约定的一致代码结构
特性
- 基于模板的提示生成
- 自定义参数替换
- 提示中嵌入了最佳实践指南
- 通过调试mcp服务器自动发现
安装
composer require wachterjohannes/debug-mcp-prompts调试mcp服务器启动时,将自动发现提示。
可用提示
symfony命令
生成具有适当结构和最佳实践的Symfony控制台命令。
名字: symfony_command
参数:
command_name(必填):命令名称(例如,“app:process-data”)description(必填):命令的作用是什么interactive(可选,默认:false):命令是否需要用户交互
示例用法:
通过MCP协议:
{
"jsonrpc": "2.0",
"method": "prompts/get",
"params": {
"name": "symfony_command",
"arguments": {
"command_name": "app:import-users",
"description": "Import users from CSV file",
"interactive": true
}
},
"id": 1
}生成提示:
提示将引导LLM按照以下结构创建命令:
- 用途
#[AsCommand]属性 - 扩展
Command类 - 包含参数/选项的configure()方法
- 使用SymfonyStyle实现execute()方法
- 通过构造函数添加依赖注入
- 包括错误处理
- 交互式输入处理(如果需要)
模板结构
提示在中使用模板文件 templates/:
templates/
├── command-basic.txt # Non-interactive command template
└── command-interactive.txt # Interactive command template模板包含:
- 角色标记(用户/助理)
- 参数占位符({command_name}、{description})
- 逐步生成说明
- 代码结构指导
- 最佳做法提醒
Claude中的用法
当与配置了debug mcp的Claude Desktop一起使用时:
- 列出可用提示:
问克劳德:“有什么提示?”
- 使用提示:
“使用symfony_command提示符创建一个名为app:export orders的命令,将订单导出为CSV”
- 自定义参数:
Claude将使用提示模板和您提供的参数来生成代码。
注册
提示通过composer.json额外配置注册:
{
"extra": {
"wachterjohannes/debug-mcp": {
"classes": [
"Wachterjohannes\\DebugMcp\\Prompts\\SymfonyCommandPrompt"
]
}
}
}添加新提示
要添加新提示,请执行以下操作:
- 创建模板文件 在
templates/:
templates/entity-crud.txt- 创建提示类:
'user', 'content' => $content]
];
}
}- 在composer.json中注册:
{
"extra": {
"wachterjohannes/debug-mcp": {
"classes": [
"Wachterjohannes\\DebugMcp\\Prompts\\EntityCrudPrompt"
]
}
}
}- README中的文档
模板指南
创建提示模板时:
- 清除指令:提供分步指导
- 参数占位符:使用{param_name}进行替换
- 最佳实践:在说明中嵌入Symfony最佳实践
- 代码示例:显示预期的输出结构
- 错误处理:包括错误处理指南
- 测试提示:提及如何测试生成的代码
模板结构示例:
Create a Symfony Console Command with the following specifications:
Command Name: {command_name}
Description: {description}
Requirements:
1. Use #[AsCommand] attribute
2. Extend Symfony\Component\Console\Command\Command
3. Use SymfonyStyle for output
4. Include proper error handling
5. Return appropriate exit codes (SUCCESS/FAILURE)
Generate the complete command class with:
- Namespace: App\Command
- Class name: Derived from command name (PascalCase + "Command" suffix)
- Constructor with dependency injection
- configure() method if arguments/options needed
- execute() method with full implementation发展
代码质量
提交前格式化代码:
composer cs-fix测试提示
测试提示:
- 在调试mcp实例中安装软件包
- 配置Claude桌面
- 通过自然语言使用提示
- 验证生成的代码质量
需求
- PHP 8.1或更高版本
- modelcontextprotocol/php-sdk
- wachterjohannes/debug mcp(用于测试)
仓库
github:https://github.com/wachterjohannes/debug-mcp-prompts
许可证
麻省理工学院
