把 Foundry IQ 知识库接到 Foundry 智能体服务
按步骤把 Foundry IQ 知识库以 MCP 工具接到 Foundry 智能体:创建托管标识连接、限定 knowledge_base_retrieve,并用逐请求头做权限过滤。

目录
#把 Foundry IQ 知识库接到 Foundry 智能体服务
重要
标记为(预览)的功能、能力或属性不在服务级别协议(service level agreement,SLA)覆盖范围内,不建议用于生产工作负载,并且在正式发布之前可能变更或受到限制。Azure AI 搜索预览条款适用于全部预览功能,无论它是独立功能,还是正式发布功能的一部分。
本文说明如何把 Foundry IQ 中的知识库连接到 Foundry 智能体服务(Foundry Agent Service)中的智能体。该连接使用模型上下文协议(Model Context Protocol,MCP)来促成工具调用。当智能体调用时,知识库会在其已配置的知识源之间编排检索。根据其配置,知识库可以:
- 使用基于大语言模型(large language model,LLM)的查询规划(预览),把用户查询分解为子查询。
- 通过关键字、向量或混合搜索同时处理这些子查询。
- 应用语义重排序,以识别最相关的结果。
- 使用答案合成(预览),把结果合并成带有来源引用的自然语言响应。
智能体使用检索到的或合成的响应,把答案扎根于企业数据或 Web 来源。来源引用帮助用户核验信息,并追溯到原始内容。
关于把 Azure AI 搜索与 Foundry 智能体服务集成为知识检索的端到端示例,请参见 GitHub 上的 Python 示例 agentic-retrieval-pipeline-example:https://github.com/Azure-Samples/azure-search-python-samples/tree/main/agentic-retrieval-pipeline-example
使用支持
| Microsoft Foundry 支持 | Python SDK | C# SDK | JavaScript SDK | Java SDK | REST API | 基本智能体设置 | 标准智能体设置 |
|---|---|---|---|---|---|---|---|
| ✔️ | ✔️ | - | - | - | ✔️ | ✔️ | ✔️ |
前提条件
- 一个 Azure AI 搜索服务,其中有一个知识库,知识库包含一个或多个知识源。
- 一个带有 LLM 部署的 Microsoft Foundry 项目,例如
gpt-4.1-mini。不支持基于中心(hub)的项目。 - 你的搜索服务和项目上的认证与权限。
- 最新预览版 Python SDK(2.0.0 或更高版本),或 2026-08-01-preview REST API 版本。
pip install "azure-ai-projects>=2.0.0" requests认证与权限
我们建议生产部署使用基于角色的访问控制(role-based access control,RBAC)。要分配本节中的角色,你需要在两个资源上都拥有 所有者(Owner) 或 用户访问管理员(User Access Administrator) 角色,或另一个授予 Microsoft.Authorization/roleAssignments/write 的角色。如果角色不可行,跳过本节,改用基于密钥的认证。
- 在项目的父资源上,你需要 Foundry 用户(Foundry User) 角色才能访问模型部署并创建智能体。所有者 在创建该资源时会自动获得此角色。其他用户需要一次明确的角色分配。
- 重要:Foundry 的 RBAC 角色最近已重命名。Foundry User、Foundry Owner、Foundry Account Owner 和 Foundry Project Manager 以前分别名为 Azure AI User、Azure AI Owner、Azure AI Account Owner 和 Azure AI Project Manager。在重命名推出期间,你仍可能在某些地方看到旧名称。角色 ID 和核心权限不因重命名而改变。
- 在项目的父资源上,你需要 Foundry 项目经理(Foundry Project Manager) 角色才能为 MCP 认证创建项目连接;要在智能体中使用 MCP 工具,则需要 Foundry User 或 Foundry Project Manager。
- (有条件)在项目的父资源上,把 认知服务用户(Cognitive Services User) 角色分配给你的搜索服务的系统分配托管标识。仅当你的知识库指定了 LLM 时才需要这一步。根据其配置,知识库使用该标识调用 LLM 做查询规划、答案合成,或两者都做。
- 在你的项目上,为与 Azure AI 搜索的交互创建一个系统分配的托管标识。
- 在你的搜索服务上,把 搜索索引数据读取者(Search Index Data Reader) 角色分配给你的项目的托管标识,以便对搜索索引进行只读访问。如果智能体需要向搜索索引写入文档,还要分配 搜索索引数据参与者(Search Index Data Contributor) 角色。
- 对于带有访问控制列表(access control list,ACL)的已索引内容,在搜索索引中包含权限元数据字段,并在查询时通过
x-ms-query-source-authorization头传递用户令牌,以根据用户身份筛选结果。 - 对于远程 SharePoint 知识源,
x-ms-query-source-authorization头传递用户身份,使 SharePoint 能在查询时强制执行文档权限。内容不会被索引。相反,SharePoint 通过 Copilot Retrieval API 直接应用权限。
所需的值
在代码示例中使用下列值。
| 值 | 从哪里取得 | 示例 |
|---|---|---|
项目终结点(project_endpoint) | 在 Microsoft Foundry 门户的项目详细信息中找到它。 | https://your-resource.services.ai.azure.com/api/projects/your-project |
项目资源 ID(project_resource_id) | 从 Azure 门户复制项目的 ARM 资源 ID,或使用 Azure CLI 查询资源 ID。你的 Microsoft Foundry 项目必须具有 Microsoft.CognitiveServices/accounts 命名空间。 | /subscriptions/.../resourceGroups/.../providers/Microsoft.CognitiveServices/accounts/.../projects/... |
Azure AI 搜索终结点(search_service_endpoint) | 在 Azure 门户中你的 Azure AI 搜索服务的 概述(Overview) 页上找到它(服务 URL)。 | https://your-search-service.search.windows.net |
知识库名称(knowledge_base_name) | 使用你在 Azure AI 搜索中创建的知识库名称。 | hr-policy-kb |
项目连接名称(project_connection_name) | 为你创建的项目连接选择一个名称。 | my-kb-mcp-connection |
智能体名称(agent_name) | 为你创建的智能体版本选择一个名称。 | hr-assistant |
模型部署名称(deployed_LLM) | 在 Microsoft Foundry 项目的模型部署中找到它。 | gpt-4.1-mini |
提示
我们建议你把项目终结点、搜索终结点和知识库名称存放在本地开发用的 .env 文件中。
创建项目连接
在你的 Microsoft Foundry 项目上创建一个 RemoteTool 连接(预览)。该连接使用项目的托管标识指向知识库的 MCP 终结点,使智能体能够安全地与 Azure AI 搜索通信以执行检索操作。
注意
RemoteTool 类别和 ProjectManagedIdentity 认证类型是 Microsoft Foundry 项目连接所特有的。
Python
import requests
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
# Provide connection details
credential = DefaultAzureCredential()
project_resource_id = "{project_resource_id}" # e.g. /subscriptions/{subscription}/resourceGroups/{resource_group}/providers/Microsoft.CognitiveServices/accounts/{account_name}/projects/{project_name}
project_connection_name = "{project_connection_name}"
mcp_endpoint = "{search_service_endpoint}/knowledgebases/{knowledge_base_name}/mcp?api-version=2026-08-01-preview" # This endpoint enables the MCP connection between the agent and knowledge base
# Get bearer token for authentication
bearer_token_provider = get_bearer_token_provider(credential, "https://management.azure.com/.default")
headers = {
"Authorization": f"Bearer {bearer_token_provider()}",
}
# Create project connection
response = requests.put(
f"https://management.azure.com{project_resource_id}/connections/{project_connection_name}?api-version=2025-10-01-preview",
headers = headers,
json = {
"name": project_connection_name,
"type": "Microsoft.MachineLearningServices/workspaces/connections",
"properties": {
"authType": "ProjectManagedIdentity",
"category": "RemoteTool",
"target": mcp_endpoint,
"isSharedToAll": True,
"audience": "https://search.azure.com/",
"metadata": { "ApiType": "Azure" }
}
}
)
response.raise_for_status()
print(f"Connection '{project_connection_name}' created or updated successfully.")REST
使用 Azure CLI 取得用于 Azure 资源管理器(Azure Resource Manager)的访问令牌:
az account get-access-token --scope https://management.azure.com/.default --query accessToken -o tsv通过向 Azure 资源管理器发出 PUT 请求来创建项目连接:
PUT https://management.azure.com/{project_resource_id}/connections/{project_connection_name}?api-version=2025-10-01-preview
Authorization: Bearer {management_access_token}
Content-Type: application/json
{
"name": "{project_connection_name}",
"type": "Microsoft.MachineLearningServices/workspaces/connections",
"properties": {
"authType": "ProjectManagedIdentity",
"category": "RemoteTool",
"target": "{search_service_endpoint}/knowledgebases/{knowledge_base_name}/mcp?api-version=2026-08-01-preview", // This endpoint enables the MCP connection between the agent and knowledge base
"isSharedToAll": true,
"audience": "https://search.azure.com/",
"metadata": {
"ApiType": "Azure"
}
}
}为知识检索优化智能体指令
为了提高知识库调用率并产生带引用的答案,从类似下面的指令开始:
You are a helpful assistant.
Use the knowledge base tool to answer user questions.
If the knowledge base doesn't contain the answer, respond with "I don't know".
When you use information from the knowledge base, include citations to the retrieved sources.该指令模板针对下列方面做了优化:
- 更高的 MCP 工具调用率:明确指令确保智能体一致地调用知识库工具,而不是依赖其训练数据。
- 清晰的来源归属:引用使验证信息来自何处变得更容易。
提示
虽然该模板提供了扎实的基础,仍应根据你的具体用例和目标评估并迭代这些指令。测试不同变体,以找到最适合你场景的写法。
创建带有 MCP 工具的智能体
警告
MCP 实现容易受到攻击、级联失败和失去人工监督等风险的影响。你可以通过审查 MCP 服务器的安全性和可靠性、遵循 Microsoft 推荐做法和行业最佳实践,并实施审批机制和监控级联行为,来缓解这些风险。
创建一个把知识库集成为 MCP 工具的智能体。智能体使用系统提示来指示何时以及如何调用知识库。它遵循关于如何回答问题的指令,并在对话会话之间自动维持其工具配置和设置。
用你先前创建的项目连接添加知识库 MCP 工具。该工具在已配置的知识源之间编排查询规划、分解和检索。智能体使用该工具回答查询。
注意
Azure AI 搜索知识库暴露 knowledge_base_retrieve 这一 MCP 工具供智能体集成。这是目前唯一支持与 Foundry 智能体服务一起使用的工具。
Python
from azure.ai.projects import AIProjectClient
from azure.ai.projects.models import PromptAgentDefinition, MCPTool
from azure.identity import DefaultAzureCredential
# Provide agent configuration details
credential = DefaultAzureCredential()
mcp_endpoint = "{search_service_endpoint}/knowledgebases/{knowledge_base_name}/mcp?api-version=2026-08-01-preview"
project_endpoint = "{project_endpoint}" # e.g. https://your-foundry-resource.services.ai.azure.com/api/projects/your-foundry-project
project_connection_name = "{project_connection_name}"
agent_name = "{agent_name}"
agent_model = "{deployed_LLM}" # e.g. gpt-4.1-mini
# Create project client
project_client = AIProjectClient(endpoint = project_endpoint, credential = credential)
# Define agent instructions (see "Optimize agent instructions" section for guidance)
instructions = """
You are a helpful assistant that must use the knowledge base to answer all the questions from user. You must never answer from your own knowledge under any circumstances.
Every answer must always provide annotations for using the MCP knowledge base tool and render them as: `【message_idx:search_idx†source_name】`
If you cannot find the answer in the provided knowledge base you must respond with "I don't know".
"""
# Create MCP tool with knowledge base connection
mcp_kb_tool = MCPTool(
server_label = "knowledge-base",
server_url = mcp_endpoint,
require_approval = "never",
allowed_tools = ["knowledge_base_retrieve"],
project_connection_id = project_connection_name
)
# Create agent with MCP tool
agent = project_client.agents.create_version(
agent_name = agent_name,
definition = PromptAgentDefinition(
model = agent_model,
instructions = instructions,
tools = [mcp_kb_tool]
)
)
print(f"Agent '{agent_name}' created or updated successfully.")REST
取得用于 Microsoft Foundry 的访问令牌:
az account get-access-token --scope https://ai.azure.com/.default --query accessToken -o tsv通过向 Foundry 智能体服务发送 POST 请求来创建智能体:
POST {project_endpoint}/agents?api-version=v1
Authorization: Bearer {foundry_access_token}
Content-Type: application/json
{
"name": "{agent_name}",
"definition": {
"model": "{deployed_llm}",
"instructions": "\nYou are a helpful assistant that must use the knowledge base to answer all the questions from user. You must never answer from your own knowledge under any circumstances.\nEvery answer must always provide annotations for using the MCP knowledge base tool and render them as: `【message_idx:search_idx†source_name】`\nIf you cannot find the answer in the provided knowledge base you must respond with \"I don't know\".\n",
"tools": [\
{\
"server_label": "knowledge-base",\
"server_url": "{search_service_endpoint}/knowledgebases/{knowledge_base_name}/mcp?api-version=2026-08-01-preview",\
"require_approval": "never",\
"allowed_tools": [\
"knowledge_base_retrieve"\
],\
"project_connection_id": "{project_connection_name}",\
"type": "mcp"\
}\
],
"kind": "prompt"
}
}用 .NET SDK 创建智能体
用 dotnet add package Azure.AI.Projects --prerelease 和 dotnet add package Azure.Identity 安装预发布包。
using Azure.AI.Projects;
using Azure.AI.Projects.Agents;
using Azure.Identity;
using OpenAI.Responses;
#pragma warning disable AAIP001, OPENAI001
var mcpEndpoint = "{search_service_endpoint}/knowledgebases/{knowledge_base_name}/mcp?api-version=2026-05-01-preview";
var projectEndpoint = "{project_endpoint}"; // e.g. https://your-foundry-resource.services.ai.azure.com/api/projects/your-foundry-project
var projectConnectionName = "{project_connection_name}";
var agentName = "{agent_name}";
var agentModel = "gpt-4.1-mini";
AIProjectClient projectClient = new(new Uri(projectEndpoint), new DefaultAzureCredential());
var agentsClient = projectClient.AgentAdministrationClient;
// Define agent instructions (see "Optimize agent instructions" section for guidance).
var instructions = """
You are a helpful assistant that must use the knowledge base to answer all the questions from user. You must never answer from your own knowledge under any circumstances.
Every answer must always provide annotations for using the MCP knowledge base tool and render them as: `【message_idx:search_idx†source_name】`
If you cannot find the answer in the provided knowledge base you must respond with "I don't know".
""";
// Create an MCP tool that points at the knowledge base connection.
McpTool mcpKbTool = ResponseTool.CreateMcpTool(
serverLabel: "knowledge-base",
serverUri: new Uri(mcpEndpoint),
allowedTools: new McpToolFilter { ToolNames = { "knowledge_base_retrieve" } },
toolCallApprovalPolicy: new McpToolCallApprovalPolicy(GlobalMcpToolCallApprovalPolicy.NeverRequireApproval));
mcpKbTool.ProjectConnectionId = projectConnectionName;
// Create the agent with the MCP tool.
DeclarativeAgentDefinition definition = new(model: agentModel)
{
Instructions = instructions,
Tools = { mcpKbTool },
};
ProjectsAgentVersion agent = agentsClient.CreateAgentVersion(
agentName: agentName,
options: new ProjectsAgentVersionCreationOptions(definition));
Console.WriteLine($"Agent '{agentName}' created or updated successfully.");(可选)用逐请求头强制执行权限
如果你的任何知识源包含受权限保护的内容,检索引擎可以筛选结果,使每个用户只看到自己被授权访问的文档。选择如何设置 x-ms-query-source-authorization 头:
- 由智能体服务动态设置:当调用主体是用户时,智能体服务根据该用户的上下文设置该头。无论传入请求的目标是 Foundry 还是智能体蓝图(agent blueprint),这一行为都适用。
- 由应用程序显式设置:当调用主体并不直接代表该用户,或应用程序需要为每个请求选择用户上下文时,通过结构化输入提供用户的 Azure AI 搜索令牌。
下面的模式演示显式选项。如果没有该令牌,启用了权限的来源会返回未筛选的结果。
要让 MCP 头随请求变化,例如在每次调用时传递不同用户的令牌,请在智能体定义中声明一个结构化输入,并在工具的 headers 中把它引用为 {{placeholder}}。调用方在每次调用时提供该值。这一方法适用于绑定到项目连接的 MCP 工具。
对于针对 MCP 服务器的按用户授权,你也可以使用 OAuth 身份直通(OAuth identity passthrough)。
#### Python
更新上一步中的智能体,使 MCP 工具从结构化输入读取其授权头:
from azure.ai.projects.models import StructuredInputDefinition
# Reference the token as a placeholder in the header
mcp_kb_tool = MCPTool(
server_label = "knowledge-base",
server_url = mcp_endpoint,
require_approval = "never",
allowed_tools = ["knowledge_base_retrieve"],
project_connection_id = project_connection_name,
headers = {
"x-ms-query-source-authorization": "{{search_auth_token}}"
}
)
# Declare the structured input so the caller can supply the token per request
agent = project_client.agents.create_version(
agent_name = agent_name,
definition = PromptAgentDefinition(
model = agent_model,
instructions = instructions,
tools = [mcp_kb_tool],
structured_inputs = {
"search_auth_token": StructuredInputDefinition(
description = "Per-user Azure AI Search bearer token",
required = True,
schema = {"type": "string"},
)
}
)
)
print(f"Agent '{agent_name}' created or updated successfully.")调用智能体时,在 structured_inputs 中提供 Azure AI 搜索令牌。此示例从当前 credential 解析令牌。对于多用户应用,改为传递每个已登录用户的令牌。例如,使用通过代表用户(on-behalf-of)流程取得的令牌,以便检索引擎能为该用户筛选结果。
# Resolve an Azure AI Search token from the current credential (use a per-user token in production)
from azure.identity import get_bearer_token_provider
search_token = get_bearer_token_provider(credential, "https://search.azure.com/.default")()
openai_client = project_client.get_openai_client(agent_name=agent.name)
conversation = openai_client.conversations.create()
response = openai_client.responses.create(
conversation = conversation.id,
input = "{user_query}",
extra_body = {
"structured_inputs": {"search_auth_token": search_token},
},
)#### REST
更新智能体创建请求,使 MCP 工具从结构化输入读取其授权头:
POST {project_endpoint}/agents?api-version=v1
Authorization: Bearer {foundry_access_token}
Content-Type: application/json
{
"name": "{agent_name}",
"definition": {
"model": "{deployed_llm}",
"instructions": "\nYou are a helpful assistant that must use the knowledge base to answer all the questions from user. You must never answer from your own knowledge under any circumstances.\nEvery answer must always provide annotations for using the MCP knowledge base tool and render them as: `【message_idx:search_idx†source_name】`\nIf you cannot find the answer in the provided knowledge base you must respond with \"I don't know\".\n",
"tools": [\
{\
"server_label": "knowledge-base",\
"server_url": "{search_service_endpoint}/knowledgebases/{knowledge_base_name}/mcp?api-version=2026-08-01-preview",\
"require_approval": "never",\
"allowed_tools": [\
"knowledge_base_retrieve"\
],\
"project_connection_id": "{project_connection_name}",\
"type": "mcp",\
"headers": {\
"x-ms-query-source-authorization": "{{search_auth_token}}"\
}\
}\
],
"structured_inputs": {
"search_auth_token": {
"description": "Per-user Azure AI Search bearer token",
"required": true,
"schema": { "type": "string" }
}
},
"kind": "prompt"
}
}取得已登录用户用于 Azure AI 搜索的访问令牌:
az account get-access-token --scope https://search.azure.com/.default --query accessToken --output tsv在发送用于调用智能体的 POST 请求时,把令牌放进 structured_inputs:
POST {project_endpoint}/openai/v1/responses
Authorization: Bearer {foundry_access_token}
Content-Type: application/json
{
"conversation": "{conversation_id}",
"input": "{user_query}",
"agent_reference": {
"type": "agent_reference",
"name": "{agent_name}"
},
"structured_inputs": {
"search_auth_token": "{search_bearer_token}"
}
}用查询调用智能体
创建对话会话,并向智能体发送用户查询。在适当的时候,智能体编排对 MCP 工具的调用,从知识库检索相关内容。然后智能体把这些内容合成为引用源文档的自然语言响应。
智能体响应中的引用 URL 因知识源而异。例如,Blob 知识源返回原始文档 URL,而搜索索引知识源则回退到你的知识库的 MCP 终结点。
Python
# Get the OpenAI client for responses and conversations
openai_client = project_client.get_openai_client(agent_name=agent.name)
# Create conversation
conversation = openai_client.conversations.create()
# Send request to trigger the MCP tool
response = openai_client.responses.create(
conversation = conversation.id,
input = """
Why do suburban belts display larger December brightening than urban cores even though absolute light levels are higher downtown?
Why is the Phoenix nighttime street grid is so sharply visible from space, whereas large stretches of the interstate between midwestern cities remain comparatively dim?
""",
)
print(f"Response: {response.output_text}")输出应类似于下面的内容(为简短而截断):
Response: Suburban belts display larger December brightening than urban cores, even
though absolute light levels are higher downtown, primarily because holiday lights
increase most dramatically in the suburbs and outskirts of major cities. This is due
to more yard space and a prevalence of single-family homes in suburban areas...
The Phoenix nighttime street grid is sharply visible from space due to the city's
layout along a regular grid of city blocks and streets with extensive street lighting...
References:
- earth_at_night_508_page_174, earth_at_night_508_page_176 (Holiday lighting)
- earth_at_night_508_page_104, earth_at_night_508_page_105 (Phoenix grid visibility)REST
发送一个空的 POST 请求以创建对话会话:
### Create conversation
POST {project_endpoint}/openai/v1/conversations
Authorization: Bearer {foundry_access_token}
Content-Type: application/json
{}响应包含一个对话 id,你可以用它向智能体发送查询:
### Send request to trigger the MCP tool
POST {project_endpoint}/openai/v1/responses
Authorization: Bearer {foundry_access_token}
Content-Type: application/json
{
"conversation": "{conversation_id}",
"input": "\nWhy do suburban belts display larger December brightening than urban cores even though absolute light levels are higher downtown?\nWhy is the Phoenix nighttime street grid is so sharply visible from space, whereas large stretches of the interstate between midwestern cities remain comparatively dim?\n",
"agent_reference": {
"type": "agent_reference",
"name": "{agent_name}"
}
}响应包含关于智能体执行、工具调用和生成输出的元数据。响应中最相关的部分是 content 字段中的 text,它应类似于下面的内容(为简短而截断):
Suburban belts display larger December brightening in nighttime lights than urban
cores, primarily because suburban areas have more yard space and single-family homes
where holiday lighting decorations are more commonly used...
The Phoenix nighttime street grid is sharply visible due to the regular, planned
layout of city blocks with extensive street lighting, shopping centers, and
commercial properties along major streets...
References:
- earth_at_night_508_page_174_verbalized, earth_at_night_508_page_176_verbalized
- earth_at_night_508_page_104_verbalized, earth_at_night_508_page_105_verbalized删除智能体和项目连接
Python
# Delete the agent
project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version)
print(f"Agent '{agent.name}' version '{agent.version}' deleted successfully.")
# Delete the project connection (Azure Resource Manager)
import requests
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
credential = DefaultAzureCredential()
project_resource_id = "{project_resource_id}"
project_connection_name = "{project_connection_name}"
bearer_token_provider = get_bearer_token_provider(credential, "https://management.azure.com/.default")
headers = {"Authorization": f"Bearer {bearer_token_provider()}"}
response = requests.delete(
f"https://management.azure.com{project_resource_id}/connections/{project_connection_name}?api-version=2025-10-01-preview",
headers=headers,
)
response.raise_for_status()
print(f"Project connection '{project_connection_name}' deleted successfully.")REST
### Delete the agent
DELETE {project_endpoint}/agents/{agent_name}?api-version=v1
Authorization: Bearer {foundry_access_token}
### Delete the project connection
DELETE https://management.azure.com/{project_resource_id}/connections/{project_connection_name}?api-version=2025-10-01-preview
Authorization: Bearer {management_access_token}注意
删除智能体和项目连接并不会删除你的知识库或其知识源。你必须在 Azure AI 搜索服务上单独删除这些对象。
故障排除
本节帮助你排查把 Foundry 智能体服务连接到 Foundry IQ 知识库时的常见问题。
授权失败(401/403)
- 如果你从 Azure AI 搜索收到 403,请确认项目的托管标识在搜索服务上拥有 Search Index Data Reader 角色(如果你写入索引,还要有 Search Index Data Contributor)。
- 如果你在创建或删除项目连接时从 Azure 资源管理器收到 403,请确认你的用户或服务主体在 Microsoft Foundry 资源和项目上拥有权限。
- 如果你使用无密钥认证,请确认你的环境已登录到正确的租户和订阅。
MCP 终结点错误(400/404)
- 确认
search_service_endpoint是 Azure AI 搜索服务 URL,例如https://<name>.search.windows.net。 - 确认
knowledge_base_name与你在 Azure AI 搜索中创建的知识库一致。 - 确认你对知识库 MCP 终结点使用
2026-08-01-previewAPI 版本。
智能体没有把答案扎根于知识库
- 确认智能体已配置 MCP 工具,并且
allowed_tools包含knowledge_base_retrieve。 - 更新智能体指令,明确要求使用知识库,并在检索结果不包含答案时返回 “I don't know”。
PRIMARY_SOURCE: https://learn.microsoft.com/en-us/azure/foundry/agents/how-to/foundry-iq-connect
- #产品教程
- #Foundry
- #知识库
- #MCP
- #权限


