使用说明
MCP提示经纪人
基于模型上下文协议的人工智能代理智能指令路由
执行摘要
MCP提示经纪人 是一个基于Python的模型上下文协议(MCP)服务器,它为用户提示动态选择最佳指令配置文件。它使GitHub Copilot等人工智能助手能够自动应用特定于上下文的指导,提高不同领域的响应质量,包括创造性思维、技术故障排除、隐私敏感操作和通用交互。
关键价值主张
| 挑战 | 解决方案 |
|---|---|
| 一刀切的AI指令 | 上下文感知配置文件路由 |
| 静态AI行为 | 热可重新加载的markdown配置文件 |
| 有限的领域专业知识 | 创意、技术、隐私和一般任务的专业配置文件 |
| 不透明的路由决策 | 透明的评分和置信度指标 |
核心能力
mindmap
root((MCP Prompt Broker))
Intelligent Routing
Metadata extraction
Rule-based scoring
Confidence metrics
Profile Management
Markdown-based profiles
Hot reload support
Central metadata registry
MCP Integration
Standard MCP tools
VS Code Copilot Chat
Extensible architecture
Quality Assurance
Checklists per profile
Capability inference
Domain detection
快速开始
先决条件
- Python 3.10或更高版本
- 带有GitHub Copilot聊天扩展的VS代码(可选)
安装
选项1:自动安装(Windows)
git clone https://github.com/michaelprinc/MCP_prompt_broker.git
cd MCP_prompt_broker
./install.ps1
这将安装:
- ✅ MCP提示代理服务器
- ✅ MCP服务器配置(全局+工作区)
- ✅ 配套报关员 GitHub Copilot聊天
选项2:手动安装
git clone https://github.com/michaelprinc/MCP_prompt_broker.git
cd MCP_prompt_broker
python -m pip install .
运行服务器
python -m mcp_prompt_broker
或者使用自定义配置文件目录:
python -m mcp_prompt_broker --profiles-dir /path/to/profiles
运作原理
sequenceDiagram
participant User
participant Copilot as GitHub Copilot
participant MCP as MCP Prompt Broker
participant Router as Profile Router
participant Profiles as Profile Store
User->>Copilot: Send prompt
Copilot->>MCP: get_profile(prompt)
MCP->>MCP: Analyze prompt metadata
MCP->>Router: Route with metadata
Router->>Profiles: Score all profiles
Profiles-->>Router: Scored matches
Router-->>MCP: Best profile + score
MCP-->>Copilot: Profile + instructions
Copilot->>User: Enhanced response
配置文件路由过程
- 即时分析:提取元数据(意图、领域、敏感性、主题)
- 配置文件匹配:评估每个配置文件的所需条件
- 加权评分:应用特定领域的权重来计算分数
- 置信度计算:使用softmax样式规范化一致性度量
- 响应:返回带有说明和检查表的最佳匹配配置文件
可用配置文件
| 简介 | 用例 | 复杂性 |
|---|---|---|
general_default |
通用回退 | 标准 |
creative_brainstorm |
构思和创造性思维 | 标准 |
technical_support |
故障排除和调试 | 标准 |
privacy_sensitive |
GDPR/HIPAA合规运营 | 标准 |
*_complex |
具有元认知功能的增强版本 | 复杂 |
配套定制代理
同伴 是一个智能AI助手,它使用MCP Prompt Broker自动将您的请求路由到最佳指令配置文件。
在GitHub Copilot聊天中使用Companion
安装后,将Companion代理与 @companion 提及:
@companion Generate creative names for a fitness tracking app
@companion Debug this Python KeyError on line 42
@companion Analyze this medical data with privacy compliance
伴侣是如何工作的
- 自动配置文件选择:每个请求都通过以下方式进行分析
get_profile工具 - 上下文感知指令:自动应用特定领域的指导
- 最佳响应质量:利用专业配置文件(创意、技术、隐私、一般)
- 透明路由:显示选择了哪个配置文件以及原因
同伴福利
| 没有伴侣 | 有伴侣 |
|---|---|
| 通用AI响应 | 领域优化响应 |
| 手动指令编写 | 自动指令路由 |
| 质量不一致 | 基于配置文件的一致性 |
| 一刀切 | 情境感知适应 |
看 用户指南 了解详细的Companion使用说明。
MCP工具参考
| 工具 | 说明 |
|---|---|
list_profiles |
列出所有可用的指令配置文件 |
get_profile |
分析提示并返回最佳匹配配置文件 |
reload_profiles |
从markdown文件热重新加载配置文件 |
get_checklist |
获取特定配置文件的质量检查表 |
get_registry_summary |
获取元数据注册表统计信息 |
find_profiles_by_capability |
按能力查找配置文件(例如,“构思”) |
find_profiles_by_domain |
按域查找个人资料(例如,“医疗保健”) |
文档结构
该项目遵循 Diátaxi文件框架,提供四种不同类型的文档:
graph TB
subgraph "Learning-Oriented"
A[README.md<br/>Executive Summary]
end
subgraph "Goal-Oriented"
B[docs/USER_GUIDE.md<br/>User Guide]
end
subgraph "Understanding-Oriented"
C[docs/DEVELOPER_GUIDE.md<br/>Developer Guide]
end
subgraph "Information-Oriented"
D[docs/REPORTS_INDEX.md<br/>Ad-hoc Reports]
end
A --> B
A --> C
A --> D
B --> C
C --> D
| 级别 | 文档 | 目的 | 受众 |
|---|---|---|---|
| 1 | README.md | 执行摘要,快速入门 | 每个人 |
| 2 | 用户指南 | 安装、配置、使用 | 最终用户 |
| 3 | 开发者指南 | 架构,API,贡献 | 开发人员 |
| 4 | 报告索引 | 开发历史、决策 | 维护人员 |
文件编制方法
本文档是按照以下原则创建的:
- 迪亚斯出租车框架:将教程、操作指南、解释和参考分开
- 渐进式披露:信息复杂性随着文档深度的增加而增加
- 加注使相互参照:所有文档都相互连接,便于导航
- 可视化文档:流程和架构的美人鱼图
- 生活文档:报告跟踪发展历史和决策
项目结构
MCP_Prompt_Broker/
├── .github/
│ └── agents/
│ ├── companion-instructions.md # Companion agent instructions
│ ├── companion-agent.json # Agent definition (reference)
│ └── README.md # Agent directory documentation
├── src/
│ └── mcp_prompt_broker/
│ ├── server.py # MCP server entry point
│ ├── profile_parser.py # Markdown profile parser
│ ├── metadata_registry.py # Central metadata management
│ ├── config/
│ │ └── profiles.py # InstructionProfile class
│ ├── metadata/
│ │ └── parser.py # Prompt metadata extraction
│ ├── router/
│ │ └── profile_router.py # Profile routing logic
│ └── copilot-profiles/ # Markdown profile files
├── tests/ # Unit tests
├── docs/ # Documentation
├── reports/ # Ad-hoc development reports
├── companion-agent.json # Source agent definition
├── companion-instructions.md # Source agent instructions
├── pyproject.toml # Package configuration
└── install.ps1 # Windows installation script
贡献
我们欢迎捐款!请查看 开发者指南 用于:
- 架构概述
- 建立开发环境
- 创建新配置文件
- 代码风格指南
- 测试要求
许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
致谢
- 模型上下文协议 规格
- GitHub Copilot 用于MCP集成
- 迪亚斯出租车框架 文件编制方法
