Skip to main content
Glama

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"
}

接続後:

  1. health_check を呼び出します。Azure に一切触れずに {"status": "ok", ...} が返るはずです。

  2. check_auth を呼び出します。これは Azure AD に対して実際に 1 回呼び出しを行い、ARM トークンを取得します。成功すると次のようになります:

    {"authenticated": true, "auth_mode": "service_principal", "token_expires_on": 1735000000}

    失敗した場合は、スタック トレースではなく構造化された説明が返されます (例: 環境変数の欠落、シークレットの無効など)。下記の「トラブルシューティング」を参照してください。

  3. list_factories を呼び出します。これは Azure Data Factory に対して実際に呼び出しを行います。各ファクトリの resource_group が返されます。これは以下のすべてのツールで入力として必要です:

    {"factories": [{"name": "shell-prod-adf", "resource_group": "rg-shell-prod", "location": "eastus"}]}

利用可能なツール (ステップ 3)

すべてのツールは 読み取り専用 です。Azure Data Factory 内の何かを作成、変更、トリガー、削除することはできません。

ツール

必須引数

備考

health_check

—

Azure 呼び出しなし

check_auth

—

サービス プリンシパルのみを検証します

list_factories

—

ここから開始します。各ファクトリの resource_group を返します

get_factory

resource_group, factory_name

list_pipelines

resource_group, factory_name

軽量: 名前 + アクティビティ数/名前

get_pipeline

resource_group, factory_name, pipeline_name

1 つのパイプラインの完全なアクティビティ一覧

list_pipeline_runs

resource_group, factory_name

start_time/end_time は省略可能 (デフォルト: 過去 24 時間)。さらに省略可能な pipeline_name/status フィルター。メッセージは 500 文字に切り詰められます。

get_pipeline_run

resource_group, factory_name, run_id

完全で切り詰めのない実行詳細。run_id は最初に list_pipeline_runs から取得します。

エージェント向けの RCA フローの例: list_factories → list_pipeline_runs(status="Failed") → get_failed_activity_details(run_id=...) でエラーの内訳を直接取得します。

利用可能なツール (ステップ 4 の追加)

ツール

必須引数

備考

list_activity_runs

resource_group, factory_name, run_id

実行の完全なアクティビティ一覧。start_time/end_time は省略可能 (デフォルト: 過去 7 日間)

get_failed_activity_details

resource_group, factory_name, run_id

RCA ツール。失敗したアクティビティのみ。error_code/message/failure_type はすでに抽出済み

list_triggers

resource_group, factory_name

すべてのトリガーと現在のランタイム状態 (開始済み/停止済み)

get_trigger_status

resource_group, factory_name, trigger_name

1 つのトリガーのランタイム状態。「トリガーが停止していたためパイプラインが実行されなかった」ケースを検出します

list_trigger_runs

resource_group, factory_name

trigger_name は省略可能 (省略時はすべてのトリガー)。デフォルトのウィンドウは過去 7 日間。省略可能な status フィルター

失敗したパイプラインの完全な 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 tools
check_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

    A3.6/5.0

    Scored across 13 tools

    Disambiguation5/5

    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.

    Naming Consistency4/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables 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.
      11
      41 npm
      2
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables 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.
      -
    • A
      license
      B
      quality
      C
      maintenance
      Provides read-only access to multiple production services with unified status and timeline tools for cross-service monitoring and diagnostics.
      13
      1
      MIT