使用说明
提示MCP服务器
提示为代码 –像对待代码一样对待提示:结构化、参数化、版本化和可重用。
为什么提示为代码?
作为软件工程师,我们遵循一个简单的原则:
如果重复相同的操作三次,则构建一个模板。
工匠的原则。从临时到系统。从重复到工具。最终:
重复→ 工具→ 质量
这也适用于提示。无论是代码审查、测试生成还是文档清理,我们都会在不同的上下文中重复相同的提示结构。我们可以对它们进行参数化,而不是重新键入或复制粘贴变体。
困境
提示通常是:
- 太简单 –除了基本说明外,几乎没有其他价值
- 太详细了 –需要不断适应每种情况,使其难以重用
解决方案
将您的提示参数化 就像你从代码中提取变量一样:
---
name: code-review
description: Perform a code review with specific focus areas
arguments:
- name: code
description: The code to review
required: true
- name: focus
description: Specific aspects to focus on (e.g., "performance", "security")
required: false
---
Review the following code:
\`\`\`
{{code}}
\`\`\`
{{#if focus}}
Focus specifically on: {{focus}}
{{/if}}
Provide feedback on:
1. Code quality and maintainability
2. Potential bugs or issues
3. Performance considerations
4. Best practices
结构保持稳定。这 可变部件 ({{code}}, {{focus}})参数化。
为什么这很重要
🔄 通过变量实现可重用性
一个提示,多个上下文。对可变部分进行参数化,而不是为每个用例重写。
📦 版本控制
提示存在于您的 Git 仓库,不会丢失在聊天记录中。审查、迭代和回滚——就像任何其他代码一样。
🔧 质量
当提示效果更好时,对其进行优化。当它降级时,回滚。持续改进,就像代码一样。
👥 团队共享
与您的团队分享您最好的提示——不是截图或复制粘贴,而是 结构化、有文件记录的工件.
特性
- 📝 基于Markdown的提示 使用YAML/JSON作为前台
- 🎨 把手模板 用于参数替换和条件
- 🔌 双重运输支持:stdio(本地)和HTTP(远程)
- 🎯 预发货提示 包括
create-prompt帮助您构建新提示 - 🔒 类型安全 完全支持TypeScript
- ⚡ 轻量级 而且很快
- 🔄 热重载 用户提示来自
.prompts-mcp/prompts
快速开始
安装
# Clone the repository
git clone https://github.com/mrsimpson/prompts-mcp.git
cd prompts-mcp/packages/mcp-server
# Install dependencies
npm install
# Build
npm run build
# Run the server (stdio transport for Claude Desktop)
node dist/bin.js
配置Claude桌面
添加到您的Claude配置文件中:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
窗户: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"prompts": {
"command": "node",
"args": ["/absolute/path/to/prompts-mcp/packages/mcp-server/dist/bin.js"],
"env": {
"ENABLE_STDIO": "true",
"LOG_LEVEL": "info"
}
}
}
}
重新启动Claude Desktop,您就可以使用提示了!
创建您的第一个提示
-
创建一个
.prompts-mcp/prompts项目中的目录:mkdir -p .prompts-mcp/prompts -
添加提示文件(例如。,
my-prompt.md):--- name: my-first-prompt description: A simple greeting prompt arguments: - name: name description: The name to greet required: true --- Hello {{name}}! Welcome to prompts-as-code. -
重新启动服务器以加载新提示
运作原理
- 定义提示 作为带有YAML前体的Markdown文件
- 参数化 使用Handlebars语法的可变部分(
{{variable}}) - 店铺提示 在
.prompts-mcp/prompts或使用预装的 - 调用提示 从您的MCP客户端(例如,Claude Desktop)
- 参数被替换 服务器端发送到客户端之前
服务器处理模板渲染、验证和传输——您只需专注于编写出色的提示即可。
用户指南
有关详细文档,请参阅:
📚 完整的用户指南 –完整的文件,包括:
- 详细的配置选项
- 提示文件格式和Handlebars语法
- 使用stdio和HTTP传输运行
- 预发货提示参考
- 发展指南
- 故障排除
🚀 快速入门指南 –几分钟内起床跑步
示例:代码审查提示
下面是一个可重用代码审查提示的实际示例:
---
name: code-review
description: Perform a comprehensive code review
arguments:
- name: code
description: The code to review
required: true
- name: language
description: Programming language (e.g., "TypeScript", "Python")
required: false
- name: focus
description: Specific review focus (e.g., "performance", "security")
required: false
---
Please review the following {{language}} code:
\`\`\`
{{code}}
\`\`\`
{{#if focus}}
Focus specifically on: {{focus}}
{{/if}}
Provide feedback on:
1. Code quality and style
2. Potential bugs or issues
3. Performance optimizations
4. Best practices
用途:
- 调用
code-review随着code参数 - 可选择指定
language和focus - 获得一致、结构化的代码审查
预发货提示
服务器包括 create-prompt –帮助您创建新提示的元提示:
Arguments:
- purpose: What the prompt should accomplish
- target_audience: Who will use this prompt (optional)
- parameters: What parameters the prompt should accept (optional)
使用 create-prompt 学习结构并生成即用型提示文件!
但也有技能!
没错。创建此mcp服务器时,这些都不存在。然而,技能可以在很大程度上取代对这种mcp服务器的需求
- 提示暴露给用户,技能意味着可以被代理发现。Claude Code通过向可能调用它的技能添加元数据,特别模糊了这条线。
- 技能将影响环境
- 技能参数没有适当的规范。Annthropic再次提供了一个专有的解决方案,但它根本没有标准化,而且由于无模式参数,实际上有点错误。
建筑
prompts-mcp/
├── packages/
│ └── mcp-server/
│ ├── src/
│ │ ├── prompts/ # Prompt loading & validation
│ │ ├── server/ # MCP server factory
│ │ ├── transports/ # stdio & HTTP transports
│ │ └── config/ # Configuration management
│ ├── resources/
│ │ └── prompts/ # Pre-shipped prompts
│ └── test/ # Integration & unit tests
└── .prompts-mcp/
└── prompts/ # Your user prompts (auto-loaded)
发展
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Build
npm run build
# Lint
npm run lint
# Type check
npm run typecheck
贡献
欢迎投稿!请随时提交问题和拉取请求。
许可证
MIT许可证——见 许可证 详见
链接
- 📦 GitHub存储库
- 📖 模型上下文协议(MCP)
- 📝 博客文章:提示代码 (德语)
状态
⚠️ 阿尔法 该项目仍处于早期开发阶段。期待突破性的变化和粗糙的边缘。欢迎反馈和贡献!
提前公开发布。 🚀
