PythonのHamiltonでデータ処理のDAGを組み立て、実行・テスト・デバッグするためのスキルです。関数やデコレーターで処理の依存関係を表し、既存コードの分割や可視化も進められます。
- データ加工処理をDAGに整理したいとき
- 既存スクリプトを関数に分割したいとき
- Hamiltonの関数をテストしたいとき
HamiltonのMCPツールを使い、データ処理のひな形作成からDAGの検証・可視化・実行までを会話の中で進め、構造上の誤りを直しながらパイプラインを組み立てます。
Interactive Hamilton DAG development via MCP tools. Validate, visualize, scaffold, and execute Hamilton pipelines without leaving the conversation. Use when building or debugging Hamilton dataflows interactively.
実行スコア 未検証
インストール方法を見るHamiltonのMCPサーバーが提供するツールを使い、データ処理パイプラインを会話の中で組み立て、検証し、実行する手順を扱います。利用するデータライブラリを確認してから、用途に合ったコードのひな形を作成します。実行前にはDAG(処理の依存関係を表す有向グラフ)を検証し、構文エラー、依存先の不足、型注釈、循環参照などを確認します。必要に応じて構造を図にし、各ノードの入出力や依存関係を調べてから実行できます。エラーが出た場合の修正手順や、MCPサーバーが使えない場合のCLIによる代替方法も説明します。
Hamiltonを使い始める際に、パイプラインの初期コードを用意したい人に向いています。コードの構造を実行前に確かめたい場合や、依存関係を見ながら対話形式でエラーを直したい場合にも役立ちます。
Hamilton MCPサーバーとapache-hamilton[mcp]が必要です。利用するデータライブラリに応じた追加インストールが必要な場合があります。実行ツールはPythonコードを実行するため、実行前の検証が必要です。
この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。
インストールする前に、エージェントに与えられる指示の中身を確認できます。
The Hamilton MCP server exposes Hamilton's DAG compilation, validation, and execution as interactive tools. It enables a tight feedback loop: write functions, validate the DAG, visualize dependencies, fix errors, and execute -- all without leaving the conversation.
Run via uvx (recommended). Add --with for whichever libraries your code uses:
uvx --from "apache-hamilton[mcp]" hamilton-mcp # minimal
uvx --from "apache-hamilton[mcp]" --with pandas --with numpy hamilton-mcp # pandas/numpy project
uvx --from "apache-hamilton[mcp]" --with polars hamilton-mcp # polars project
Or install and run directly:
pip install "apache-hamilton[mcp]"
hamilton-mcp
Or use programmatically:
from hamilton.plugins.h_mcp import get_mcp_server
mcp = get_mcp_server()
mcp.run()
Always follow this sequence when building Hamilton DAGs interactively:
ask user -> capabilities -> scaffold -> validate -> visualize -> correct -> execute
Before calling any tool, ask the user which data libraries they use (pandas, numpy, polars, etc.). Then pass their answer as preferred_libraries to hamilton_capabilities and hamilton_scaffold. This ensures scaffolds match the user's project, not the server's environment.
// Example: user says "I use pandas"
// Tool call: hamilton_capabilities(preferred_libraries=["pandas"])
{
"libraries": {
"pandas": true,
"numpy": true,
"polars": false,
"graphviz": true
},
"available_scaffolds": [
"basic", "basic_pure_python", "config_based",
"data_pipeline", "parameterized"
]
}
Decision rules:
basic_pure_python scaffold and int/float/str/dict typesgraphviz is available: use hamilton_visualize to show the DAG structureUse hamilton_scaffold with a pattern name from the capabilities response:
| Pattern | Libraries Required | Use Case |
|---|---|---|
basic_pure_python | None | Simple pipelines with built-in types |
basic | pandas | DataFrame cleaning & counting |
parameterized | pandas | Multiple nodes from one function |
config_based | pandas | Environment-conditional logic |
data_pipeline | pandas | ETL: ingest, clean, transform, aggregate |
ml_pipeline | pandas, numpy | Feature engineering & train/test split |
data_quality | pandas, numpy | Validation with @check_output |
Always validate before executing. hamilton_validate_dag compiles the DAG without running it, catching:
// Success response
{
"valid": true,
"node_count": 5,
"nodes": ["cleaned", "feature_a", "feature_b", "raw_data", "result"],
"inputs": ["data_path"],
"errors": []
}
// Failure response
{
"valid": false,
"node_count": 0,
"nodes": [],
"inputs": [],
"errors": [{"type": "SyntaxError", "message": "...", "detail": "line 5"}]
}
Self-correction loop: If validation fails, read the error, fix the code, and validate again. Do not proceed to execution until validation passes.
hamilton_visualize returns DOT graph source. Use this to:
hamilton_list_nodes returns structured info for every node:
Use this to understand what inputs the DAG needs before execution.
hamilton_execute runs the DAG with provided inputs and returns results. Key parameters:
code: The full Python sourcefinal_vars: List of node names to compute (only these and their dependencies run)inputs: Dict of external input valuestimeout_seconds: Safety limit (default 30s)WARNING: This executes arbitrary Python code. Always validate first.
"No module named 'X'"
The code imports a library that isn't installed. Call hamilton_capabilities to check availability, then rewrite without the missing library.
"Missing dependencies: ['node_name']" A function parameter doesn't match any function name or external input. Either:
inputs when executing"Execution timed out after Ns"
The code takes too long. Reduce data size, simplify computation, or increase timeout_seconds.
Validation passes but execution fails Validation checks structure, not runtime behavior. Common causes:
| Tool | Purpose | When to Use |
|---|---|---|
hamilton_capabilities | Environment discovery | Always first |
hamilton_scaffold | Generate starter code | Starting a new pipeline |
hamilton_validate_dag | Compile-time validation | Before every execution |
hamilton_list_nodes | Inspect DAG structure | Understanding dependencies |
hamilton_visualize | DOT graph generation | Explaining structure (requires graphviz) |
hamilton_execute | Run the DAG | After successful validation |
hamilton_get_docs | Hamilton documentation | Learning decorators, patterns |
If the MCP server is not running: Fall back to CLI:
# Validate a module
python -c "from hamilton import driver; import my_module; dr = driver.Builder().with_modules(my_module).build(); print('Valid!')"
If Hamilton is not installed: Provide the user with installation instructions:
uvx --from "apache-hamilton[mcp]" hamilton-mcp # Run via uvx (add --with <lib> as needed)
pip install "apache-hamilton[mcp]" # Or install directly
A successful MCP interaction produces:
hamilton_validate_dag with zero errorshamilton_list_nodeshamilton_execute/hamilton-core/hamilton-scale/hamilton-llm/hamilton-observabilityhamilton_get_docs("overview")まだレビューはありません。使ってみた感想をお寄せください。
ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。
まだコメントはありません。最初のコメントを書いてみませんか。
PythonのHamiltonでデータ処理のDAGを組み立て、実行・テスト・デバッグするためのスキルです。関数やデコレーターで処理の依存関係を表し、既存コードの分割や可視化も進められます。
Hamiltonの新しいデータフローを、DOT図の設計から構造検証、ノード単位のテスト駆動実装まで順序立てて作る手順を案内します。
Hamiltonのデータ処理フローをAirflowやFastAPIなどに組み込み、定期実行、予測API、ダッシュボード、ノートブックで活用する方法を扱います。
HamiltonでRAGや埋め込み、ベクトルデータベース、プロンプトを組み合わせたLLMワークフローを設計し、並列実行やキャッシュ、構造化出力を使う実装パターンを学べます。
Hamiltonのデータフロー実行をUIとSDKで記録し、処理履歴や依存関係、失敗箇所、実行時間を確認して、開発時のデバッグや本番監視に役立てます。
Hamiltonの処理を規模や負荷に応じて高速化するため、非同期I/Oやマルチスレッド、Spark・Ray・Daskによる並列化とキャッシュの使い分けを学べます。