AI代理与向量搜索服务器

一个基于MCP协议的服务器,提供Azure AI Foundry代理、工作流和AI Search向量数据库功能,支持本地和HTTP部署。

  • by denniszielke
  • Python
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 denniszielke/foundry-agents-mcp-server

使用说明

Foundry代理MCP服务器

一 MCP(模型上下文协议) 服务器 公开Azure AI Foundry代理、工作流和AI搜索向量数据库 作为MCP工具的功能。

支持两种传输方式:

  • 标准 –供本地使用 uvx 或VS代码副本
  • 超文本传输协议 –用于部署到 Azure容器应用 通过 azd up

存储库布局

src/
  foundry_agents_mcp/     ← MCP server (10 tools across 4 namespaces)
  foundry_agents/         ← Standalone agent & workflow implementations
    definitions/          ← Declarative YAML agent & workflow definitions
    case_study_agent.py   ← deploy-case-study-agent CLI command
    architecture_agent.py ← deploy-architecture-agent CLI command
    project_log_workflow.py ← run-project-log-workflow CLI command
infra/
  main.bicep              ← Container Apps + managed identity + role assignments
  app/server.bicep        ← Container App definition with health probes
  core/security/role.bicep
azure.yaml                ← azd service definition
Dockerfile                ← Multi-stage Alpine build
entrypoint.sh             ← Selects stdio or HTTP transport at startup
.env.sample               ← Template for local environment configuration

MCP工具命名空间

命名空间 工具
agents_* 列出代理·调用代理·检查状态·获取结果
search_* 语义向量搜索·将文档添加到向量数据库
index_* 创建项目日志索引·摄取项目日志条目
workflows_* 列出示例工作流·运行项目日志管道

先决条件

  • Python 3.10+
  • 紫外线 安装
  • 一 Azure AI Foundry 项目(用于代理工具)
  • 一 Azure人工智能搜索 具有矢量层的资源(用于搜索/索引工具)
  • 一 Azure OpenAI 部署了文本嵌入模型的资源

快速开始使用uvx

# Install and run directly from GitHub (no PyPI package required)
uvx --from git+https://github.com/denniszielke/foundry-agents-mcp-server@main foundry-agents-mcp-server

或者使用显式环境文件:

uvx --from git+https://github.com/denniszielke/foundry-agents-mcp-server@main --env-file .env foundry-agents-mcp-server

配置

所有配置都由环境变量驱动。复制 .env.sample 到 .env 并填写你的价值观。

变量 必填 描述
AZURE_AI_PROJECT_ENDPOINT 对于代理工具 AI Foundry项目端点- https://<account>.services.ai.azure.com/api/projects/<project>
AZURE_OPENAI_ENDPOINT 否 OpenAI兼容端点(回退到 AZURE_AI_PROJECT_ENDPOINT)
AZURE_OPENAI_COMPLETION_MODEL_NAME 对于工作流工具 Foundry帐户中的完成模型部署名称
AZURE_OPENAI_EMBEDDING_MODEL 对于搜索/索引工具 嵌入模型部署名称(默认值: text-embedding-3-small)
AZURE_OPENAI_EMBEDDING_DIMENSIONS 否 嵌入向量大小(默认值: 1536)
AZURE_AI_SEARCH_ENDPOINT 搜索/索引工具 Azure AI搜索服务端点URL
AZURE_AI_SEARCH_INDEX_NAME 否 搜索索引名称(默认值: project-log-index)
APPLICATIONINSIGHTS_CONNECTION_STRING 否 遥测的Application Insights连接字符串

备注 –通过部署时 azd up,所有这些值都将写入 .env 自动通过 infra/write_env.sh.用于当地开发运行 az login 和 使用 DefaultAzureCredential;不需要API密钥。


Claude桌面配置

将以下内容添加到您的 claude_desktop_config.json:

{
  "mcpServers": {
    "foundry-agents": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/denniszielke/foundry-agents-mcp-server@main", "foundry-agents-mcp-server"],
      "env": {
        "AZURE_AI_PROJECT_ENDPOINT": "https://...",
        "AZURE_AI_SEARCH_ENDPOINT": "https://...",
        "AZURE_OPENAI_ENDPOINT": "https://..."
      }
    }
  }
}

工具参考和示例提示

代理命名空间

agents_list_agents

列出Foundry项目中可用的所有代理和工作流,包括其 ID、模型、描述和工具功能。

示例提示

  • “项目中有哪些代理?”
  • “列出我可以调用的所有AI工作流”
  • “向我展示这个Foundry项目中的代理及其能力”

agents_invoke_agent

异步调用代理或工作流。返回一个 调用ID 到 跟踪进度。

参数 类型 说明
agent_id string 来自的代理ID agents_list_agents
task string 任务描述或问题
file_context string(可选) 作为上下文的其他文本或文件内容

示例提示

  • “问代理人 <agent_id> 总结最新的Azure AI公告”
  • “用任务调用研究工作流程:分析人工智能服务的竞争格局”
  • “将此文档发送给分析代理,并将文件文本作为上下文包含在内: <text>"

agents_get_invocation_status

检查代理调用是否仍在运行或已完成。

参数 类型 说明
invocation_id string 调用ID来自 agents_invoke_agent

可能的状态: queued, in_progress, requires_action, cancelling, cancelled, failed, completed, expired

示例提示

  • “检查调用状态 <invocation_id>"
  • “我的代理任务完成了吗?ID: <invocation_id>"
  • “工作流是否仍在运行以供调用 <invocation_id>?"

agents_get_invocation_result

从已完成的调用中检索文本(和文件引用)输出。

参数 类型 说明
invocation_id string 调用ID来自 agents_invoke_agent

示例提示

  • “从调用中获取结果 <invocation_id>"
  • “代理人拿什么身份证回来了 <invocation_id>?"
  • “显示已完成工作流的输出: <invocation_id>"

搜索命名空间

search_vector_db

对项目日志索引执行语义(向量)搜索。

参数 类型 说明
query string 自然语言搜索查询
top_k integer(可选) 结果数(默认值:5)

示例提示

  • “查找与Azure Kubernetes服务相关的项目日志”
  • “搜索关于机器学习的研讨会摘要”
  • “哪些会议讨论了安全架构?”
  • “查找有关微服务的博客文章,返回前10名结果”

search_add_to_vector_db

将文档添加到项目日志向量索引中。内容自动 嵌入并存储在元数据旁边。

参数 类型 说明
title string 文档标题
content string 要嵌入和索引的主文本
entry_type string(可选) workshop, meeting, blog,或 repo (默认值: meeting)
customer_name string(可选) 客户或组织名称
short_summary string(可选) 简要概述
project_name string(可选) 关联的项目名称
tags string(可选) 逗号分隔的标签(例如。 "azure,kubernetes")
reference_url string(可选) 源URL
architecture string(可选) JSON或XML格式的架构图

示例提示

  • “将此会议摘要添加到矢量数据库:title='Azure Workshop',content='…'”
  • “存储有关我们Kubernetes迁移讨论的新项目日志条目”
  • “用标签索引这篇博客文章:azure、容器、devops”

索引命名空间

index_create_project_log_index

使用正确的架构和HNSW创建项目日志Azure AI搜索索引 矢量配置。索引已存在时可以安全调用。

架构字段

字段 类型 注释
id 字符串(键) 自动生成的UUID
title 字符串 可搜索、可过滤、可排序
type 字符串 可过滤、可分面(workshop, meeting, blog, repo)
customer_name 字符串 可过滤、可分面
short_summary 字符串 可搜索
context 字符串 可搜索(全文)
context_vector 集合(单个) HNSW矢量搜索字段
project_name 字符串 可过滤、可分面
tags 集合(字符串) 可筛选、可分面
reference_url 字符串 可搜索
architecture 字符串 可搜索
creation_date DateTimeOffset 可过滤、可排序
modified_date DateTimeOffset 可过滤、可排序

示例提示

  • “设置项目日志搜索索引”
  • “创建Azure AI搜索索引以存储项目摘要”
  • “初始化项目日志的矢量数据库架构”

index_ingest_project_log

将单个项目日志条目引入索引。索引已创建 如果它不存在,则自动执行。

参数 类型 说明
title string 日志条目标题
entry_type 字符串 workshop, meeting, blog,或 repo
customer_name string 客户或组织名称
short_summary string 简要总结(1-2句话)
context string 完整上下文文本(将嵌入)
project_name string(可选) 项目名称
tags string(可选) 逗号分隔的标签
reference_url string(可选) 源URL
architecture string(可选) JSON或XML格式的架构图

示例提示

  • “添加研讨会日志:title='Azure AI Day',entry_type='workshop',customer_name='Contoso',context='…'”
  • “索引有关云迁移项目的新会议摘要”
  • 使用标签存储此仓库文档:python、mcp、azure

示例代理和工作流程

这 foundry_agents 该包提供了两个示例代理和一个管道工作流 其独立于MCP服务器工作。

将代理部署到Azure AI Foundry

在您的Foundry项目中注册示例代理(然后它们会出现在 agents_list_agents 并且可以通过以下方式调用 agents_invoke_agent):

deploy-case-study-agent      # registers CaseStudyAgent
deploy-architecture-agent    # registers ArchitectureAgent

运行项目日志工作流

获取Microsoft客户故事,提取元数据,生成架构 图表,并将所有内容存储在向量索引中——所有这些都在一个命令中:

run-project-log-workflow \
  --url "https://www.microsoft.com/en/customers/story/25676-commerzbank-ag-azure-ai-foundry-agent-service" \
  --project "Commerzbank AI Platform"

或者从MCP服务器触发相同的管道:

Run the project log workflow for https://www.microsoft.com/en/customers/story/...

工作流程 自动使用已部署的Foundry代理 如果可用,以及 否则,将退回到直接的Azure OpenAI推理。


部署到Azure容器应用程序

服务器可以部署到 Azure容器应用 只需一个命令 使用 Azure开发者命令行界面(azd).

配置什么

资源 目的
虚拟网络 容器应用程序环境(始终)运行Direct3D集成
容器应用程序环境 托管MCP服务器;集 USE_PRIVATE_INGRESS=true 仅供内部访问
Azure容器注册表 存储Docker映像
日志分析+应用洞察 遥测和分布式跟踪
Azure AI Foundry(AIServices+项目) 代理API+模型部署(完成+嵌入)
Azure AI搜索 项目日志的矢量搜索索引
用户分配的托管身份 无密码身份验证-分配的Azure AI开发人员、认知服务OpenAI用户、搜索索引数据贡献者和AcrPull角色

Infra文件夹结构

infra/
  abbreviations.json          ← Azure resource name prefixes
  main.bicep                  ← Subscription-scoped orchestrator
  main.parameters.json        ← azd parameter file
  ai/
    foundry.bicep             ← AIServices account + Foundry project + model deployments
    search.bicep              ← Azure AI Search
  app/
    server.bicep              ← MCP server Container App + identity
  core/
    host/
      vnet.bicep              ← VNet with aca-apps subnet (always deployed)
      container-apps.bicep    ← Environment + registry orchestration
      container-apps-environment.bicep  ← Managed environment (usePrivateIngress flag)
      container-app.bicep     ← Container App with health probes + role assignments
      container-app-upsert.bicep
      container-registry.bicep
    monitor/
      monitoring.bicep        ← Log Analytics + Application Insights
      loganalytics.bicep
      applicationinsights.bicep
    security/
      foundry-access.bicep    ← Azure AI Developer + Cognitive Services OpenAI User
      registry-access.bicep   ← AcrPull
      search-access.bicep     ← Search Index Data Contributor

快速部署

# 1. Login
azd auth login

# 2. Create an azd environment
azd env new foundry-mcp
azd env set AZURE_LOCATION swedencentral   # or eastus2, westus3, northcentralus

# 3. (Optional) private ingress – accessible only from within the VNet
azd env set USE_PRIVATE_INGRESS true

# 4. Provision infrastructure (no local Docker required)
azd up

azd up 将:

  1. 提供所有资源(ExpressRoute、容器应用程序、Foundry、搜索、监控)
  2. 跑 infra/write_env.sh 填充 .env 所有端点值

构建和部署容器

容器映像是使用Azure容器注册表(ACR)远程构建的 不需要本地Docker安装.之后 azd up 已配置 基础设施,运行:

# Build in ACR and deploy the Container App
./azd-hooks/deploy.sh foundry-mcp   # pass your azd environment name

脚本将:

  1. 通过ACR远程构建Docker镜像 az acr build
  2. 通过二头肌部署部署容器应用程序(infra/app/server.bicep)
  3. 打印MCP服务器URL

私人入口

当 USE_PRIVATE_INGRESS=true 容器应用程序环境配置为 internal: true 并且容器应用程序入口设置为 external: falseThe 然后,MCP服务器只能从ExpressRoute内访问(例如通过跳转主机, VPN或同一环境中的另一个容器应用程序)。

将VS代码副本连接到部署的服务器

# Find the URL
cat .env | grep MCP_SERVER_URL
  1. 在VS代码中打开命令面板→ MCP:添加服务器 → 超文本传输协议.
  2. 输入URL .env (例如。 https://<app-fqdn>/mcp).
  3. 所有10个Foundry Agent工具现在都可以在Copilot Chat中使用。

使用HTTP传输在本地运行

# Start the HTTP server (same code, same image)
uvicorn foundry_agents_mcp.server:http_app --host 0.0.0.0 --port 8000

# Test the health probe
curl http://localhost:8000/health
# → {"status":"healthy","service":"foundry-agents-mcp-server"}

监控

当以下情况发生时,OpenTetry跟踪会自动启用 APPLICATIONINSIGHTS_CONNECTION_STRING 已设置。每个MCP工具调用和HTTP 通过以下方式跟踪请求 azure-monitor-opentelemetry.

azd monitor   # open the Application Insights dashboard in the portal

拆除

azd down

发展

# Clone and install in editable mode
git clone https://github.com/denniszielke/foundry-agents-mcp-server
cd foundry-agents-mcp-server
pip install -e ".[dev]"

# Run locally (stdio)
python -m foundry_agents_mcp

许可证

麻省理工学院