adf-mcp-server
adf-mcp-server
Azure Data Factory の監視と根本原因分析のための読み取り専用 MCP (Model Context Protocol) サーバーです。VS Code / Claude Code から使用することを想定しています。
ステータス: ステップ 1 (スケルトン + ヘルスチェック)。 まだ Azure 接続はありません。これはステップ 2 (認証) とステップ 3 (ADF ツール) で追加されます。
要件
Python 3.11+
検査対象の Data Factory リソースに対して Reader ロールを持つ Azure AD アプリ登録 (サービス プリンシパル) (Reader で十分です。このサーバーはエンドツーエンドで読み取り専用のため、Contributor は不要です)
Related MCP server: adf-mcp-server
ローカル設定
cd adf-mcp-server
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
cp .env.example .envサービス プリンシパルの作成 (1 回限り、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を呼び出します。Azure に一切触れずに{"status": "ok", ...}が返るはずです。check_authを呼び出します。これは Azure AD に対して実際に 1 回呼び出しを行い、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 呼び出しなし |
| — | サービス プリンシパルのみを検証します |
| — | ここから開始します。各ファクトリの |
|
| |
|
| 軽量: 名前 + アクティビティ数/名前 |
|
| 1 つのパイプラインの完全なアクティビティ一覧 |
|
|
|
|
| 完全で切り詰めのない実行詳細。 |
エージェント向けの RCA フローの例: list_factories → list_pipeline_runs(status="Failed") → get_failed_activity_details(run_id=...) でエラーの内訳を直接取得します。
利用可能なツール (ステップ 4 の追加)
ツール | 必須引数 | 備考 |
|
| 実行の完全なアクティビティ一覧。 |
|
| RCA ツール。失敗したアクティビティのみ。 |
|
| すべてのトリガーと現在のランタイム状態 (開始済み/停止済み) |
|
| 1 つのトリガーのランタイム状態。「トリガーが停止していたためパイプラインが実行されなかった」ケースを検出します |
|
|
|
失敗したパイプラインの完全な 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 (構造化ログ)。ドメイン ロジックと Azure 接続は、ステップ 3 以降で src/adf_mcp/domain/ の下に追加されます。
トラブルシューティング
クライアントに「サーバーがすぐに切断された」と表示される: まず
python -m adf_mcp.serverが単独で正常に実行されることを確認してください。起動時の例外は、クライアントが接続する前にプロセスを強制終了させます。クライアントが応答を解析できない / 出力が文字化けする: MCP プロトコル以外の何かが stdout に書き込まれています (例: 余分な
print())。このプロジェクトのすべてのログは、まさにこの理由で stderr に出力されます。check_authが「Missing required Service Principal setting(s)」を返す:.env内のAZURE_TENANT_ID/AZURE_CLIENT_ID/AZURE_CLIENT_SECRETのいずれかが空です。これら 3 つにはADF_MCP_プレフィックスが付かないことに注意してください。check_authが「Azure authentication failed」を返す: 通常は、クライアント シークレットの期限切れ/ローテーション、アプリ登録の無効化、テナント ID のタイプミスが原因です。az ad sp show --id <AZURE_CLIENT_ID>で再確認してください。ClientAuthenticationError: AADSTS7000215: クライアント シークレットが無効です。アプリ登録で再生成し、.envを更新してください。ツールが
{"error": "AZURE_SUBSCRIPTION_ID is not set..."}を返す:.envにAZURE_SUBSCRIPTION_IDを追加してください。これはすべての 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が空のリストを返すが、パイプラインが失敗したことがわかっている場合: 失敗がパイプライン レベル (例: 無効なパラメーター) で発生している可能性があります。個々のアクティビティではなく、親実行のmessageをget_pipeline_runで確認してください。パイプラインが「単に実行されなかった」が、失敗した実行がまったくない場合: そのトリガーの
get_trigger_statusを確認してください。runtime_state: "Stopped"は、トリガーが無効化されて起動しなかったことを意味します。実行が作成されていないため、失敗した実行としては表示されません。
Available Tools
13 toolscheck_authA
Verify Azure Service Principal credentials by acquiring a real ARM token.
Makes no Azure Data Factory calls - it only proves auth is configured correctly (tenant/client/secret valid, SPN enabled) before any ADF connectivity exists. Run this after health_check and before Step 3.
Inputs: no named parameters. Returns: object
get_factoryC
Get details for a single Data Factory instance.
Inputs: factory_name (required), resource_group (required). Returns: object
get_failed_activity_detailsA
RCA convenience tool: returns only the activities that failed within a pipeline run, each with error_code/message/failure_type already extracted. Prefer this over list_activity_runs when you just need "what went wrong" rather than the full activity list.
Inputs: run_id (required), factory_name (required), resource_group (required), end_time, +1 more. Returns: object
get_pipelineC
Get a single pipeline's activity list.
Inputs: factory_name (required), pipeline_name (required), resource_group (required). Returns: object
get_pipeline_runB
Get full, untruncated detail for a single pipeline run.
Get run_id from list_pipeline_runs first.
Inputs: run_id (required), factory_name (required), resource_group (required). Returns: object
get_trigger_statusB
Get a single trigger's current runtime state. A stopped trigger is a common silent cause of "why didn't this pipeline run today" - the pipeline simply was never invoked, so pipeline-run history alone won't show it.
Inputs: factory_name (required), trigger_name (required), resource_group (required). Returns: object
health_checkA
Report that the MCP server is up and configuration loaded correctly.
Useful as a first call from any MCP client (VS Code, Claude Code) to confirm the server started, before any Azure-dependent tools exist.
Inputs: no named parameters. Returns: object
list_activity_runsA
List every activity run within a pipeline run, each with error detail populated if it failed. Time window defaults to the last 7 days. Get run_id from list_pipeline_runs first.
Inputs: run_id (required), factory_name (required), resource_group (required), end_time, +1 more. Returns: object
list_factoriesA
List all Data Factory instances the configured Service Principal can see.
Returns each factory's resource_group, which every other ADF tool below requires as an input - call this first.
Inputs: no named parameters. Returns: object
list_pipeline_runsA
List pipeline runs in a time window (default: last 24 hours).
Time values are ISO 8601 strings, e.g. "2026-08-22T00:00:00Z". Narrow results with pipeline_name and/or status (e.g. "Failed", "Succeeded", "InProgress"). Run messages are truncated to 500 chars here - use get_pipeline_run with a run_id from this result for full detail.
Inputs: factory_name (required), resource_group (required), status, end_time, +2 more. Returns: object
list_pipelinesA
List pipelines in a factory with a lightweight activity summary (count and names only - use get_pipeline for full detail on one).
Inputs: factory_name (required), resource_group (required). Returns: object
list_trigger_runsA
List trigger firing history (default: last 7 days). Omit trigger_name to see every trigger's runs, or narrow to one; filter by status (e.g. "Succeeded", "Failed") to spot triggers that fired but errored.
Inputs: factory_name (required), resource_group (required), status, end_time, +2 more. Returns: object
list_triggersA
List every trigger in a factory with its current runtime state (Started/Stopped).
Inputs: factory_name (required), resource_group (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Each tool targets a distinct layer of the ADF workflow: health/auth bootstrap, factory discovery, pipeline inspection, run monitoring, activity diagnostics, and trigger management. Even the closest pair, list_activity_runs and get_failed_activity_details, is clearly separated by scope and purpose.
The naming is overwhelmingly consistent with list_/get_ + resource noun in snake_case, and the run-related tools follow a clear pattern. health_check is a minor convention break compared to check_auth, but this is a small deviation in an otherwise predictable set.
13 tools is well-scoped for an ADF server: each tool maps to a distinct object hierarchy or bootstrap step without unnecessary redundancy. The count is substantial enough to cover real workflows but not bloated.
The set covers the read-only factory, pipeline, run, activity, and trigger diagnostics lifecycle well, including failure RCA. It lacks any management/remediation operations such as stopping or starting triggers, canceling runs, or rerunning pipelines, so it is slightly incomplete for full operational control.
Related MCP Connectors
Read-only MCP access to sessions, funnels, campaigns, errors, live visitors, and anomalies.
Read-only access to a Lumin project's logs, metrics, uptime checks, alerts and infrastructure.
Read-only MCP for identity resolution and write guardrails.
Provides read access to your GKE and Kubernetes resources.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables 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.1141 npm2MIT
- FlicenseAqualityDmaintenanceProvides a read-only MCP interface for Azure Data Factory monitoring and root-cause analysis, with a health check for MCP clients.1-
- FlicenseNot gradedqualityDmaintenanceEnables read-only monitoring and root-cause analysis of Azure Data Factory resources through MCP, allowing users to inspect factories, pipelines, and pipeline runs and diagnose failures via natural language.-
- AlicenseBqualityCmaintenanceProvides read-only access to multiple production services with unified status and timeline tools for cross-service monitoring and diagnostics.131MIT