adf-mcp-server
adf-mcp-server
用于 Azure Data Factory 监控和根因分析的只读 MCP(模型上下文协议)服务器,专为从 VS Code / Claude Code 使用而构建。
状态:第 1 步(骨架 + 健康检查)。 尚无 Azure 连接 - 将在第 2 步(身份验证)和第 3 步(ADF 工具)中添加。
要求
Python 3.11+
一个 Azure AD 应用注册(服务主体),在你要检查的 Data Factory 资源上具有 Reader 角色(Reader 就足够了 - 此服务器端到端只读,因此永远不需要 Contributor)
Related MCP server: mcp-azure-landing-zone
本地设置
cd adf-mcp-server
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
cp .env.example .env创建服务主体(一次性,通过 az-cli)
az ad sp create-for-rbac \
--name "adf-mcp-server-reader" \
--role "Reader" \
--scopes "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RG_NAME>/providers/Microsoft.DataFactory/factories/<FACTORY_NAME>"这会打印 appId、password 和 tenant - 将它们分别映射到 .env 中的 AZURE_CLIENT_ID、AZURE_CLIENT_SECRET 和 AZURE_TENANT_ID。将角色分配范围限定到特定工厂(或最多资源组),而不是整个订阅 - 最小权限,并且此 SPN 永远不需要接触 ADF 之外的任何内容。
运行服务器
python -m adf_mcp.server
# or, after `pip install -e .`:
adf-mcp-server服务器通过 stdio 通信 - 直接在终端中运行它看起来像挂起;这是预期的,它正在等待 MCP 客户端(VS Code 扩展、Claude Code、mcp dev 等)通过 stdin/stdout 连接。
在 VS Code 中配置
将你的支持 MCP 的扩展的服务器配置指向:
{
"command": "python",
"args": ["-m", "adf_mcp.server"],
"cwd": "/absolute/path/to/adf-mcp-server"
}连接后:
调用
health_check- 应返回{"status": "ok", ...},完全不接触 Azure。调用
check_auth- 这会向 Azure AD 发出一次真实调用以获取 ARM 令牌。成功看起来像:{"authenticated": true, "auth_mode": "service_principal", "token_expires_on": 1735000000}失败返回结构化(非堆栈跟踪)说明,例如缺少环境变量或无效密钥 - 请参阅下面的故障排除。
调用
list_factories- 这会向 Azure Data Factory 发出真实调用。返回每个工厂的resource_group,下面所有其他工具都需要它作为输入:{"factories": [{"name": "shell-prod-adf", "resource_group": "rg-shell-prod", "location": "eastus"}]}
可用工具(第 3 步)
所有工具都是只读的 - 它们都不能在 Azure Data Factory 中创建、修改、触发或删除任何内容。
工具 | 必需参数 | 说明 |
| — | 无 Azure 调用 |
| — | 仅验证服务主体 |
| — | 从这里开始 - 返回每个工厂的 |
|
| |
|
| 轻量级:名称 + 活动计数/名称 |
|
| 单个管道的完整活动列表 |
|
|
|
|
| 完整、未截断的运行详情 - 先从 |
代理的示例 RCA 流程:list_factories → list_pipeline_runs(status="Failed") → get_failed_activity_details(run_id=...) 直接获取错误分解。
可用工具(第 4 步新增)
工具 | 必需参数 | 说明 |
|
| 运行的完整活动列表; |
|
| RCA 工具 - 仅失败的活动,已提取 |
|
| 所有触发器 + 当前运行时状态(已启动/已停止) |
|
| 单个触发器的运行时状态 - 捕获“管道从未运行,因为其触发器已停止” |
|
|
|
失败管道的完整 RCA 流程:list_pipeline_runs(status="Failed") → get_failed_activity_details(run_id=...) 获取错误,并单独使用 get_trigger_status(trigger_name=...) 排除“它甚至从未触发”的情况。
运行测试
pip install -e ".[dev]" pytest-asyncio
pytest -v项目结构
参见 src/adf_mcp/ - server.py(MCP 传输)、config.py(设置)、logging_config.py(结构化日志)。从第 3 步开始,在 src/adf_mcp/domain/ 下添加领域逻辑和 Azure 连接。
故障排除
客户端立即显示“服务器已断开”:首先检查
python -m adf_mcp.server能否独立正常运行 - 启动异常会在客户端连接之前终止进程。客户端无法解析响应 / 输出乱码:有东西写入了 stdout,而不是 MCP 协议本身(例如多余的
print())。本项目中的所有日志都输出到 stderr,正是出于这个原因。check_auth返回“缺少必需的服务主体设置”:AZURE_TENANT_ID/AZURE_CLIENT_ID/AZURE_CLIENT_SECRET之一在.env中为空。请注意,这三个不使用ADF_MCP_前缀。check_auth返回“Azure 身份验证失败”:通常是客户端密钥过期/轮换、应用注册被禁用或租户 ID 拼写错误。使用az ad sp show --id <AZURE_CLIENT_ID>重新验证。ClientAuthenticationError: AADSTS7000215:客户端密钥无效 - 在应用注册中重新生成并更新.env。工具返回
{"error": "AZURE_SUBSCRIPTION_ID is not set..."}:将AZURE_SUBSCRIPTION_ID添加到.env- 每个 ADF 工具都需要(check_auth不需要,它只需要租户/客户端/密钥)。工具返回
{"error": "Azure API error (403): ..."}:服务主体缺少对该工厂/资源组的 Reader 访问权限 - 重新检查设置中的az ad sp create-for-rbac --role Reader --scopes ...分配。工具返回
{"error": "Azure API error (404): ..."}:检查resource_group/factory_name/pipeline_name的拼写 - 这些区分大小写,必须与list_factories/list_pipelines返回的内容完全匹配。get_failed_activity_details返回空列表,但你知道管道失败了:失败可能发生在管道级别(例如参数无效),而不是任何单个活动 - 请改用get_pipeline_run检查父运行自身的message。管道“就是没运行”,完全没有失败的运行:检查其触发器的
get_trigger_status-runtime_state: "Stopped"表示触发器已被禁用且从未触发,这不会显示为失败的运行,因为从未创建任何运行。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables interaction with Azure Data Factory instances, allowing users to list, read, create, update, and trigger pipelines, datasets, linked services, and runs through natural language.MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI assistants to inspect and audit Azure Landing Zones by inventorying resources, auditing tagging, evaluating policy compliance, and detecting infrastructure drift, all in read-only mode.
- AlicenseAqualityAmaintenanceA read-only MCP server that reports BI pipeline readiness, blockers, and the next allowed action for governed Power BI workflows. It never writes files, executes warehouse work, or grants human approvals.63182Apache 2.0
- AlicenseAqualityCmaintenanceEnables read-only querying of Azure Log Analytics and Azure Resource Graph through MCP, supporting KQL queries, workspace discovery, and resource inventory exploration with Azure RBAC authentication.52MIT
Related MCP Connectors
Read-only MCP access to sessions, funnels, campaigns, errors, live visitors, and anomalies.
Read-only Dant3 MCP for public rooms, agents, jobs and provisional machine onboarding.
MCP uptime, schema, auth, and SLA receipt monitoring.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/mvcharygenai/adf-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server