基于Azure AI Foundry的多代理MCP架构
此存储库展示了如何 Azure AI Foundry代理服务 可以同时利用两者 内部(自托管) 和 外部的 模型上下文协议(MCP)服务器,用于创建强大的专用AI代理。
🎯 这表明了什么
两种MCP集成模式
- 🐙 外部MCP -连接到第三方MCP服务(GitHub、API等)
- 🗄️ 内部MCP -使用自定义工具部署自己的MCP服务器
真实世界示例:多代理SQL+GitHub助手
- GitHub代理 → 外部MCP→ Azure REST API规范存储库
- SQL代理 → 内部MCP→ 您的Azure SQL数据库
这两个代理共存于同一个Azure AI Foundry项目中,使用户可以访问代码搜索和数据库查询功能。
🚀 架构概述
graph TB
subgraph "Azure AI Foundry Project"
GA[GitHub Agent]
SA[SQL Agent]
end
subgraph "External MCP"
EXT[gitmcp.io/Azure/azure-rest-api-specs]
end
subgraph "Your Infrastructure"
MCPS[MCP Server
Container App]
SQL[(Azure SQL Database)]
end
GA -->|search_azure_rest_api_code| EXT
SA -->|list_table, describe_table, read_data| MCPS
MCPS -->|Azure AD Auth| SQL🚀 入门指南
根据您的需求选择实施路径:
🟢 外部MCP -快速简单(\<15分钟)
非常适合开始使用或与现有服务集成。
- 指南: 外部MCP设置
- 基础设施: 仅限Azure AI Foundry+模型部署
- 优点: 连接到GitHub API、web服务,无需部署服务器
- 限制: 仅限于可用的外部服务
🔵 自托管MCP -完全控制(15-30分钟)
构建可完全控制功能和数据的自定义工具。
- 指南: 自托管MCP设置
- 基础设施: Azure AI Foundry+模型+SQL Server+容器应用程序+密钥库
- 优点: 自定义业务逻辑、企业安全、无限功能
- 权衡: 需要基础设施部署和维护
🎬 测试您的代理
🤖 互动聊天游乐场
Azure AI Foundry UI在启用MCP的代理的游乐场体验方面仍然存在局限性。因此,此存储库包含交互式聊天会话:
cd test
# Chat with GitHub Agent (External MCP)
python chat-with-github-agent.py
# 🗨️ Interactive conversation with GitHub repository search
# 💬 Type your questions and get real-time responses
# 🔧 Automatic tool usage detection and approval
# Chat with SQL Agent (Self-Hosted MCP)
python chat-with-sql-agent.py
# 🗨️ Interactive database queries and exploration
# 💾 Real-time SQL operations with formatted results
# 🔧 Automatic tool approval for seamless experience聊天命令:
quit/exit/bye-结束聊天会话help-显示每个代理的示例查询clear-启动一个新的对话线程
📋 自动测试脚本
使用预定义的验证场景运行非交互式测试脚本:
cd test
# Test GitHub Agent (External MCP)
python test-github-agent.py
# ✅ 4 automated scenarios testing repository search capabilities
# ✅ Tool call detection with response content analysis
# ✅ No MCP server infrastructure required
# Test SQL Agent (Self-Hosted MCP)
python test-sql-agent.py
# ✅ 4 automated scenarios testing database operations
# ✅ Table listing, schema inspection, and data querying
# ✅ Full control over tools and security测试脚本功能:
- 非交互式 -自动运行预定义的测试场景
- 全面覆盖 -测试基本功能、工具使用和特定查询
- 详细报告 -显示成功/失败状态和工具调用证据
- CI/CD友好 -非常适合自动化验证流程
✅ 成功指标
GitHub代理正常工作: 正确配置GitHub MCP代理后,您将看到:
mcp_github: Allows searching for code and files within the GitHub repository
for Azure REST API specifications (Azure/azure-rest-api-specs).要尝试的示例查询:
- “在Azure REST API中搜索身份验证示例”
- “查找存储帐户REST API架构”
- “显示Azure资源管理器模板的示例”
- “查找密钥保管库API规范”
🔧 故障排除
您的MCP代理有问题吗?查看我们的全面故障排除指南:
📋 故障排除指南
涉及的常见问题:
- ❌ “RequiresAction”UI限制和解决方法
- 🔧 工具调用超时和连接问题
- 🗄️ SQL代理连接问题
- 🔐 身份验证和密钥库访问问题
- ⚙️ 配置文件问题
快速解决方案:
- 使用交互式聊天脚本 (
chat-with-*-agent.py)-它们绕过了大多数UI限制 - 运行测试脚本 (
test-*-agent.py)-非常适合验证 - 检查网络连接 -特别是对于SQL代理(IP限制)
🔗 其他资源
- 故障排除指南 -常见问题和解决方案
- MCP服务器指南 -TypeScript MCP服务器实现细节
- 配置指南 -环境变量和配置文件
- 地方发展 -基于Docker的本地测试
- **** -VS代码MCP集成(stdio)
______________________________________________________________________
*内置❤️ Azure AI社区*
