接口模块❤️ MCP——为AI代理时代实现API现代化
*“你的API正在成为工具。你的用户正在成为代理。你的平台需要适应。”*
此存储库演示了如何使用 Azure API管理 作为 安全的企业级控制平面 为了 模型上下文协议(MCP) --使AI代理能够发现和调用您的API,而无需重写业务逻辑。
以…的风格建造 Azure示例/AI网关 存储库,以及通过二头肌部署真实Azure基础设施的动手Jupyter笔记本。
🚀 实验室
| 实验室 | 描述 | 状态 |
|---|---|---|
| 将REST API公开为MCP服务器 | 以现有的REST API(产品目录)为例,通过APIM将其公开为MCP服务器,使其可被AI代理发现和调用 | ✅ 准备好了 |
为什么选择MCP+Azure API管理?
这 模型上下文协议 是一个开放标准,它将API转化为 工具 AI代理可以发现、理解和调用。Azure API管理将企业治理引入这一新范式:
- 🔐 安全 -OAuth 2.0、Microsoft Entra ID、API密钥、JWT验证
- 📊 监控 --Azure Monitor、应用程序洞察、实时分析
- 🔍 发现 -将MCP工具发布到Azure API中心以实现组织范围的可见性
- ⚙️ 政策 --MCP流量的速率限制、缓存、转换
- 🌐 统一管理 --管理MCP以及REST、GraphQL和WebSocket API
仓库结构
api-modernization-with-mcp/
+-- labs/
| +-- expose-rest-api-as-mcp/ # Lab notebook, Bicep templates, and README
| +-- expose-rest-api-as-mcp.ipynb
| +-- main.bicep
| +-- README.md
+-- modules/ # Reusable Bicep modules
| +-- apim/
| +-- apim-streamable-mcp/
| +-- cognitive-services/
+-- shared/ # Shared code (MCP servers, utilities)
| +-- mcp-servers/
| | +-- product-catalog/
| +-- utils.py
+-- requirements.txt先决条件
- Python 3.12+
- VS Code 随着 Jupyter扩展
- Azure订阅 具有参与者+RBAC管理员角色
- Azure命令行界面 已安装并登录
入门指南
# Clone the repository
git clone https://github.com/odaibert/api-modernization-with-mcp.git
cd api-modernization-with-mcp
# Open in VS Code
code .
# Navigate to a lab and open the notebook
# labs/expose-rest-api-as-mcp/expose-rest-api-as-mcp.ipynb每个实验笔记本都是独立的——点击 全部运行 提供基础设施、部署服务和端到端测试。
参考文献
- 📝 博客:Azure API管理现在支持MCP
- 📖 将API作为MCP服务器公开
- 📖 连接到符合MCP标准的外部服务器
- 🔐 安全访问MCP服务器
- 🔍 了解API中心的MCP工具
- 🤖 Microsoft代理框架
- 🌐 模型上下文协议
贡献
该项目欢迎各方提供意见和建议。
许可证
该项目根据MIT许可证获得许可。
