AI文档搜索代理

该代理连接云端MCP服务器,利用AI搜索技术帮助开发者从微软官方文档中获取实时准确的答案,适用于Azure、.NET和Microsoft 365等工具的开发者支持。

  • by build-with-shivam
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 Shiazy18/ms-learn-mcp-agent

使用说明

ms学习mcp代理

总结

我们将构建一个连接到云托管MCP服务器的代理。该代理将使用人工智能搜索来帮助开发人员从微软的官方文档中找到准确、实时的答案。这对于构建助手非常有用,这些助手为开发人员提供有关Azure等工具的最新指导。NET和微软365。代理将使用可用的MCP工具查询文档并返回相关结果。


结账

Azure AI代理服务MCP支持 https://github.com/retkowsky/Azure-AIGEN-demos/blob/main/Azure%20Agent%20Service/9%20Azure%20AI%20Agent%20service%20-%20MCP%20support.ipynb

连接到MCP https://learn.microsoft.com/en-us/azure/ai-foundry/agents/how-to/tools/model-context-protocol

先决条件

要在本地运行,请创建.env文件并在其中添加以下值

PROJECT_ENDPOINT="your_project_endpoint"
MODEL_DEPLOYMENT_NAME="your_project_endpoint"

将“your_project_endpoint”占位符替换为项目的终结点(从Azure AI Foundry门户中的项目概述页面复制),并确保MODEL_DEPLOYMENT_NAME变量设置为模型部署名称(应为gpt-4o)。

运行以下命令

python -m venv mcpenv
./mcpenv/bin/activate
pip install -r requirements.txt --pre azure-ai-projects mcp azure-ai-agents

运行

python client.py

出现提示时,输入技术信息请求,例如:

Give me the Azure CLI commands to create an Azure Container App with a managed identity.

等待代理处理您的提示,使用MCP服务器找到合适的工具来检索所请求的信息。您应该看到一些类似于以下内容的输出:

Created agent, ID: <<agent-id>>
MCP Server: mslearn at https://learn.microsoft.com/api/mcp
Created thread, ID: <<thread-id>>
Created message, ID: <<message-id>>
Created run, ID: <<run-id>>
Run completed with status: RunStatus.COMPLETED
Step <<step1-id>> status: completed

Step <<step2-id>> status: completed
MCP Tool calls:
    Tool Call ID: <<tool-call-id>>
    Type: mcp
    Type: microsoft_code_sample_search


Conversation:
--------------------------------------------------
ASSISTANT: You can use Azure CLI to create an Azure Container App with a managed identity (either system-assigned or user-assigned). Below are the relevant commands and workflow:

---

### **1. Create a Resource Group**
'''azurecli
az group create --name myResourceGroup --location eastus
'''


{{continued...}}

By following these steps, you can deploy an Azure Container App with either system-assigned or user-assigned managed identities to integrate seamlessly with other Azure services.
--------------------------------------------------
USER: Give me the Azure CLI commands to create an Azure Container App with a managed identity.
--------------------------------------------------
Deleted agent

请注意,代理能够自动调用MCP工具microsoft_code_sample_search来满足请求。

您可以再次运行该应用程序(使用命令python-client.py)以询问不同的信息。在每种情况下,代理都会尝试使用MCP工具查找技术文档。