CRM副驾驶MCP
 
📋 概述
CRM Copilot MCP是一个。基于 NET 9 的 MCP 服务器(模型上下文协议)。该仓库包含服务器部署和 Azure Bicep 模板,用于完整的云基础设施。
✨ 特性
- 🔧 MCP服务器模型上下文协议(Model Context Protocol)
- ☁️ Azure就绪用于云部署的预配置 Bicep 模板
- 🚀 热重新加载: 易于开发,自动重新加载
🛠️ 条件
地方发展
- .NET SDK 9.0 或更新
- IDE(其中之一):
- Visual Studio 2022 或 - VS代码 麻省理工学院 C#开发工具包
Azure云部署
- 需要 :
- Azure命令行界面 (最新版本) - Azure开发者命令行界面(azd) - PowerShell 7+ - 具有贡献者权限的活动 Azure 订阅
Azure AD 应用注册(用于身份验证)
- 创建应用注册的 Azure AD 权限
🚀 快速启动
本地启动
# Repository klonen
git clone https://github.com/IHR_USERNAME/CRMCopilotMCP.git
cd CRMCopilotMCP
# Abhängigkeiten wiederherstellen (für alle Projekte)
dotnet restore src/mcp-csharp-sdk.sln
# Entwicklungsserver starten (z.B. Lead-Server)
dotnet run --project src/McpServer.Lead/McpServer.Lead.csproj
# Oder Opportunity-Server:
# dotnet run --project src/McpServer.Opportunity/McpServer.Opportunity.csproj
# Oder Quote-Server:
# dotnet run --project src/McpServer.Quote/McpServer.Quote.csproj
# (Optional) HTTP-Endpunkte testen
dotnet tool install --global Microsoft.dotnet-httprepl
httprepl http://localhost:5000⚙️ 配置
地方发展
应用程序设置位于各自的项目目录中:
src/McpServer.Lead/appsettings.jsonsrc/McpServer.Opportunity/appsettings.jsonsrc/McpServer.Quote/appsettings.json
将开发特定值覆盖到相应的 appsettings.Development.json 文件
Azure Key Vault(生产版)
在生产环境中,所有秘密都会自动存储在 Azure Key Vault 中,并通过 Managed Identity 进行检索。基础设施由Bicep模块组成。 infra/ 提供的目录 :
- Client Secret 存储在 Key Vault Secret 中
- 应用服务verwendet系统分配的托管身份
- 自动 RBAC 角色分配:“Key Vault Secrets User”
项目结构
src/MCP服务器实现(C#)
- mcp-csharp-sdk.sln 适用于所有服务器的 Visual Studio 解决方案 - McpServer.http – 所有端点的 HTTP 测试文件 - McpServer.Lead/ –Lead管理服务器mit LeadTools - McpServer.Opportunity/ 带有 OpportunityTools 和 DataverseService 的机会管理服务器(包括 Azure AD 身份验证) - McpServer.Quote/ –报价管理服务器mit QuoteTools
infra/Azure基础设施(Bicep模块)
- 01-resource-group.bicep –资源组定义 - 02-logging-monitoring.bicep – 记录和监控 - 03-vnet.bicep –虚拟网络 - 04-keyvault.bicep –密钥库 - 05-appservice-mcp.bicep –应用服务 - 06-apim-internal.bicep –API管理 - 07-appservice-pe.bicep –私有端点 - main.bicep –Haupt部署模板 - main.parameters.json – 部署参数文件
helper/– 帮助文件和示例azure.yamlAzure Developer CLI 的部署配置
发展
- Linting/Formatting 通过
dotnet format - 测试(如有)通过
dotnet test - 调试:
dotnet watch run支持 Hot Reload
🚀 部署
部署的要求
- Azure CLI 认证:
az login
azd auth login- 已配置参数 在
infra/main.parameters.json
Azure开发人员命令行界面(Empfohlen)
# Initialisierung
azd init
# Deployment
azd up手动 Bicep 部署
使用 infra/main.bicep 对于手动配置:
az deployment sub create `
--name crmcopilot-$(Get-Date -Format yyyyMMddHHmm) `
--location "West Europe" `
--template-file infra/main.bicep `
--parameters @infra/main.parameters.json更多信息
- 部署详细信息: 查看 部署.md
🐛 故障排除
构建错误
# Cache löschen und neu bauen
dotnet clean
dotnet restore
dotnet build端口已在使用中
# Anderen Port verwenden
dotnet run --project src/McpServer.Lead/McpServer.Lead.csproj --urls "http://localhost:5001"
# oder für einen anderen Server entsprechend anpassenAzure部署问题
# Deployment-Logs anzeigen
azd deploy --debug
# App Service Logs streamen
az webapp log tail --name app- --resource-group -rg🔒 安全与最佳实践
发展
- ✅ 使用
appsettings.Development.json用于本地设置 - ✅ 利用它。本地开发的 NET 用户秘密:
dotnet user-secrets set "Key" "Value" - ✅ 启用 GitHub 秘密扫描
- ❌ 永远不要在 Git 中提交秘密
生产
- ✅ 将所有秘密存储在 Azure Key Vault 中
- ✅ 用于服务对服务身份验证的托管身份
- ✅ 强制使用 TLS 1.2+(已在 Bicep 中配置)
- ✅ 启用 Application Insights 进行监控
- ✅ 定期进行安全审计
合规
- GDPR:确保按照 GDPR 处理个人数据
- 记录:不记录敏感数据(秘密,PII)
- 审核:启用 Azure AD 审核日志以获取合规性证据
📚 进一步的文档
- 部署指导 详细的部署指南
- 模型上下文协议规范 -MCP标准
- Azure应用服务安全 -Azure最佳实践
📄 许可证
这个项目是根据麻省理工学院许可证授权的 - 参见 许可证 为了细节。
🤝 贡献
欢迎贡献!请注意:
- Fork des Repositories erstellen
- 创建 Feature Branch (
git checkout -b feature/AmazingFeature) - 提交更改(
git commit -m 'Add some AmazingFeature') - 蒲森分店(
git push origin feature/AmazingFeature) - 打开 Pull Request
📧 支持
如有任何问题或疑问,请创建 问题 im存储库。
