将MCP工具与AI Foundry代理一起使用
此存储库是为Contoso Bike Store构建的AI助手解决方案,演示了MCP(模型上下文协议)工具与Azure AI Foundry代理的使用。
该应用程序提供了一个聊天界面,客户可以在其中与Contoso Bike Store AI代理进行交互:
Chat Interface - Product Inquiry
架构概述
- 前端:托管在Azure App Service上的React应用程序,提供聊天界面
- 后端:ASP。NET核心Web API(Chat Orchestrator API)托管在Azure应用程序服务上,用于处理用户提示
- Azure AI Foundry:承载可访问MCP工具和模型的Contoso代理(GPT-4.1)
- MCP服务器:使用特定于域的工具扩展代理功能的自定义MCP服务器
- 产品微服务:REST API提供产品库存和订单管理数据
MCP工具类别
- 产品库存工具:
- 获取自行车型号和规格 - 检查配件可用性 - 查询库存水平
- 订单管理工具:
- 创建新订单 - 检查订单状态 - 跟踪订单历史
先决条件
- Azure订阅:注册一个 免费Azure帐户 如果你没有
- GitHub账号:存储库访问和身份验证所需
- 开发环境:
- 支持开发容器的Visual Studio代码,或 - GitHub代码空间(推荐)
入门指南
1.克隆存储库
git clone https://github.com/rakeshl4/aifoundryagent_mcp_tools.git
cd aifoundryagent_mcp_tools2.设置开发环境
选项A:GitHub代码空间(推荐)
单击下面的按钮在GitHub Codespace中启动项目:
](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=YOUR_REPO_ID&skip_quickstart=true)
选项B:使用VS代码开发容器进行本地开发
- 在Visual Studio代码中打开项目
- 安装开发容器扩展
- 按
Ctrl+Shift+P然后选择“开发容器:在容器中重新打开”
3.部署Azure资源
- 使用Azure进行身份验证:
azd auth login --use-device-code- 创建和配置环境:
azd env new dev
azd env select dev
azd env set AZURE_LOCATION australiaeast- 部署基础设施:
azd up- 复制环境变量:
cp .azure/dev/.env .env项目结构
├── infra/ # Infrastructure as Code (Bicep files)
├── resources/ # API specifications and sample data
├── scripts/ # Utility scripts
├── src/
│ ├── backend/ # AI Agent API (.NET)
│ └── frontend/ # Web application
└── azure.yaml # Azure Developer CLI configuration