Fitter について
Fitter は、データの取得元と抽出内容を宣言的な JSON/YAML 設定で記述し、Web サイトや API を構造化 JSON に変換するツールです。Fitter MCP を使うと、Claude Code や Claude Desktop などのクライアントがローカルで設定を作成、検証、実行できます。設定はプレーンデータのため、確認、保存、再実行が可能です。
主な機能
- 01JSON/YAML による宣言的なスクレイピング設定
- 02MCP ツールによる設定の検証と実行
- 03HTTP、ヘッドレスブラウザ、ファイル、静的値のソース
- 04stdio とストリーミング HTTP のトランスポート
- 05Prometheus メトリクスと Docker イメージ
活用シーン
- 01自然言語の依頼からスクレイピング設定を生成して実行
- 02検証済みの設定を定期実行ジョブやサービス設定に転用
- 03API のない Web ページを取得し JSON API でデータを補完
MCP 対応
Fitter MCP は MCP サーバーであり、fitter_run、fitter_validate_config、fitter_inspect_url などのツールと設定リファレンスのリソースを MCP クライアントに公開します。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。
ツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
Fitter — AI エージェント向けのウェブデータ
Fitter は、あらゆるウェブサイトや API を宣言的に構造化 JSON に変換します。 1 つの JSON/YAML 設定で、データの場所(HTTP リクエスト、ヘッドレスブラウザー、ファイル、静的値)と抽出方法(JSON パス、CSS セレクター、XPath)を指定できます。コードも、壊れやすいスクレイピングスクリプトも不要です。
🚀 ブラウザーでお試しください — WebAssembly にコンパイルされた実際のエンジンです。ライブサンプル、ビジュアル設定ビルダーを備え、インストールは不要です。
設定はプレーンなデータなので、LLM が作成できます。組み込みの MCP サーバーを使えば、Claude Code、Claude Desktop、その他のあらゆる MCP クライアントが、必要に応じてお使いのマシン上でスクレイピングのワークフローを作成し、実行できます。
「HackerNews の上位 5 件のストーリーについて、タイトルとスコアを取得して」 → モデルが Fitter 設定を作成し、検証してローカルで実行し、整った JSON を返します。
1 つのエンジンを、5 通りの方法で利用できます。
| 🤖 Fitter MCP | Claude Code、Claude Desktop、その他のあらゆる MCP クライアントに Fitter を提供する MCP サーバー |
| 🧠 Fitter Agent | AI 搭載の CLI:自然言語 → 設定 → 実行結果 |
| 🖥 Fitter CLI | テスト/デバッグ/個人利用向けに設定をローカルで実行 |
| 📦 Fitter Lib | エンジンを独自の Go プログラムに組み込み |
| ⚙️ Fitter | スケジュール設定と通知に対応した長時間実行サービスモード |
AI エージェントに Fitter が適している理由
- 宣言的で監査可能 — エージェントが生成するのは、使い捨てのコードではなく、読んで保存し、再実行できる設定です
- ローカル優先 — データの取得はすべてお使いのマシン上で行われます。サードパーティのスクレイピング API も、キーも、リクエストごとの課金もありません
- 必要な機能をすべて内蔵 — HTTP クライアント、ヘッドレスブラウザー(Playwright/Chromium/Docker)、JSON/HTML/XML/XPath/PDF の解析、ページネーション、キャッシュされた参照情報、ホストごとのレート制限を、単一の静的バイナリに搭載しています
- 再利用可能 — 今日エージェントが作成したものを、明日は cron ジョブやサービス設定として利用できます
Fitter_MCP の使い方
Fitter MCP は Model Context Protocol サーバー(stdio トランスポート)です。Claude Code、Claude Desktop、IDE アシスタント、カスタムエージェントなど、あらゆる MCP クライアントが Fitter の設定を実行し、構造化 JSON を取得できます。
クイックスタート(Claude Desktop — ワンクリック)
リリースページから fitter-mcp-<os>-<arch>.mcpb をダウンロードして開くと、Claude Desktop がサーバーを自動的にインストールします。
クイックスタート(Claude Code)
# 1. get the binary: download fitter_mcp_<version>-<os>-<arch> from the release page
# https://github.com/PxyUp/fitter/releases — or build it from source:
go build -o fitter_mcp ./cmd/mcp
# 2. register it once, available in every project
claude mcp add fitter -s user -- "$(pwd)/fitter_mcp"
あとは、次のように依頼するだけです。
fitter を使って、HackerNews の上位 5 件のストーリーについて、タイトルとスコアを取得して
モデルは fitter_config_reference を呼び出して設定を作成し、必要に応じて fitter_validate_config で確認してから、fitter_run で実行します。データの取得はすべてお使いのマシン上で行われます。すぐに使えるパイプラインとして、examples/config_morning_briefing.json をお試しください。
examples/config_morning_briefing.json を fitter で実行して、ブリーフィングを作成して
Claude Desktop への登録
{
"mcpServers": {
"fitter": {
"command": "/path/to/fitter_mcp"
}
}
}
ブラウザーのサポート(Playwright)
.mcpb バンドルとネイティブバイナリには、ブラウザーは同梱されていません。HTTP、静的コンテンツ、ファイルのコネクターはそのまま使えますが、ブラウザー設定(playwright コネクター)には Playwright のブラウザーが必要です。入手方法はいくつかあります。
- 初回使用時(ネイティブバイナリ/
.mcpb): Playwright コネクターに"install": trueを設定します。fitter は、組み込みのplaywright-goバージョンに対応するドライバーとブラウザーを初回使用時にダウンロードします(一度だけで、キャッシュされます)。そのため、別途インストールする必要はありません。 - 事前インストール(ネイティブ、任意): 初回実行時のダウンロードを避けるには、fitter のビルドに使われているものと同じ
playwright-goバージョンで、あらかじめブラウザーをインストールします(go.modを確認してください。現在はv0.6100.0です)。
バージョンはgo run github.com/mxschmitt/playwright-go/cmd/[email protected] install # Linux: append --with-deps to also install the required OS librariesgo.modと完全に一致している必要があります。playwright-goは、バージョンが一致しないドライバーでは実行できません。その後、"install": trueを指定せずに設定を実行します。 - Docker: Chromium、Firefox、WebKit がインストール済みの
ghcr.io/pxyup/fitter-mcp:playwrightイメージを使用します("install": trueは不要です)。
ツール
| ツール | 説明 |
|---|---|
fitter_run | インラインで渡された Fitter 設定(JSON または YAML 文字列)を実行し、抽出データを JSON として返します。任意の input 値を受け付け、設定内で {{{FromInput=.}}} / {{{FromInput=json.path}}} を使って利用できます |
fitter_run_file | fitter_run と同じですが、ローカルの .json/.yaml ファイルから設定を読み込みます |
fitter_run_url | fitter_run と同じですが、GitHub の raw リンクなど、HTTP(S) URL から設定をダウンロードします |
fitter_inspect_url | URL を取得し、簡潔な構造の概要と候補となるセレクター/パスを返します(JSON では gjson パス、HTML では繰り返し要素/リスト行のセレクター)。モデルがセレクターを推測して null を返すのではなく、最初から設定を作成できるようにします。クライアント側でレンダリングされる SPA を検出し、ヘッドレスブラウザーで render することもできます。読み取り専用で、抽出は行いません |
fitter_validate_config | 設定を実行せずに検証します(構造、response_type、コネクターのデータソース、モデル)。設定を調整する際に便利です |
fitter_config_reference | 動作する例とともに、設定形式全体の要約リファレンス(コネクター、パーサー、モデル/フィールドのスキーマ、プレースホルダー、通知先、参照、制限)を返します。モデルは外部ドキュメントなしで設定を作成できます |
リソースに対応するクライアント向けに、リファレンスは MCP リソース fitter://config-reference としても公開されています。
設定形式は Fitter_CLI とまったく同じです。トップレベルオブジェクトに item(必須)、limits、references を指定します。通知先 も使用できます(結果はさらに http/telegram/redis/file/console に送信されます)。trigger_config と http_server はサービスモード専用であり、MCP 呼び出しでは無視されます。
リモート/ホストモード(ストリーミング可能な HTTP)
デフォルトでは、fitter_mcp は stdio を使用します。代わりに ストリーミング可能な HTTP トランスポート を提供するには、--http を渡します。共有チームサーバー、コンテナー、またはリモート環境へのデプロイに利用できます。
# serve MCP at http://<host>:8080/mcp (health probe at /healthz)
FITTER_MCP_AUTH_TOKEN=my-secret fitter_mcp --http :8080
# register the remote endpoint in Claude Code
claude mcp add --transport http fitter http://localhost:8080/mcp --header "Authorization: Bearer my-secret"
--http <addr>(環境変数FITTER_MCP_HTTP_ADDR)— リッスンアドレス。空の場合は stdio モードですFITTER_MCP_AUTH_TOKEN— 設定すると、すべての/mcpリクエストでAuthorization: Bearer <token>の送信が必要です。設定しない場合、エンドポイントは認証なしになるため、localhost にバインドするか、プロキシの背後に配置してください--stateless(環境変数FITTER_MCP_STATELESS=true)— セッションごとの状態を持たないため、スティッキーセッションなしでレプリカをロードバランサーの背後に配置できます--metrics-addr <addr>(環境変数FITTER_MCP_METRICS_ADDR)— Prometheus メトリクスを別のアドレス(例:127.0.0.1:9091)で提供します。stdio モードでも動作し、空の場合は無効になります。メソッド別の MCP リクエスト数、ツールおよび結果別のツール呼び出し所要時間、ホスト、メソッド、ステータス別の送信 HTTP リクエスト所要時間を公開します。このエンドポイントには認証がないため、localhost またはプライベートインターフェースにバインドしてください
サーバーは SIGINT/SIGTERM を受け取ると、正常にシャットダウンします。
Docker
スリムなマルチアーキテクチャイメージ(linux/amd64 + linux/arm64)を、すべてのリリースで提供しています:
# hosted HTTP mode
docker run --rm -p 8080:8080 \
-e FITTER_MCP_HTTP_ADDR=:8080 \
-e FITTER_MCP_AUTH_TOKEN=my-secret \
ghcr.io/pxyup/fitter-mcp:latest
# or stdio mode, spawned by the MCP client
claude mcp add fitter -s user -- docker run --rm -i ghcr.io/pxyup/fitter-mcp:latest
スリムイメージには、fitter バイナリと CA 証明書のみが含まれます。サーバー/静的/ファイルコネクターは動作しますが、ブラウザーコネクター(chromium/docker/playwright)は動作しません。
ブラウザーベースの設定には、Playwright と Chromium、Firefox、WebKit がバンドルされた playwright バリアントを使用してください(fitter のビルド対象となった playwright-go のバージョンに合わせてあるため、設定で "install": true を指定する必要はありません):
docker run --rm -i ghcr.io/pxyup/fitter-mcp:playwright # stdio mode
# per-release tag: ghcr.io/pxyup/fitter-mcp:vX.Y.Z-playwright
これは Dockerfile.mcp-playwright からビルドされます。Chromium のみを含む小型イメージをビルドするには、--build-arg PLAYWRIGHT_BROWSERS=chromium を指定してください。
Docker での OAuth2 アカウント
どちらのイメージにも fitter_cli が含まれているため、初回の OAuth2 ログインをコンテナー内で実行できます。トークンを /tokens にマウントしたボリュームに保存し(イメージ内で書き込み可能な状態で事前作成されています)、MCP サーバーと共有してください:
# one-time login, device flow: no ports needed — open the printed url on any device
docker run --rm -it -v fitter-tokens:/tokens --entrypoint fitter_cli \
ghcr.io/pxyup/fitter-mcp:latest \
auth --provider github --client-id <ID> --client-secret <SECRET> --token-file /tokens/github.json
# or browser flow (device flow not enabled for the app): publish the callback port and
# bind on 0.0.0.0 so the published port reaches the listener; the browser still visits 127.0.0.1
docker run --rm -it -p 8988:8988 -e FITTER_AUTH_LISTEN=0.0.0.0 \
-v fitter-tokens:/tokens --entrypoint fitter_cli ghcr.io/pxyup/fitter-mcp:latest \
auth --provider github --client-id <ID> --client-secret <SECRET> --token-file /tokens/github.json
# then run the MCP server with the same volume; configs reference "token_file": "/tokens/github.json"
# stdio mode (spawned by the MCP client, no port):
docker run --rm -i -v fitter-tokens:/tokens ghcr.io/pxyup/fitter-mcp:latest
# hosted HTTP mode (MCP endpoint on 8080, like the run examples above):
docker run --rm -p 8080:8080 -v fitter-tokens:/tokens \
-e FITTER_MCP_HTTP_ADDR=:8080 \
-e FITTER_MCP_AUTH_TOKEN=my-secret \
ghcr.io/pxyup/fitter-mcp:latest
注:8988 は初回のブラウザーフローログイン専用です。MCP サーバーは stdio モードではポート不要で、ホスト型 HTTP モードでは 8080 のみ必要です。
Docker でのログイン済みブラウザーセッション
ブラウザーセッションには playwright イメージが必要です(スリムイメージにはブラウザーがありません)。初回のヘッドフルログインにはディスプレイが必要なため、ホスト上で実行してから、セッションディレクトリをコンテナーにバインドマウントしてください(イメージ内には書き込み可能な /sessions が事前作成されています):
# on the host: log in once, save the session
fitter_cli browser-login --url https://example.com/login --storage-state ~/.fitter/sessions/example.json
# run the MCP server with the sessions dir mounted; configs reference "storage_state_file": "/sessions/example.json"
docker run --rm -i -v ~/.fitter/sessions:/sessions ghcr.io/pxyup/fitter-mcp:playwright
名前付きボリュームではなく、バインドマウントを使用してください。コンテナーは実行のたびに更新された Cookie を書き戻すため、ホスト側のコピーが最新の状態に保たれ、いつでも browser-login で有効期限を延長できます。
更新トークンは更新のたびに書き戻されるため、サーバーがボリュームに書き込める状態を維持してください。
環境変数
- FITTER_PLUGINS - string[""] - プラグインフォルダーのパス。Fitter/Fitter_CLI の
--pluginsフラグと同じです - FITTER_MCP_HTTP_ADDR - string[""] - リモートモード用のリッスンアドレス。
--httpと同じです - FITTER_MCP_AUTH_TOKEN - string[""] - HTTP エンドポイントを保護するベアラートークン
- FITTER_MCP_STATELESS - bool[false] - ステートレス HTTP トランスポート。
--statelessと同じです - FITTER_MCP_METRICS_ADDR - string[""] - Prometheus メトリクスのリッスンアドレス。
--metrics-addrと同じです
レシピ
主なパターンを示す、完全でテスト済みの設定です。すべての設定は Fitter_MCP(fitter_run_file)、[Fitter_CLI](#how-to-use-fitter_cli)、またはライブラリから変更せずに実行できます。詳しくはexamples/をご覧ください。
API がないページをスクレイピングし、API があるページから情報を補完する
GitHub Trending には公式 API がありません。HTML をスクレイピングしてリポジトリのスラッグを取得し(html_attribute で href を読み取ります)、その後 {PL} を使ってそれぞれを GitHub REST API に展開します:
examples/config_github_trending.json
{
"item": {
"connector_config": {
"response_type": "HTML",
"url": "https://github.com/trending",
"server_config": { "method": "GET", "headers": { "User-Agent": "Mozilla/5.0 (fitter demo)" } }
},
"model": {
"array_config": {
"root_path": "article.Box-row h2 a",
"length_limit": 5,
"item_config": {
"field": {
"type": "string",
"html_attribute": "href",
"generated": { "model": {
"type": "object",
"connector_config": {
"response_type": "json",
"url": "https://api.github.com/repos{PL}",
"server_config": { "method": "GET", "headers": { "User-Agent": "fitter-demo" } },
"null_on_error": true
},
"model": { "object_config": { "fields": {
"repo": { "base_field": { "type": "string", "path": "full_name" } },
"stars": { "base_field": { "type": "int", "path": "stargazers_count" } },
"language": { "base_field": { "type": "string", "path": "language" } }
} } }
} }
}
}
}
}
},
"limits": { "host_request_limiter": { "api.github.com": 2 } }
}
[{"repo": "block/buzz", "stars": 6214, "language": "Rust"}, {"repo": "koala73/worldmonitor", "stars": 71179, "language": "TypeScript"}]
式を使って JSON フィールドで結合する
配列の項目がオブジェクトの場合、結合キーはその中にあります。{{{FromExp=...}}} を使って取り出してください(現在の項目である fRes に対する expr-lang)。書籍の検索から著者の詳細を取得し、検索クエリは input で指定します:
examples/config_book_authors.json
"url": "https://openlibrary.org/authors/{{{FromExp=fromJSON(fRes).author_key[0]}}}.json"
./fitter_cli --path=examples/config_book_authors.json --input=dune
[{"title": "Dune", "year": 1965, "author": {"name": "Frank Herbert", "born": "8 October 1920", "died": "11 February 1986"}}]
結果をローカルファイルに書き込む
file_storage 生成フィールドは、フィールドをファイルへの書き込みに変換します。たとえば、暗号資産の上位 5 件を、項目ごとに 1 行ずつ CSV に追記します。単独の {{{json.path}}} プレースホルダーは現在の項目を読み取ります。{HUMAN_INDEX} は 1 から始まる順位を記録します(項目は並列処理されるため、追記される順序は処理完了順です。順位列で並べ替えてください)。
examples/config_crypto_csv.json
"file_storage": {
"content": "{HUMAN_INDEX},{{{name}}},{{{current_price}}},{{{price_change_percentage_24h}}}\n",
"file_name": "coins.csv",
"path": "/tmp/fitter-report",
"append": true
}
$ sort -n /tmp/fitter-report/coins.csv
1,Bitcoin,64778,-2.3
2,Ethereum,1881.01,-3.4
3,Tether,0.999265,0
PDF からテキストを抽出する
response_type: "pdf" を指定すると、取得した PDF が JSON ドキュメント({"text": "...", "pages": ["..."], "total_pages": N})に変換されるため、通常の JSON パス(text、pages.0)や式を使用できます。Bitcoin ホワイトペーパーから、ページ数と冒頭部分をトリミングした内容を取得します。
{
"item": {
"connector_config": {
"response_type": "pdf",
"url": "https://bitcoin.org/bitcoin.pdf",
"server_config": { "method": "GET" }
},
"model": {
"object_config": {
"fields": {
"total_pages": { "base_field": { "type": "int", "path": "total_pages" } },
"intro": {
"base_field": {
"type": "string",
"path": "pages.0",
"generated": {
"calculated": {
"type": "string",
"expression": "trim(fRes[:100]) + \"...\""
}
}
}
}
}
}
}
}
}
{"intro": "Bitcoin: A Peer-to-Peer Electronic Cash SystemSatoshi [email protected]...", "total_pages": 9}
情報を収集する方法
- Server - API や HTTP リクエスト(http.Client を使用)からレスポンスを解析します
- Browser - chromium + docker + playwright/cypress を使用して実際のブラウザーをエミュレートし、DOM 情報を取得します
- Static - 静的な文字列をデータとして解析します
解析できる形式
- JSON - JSON を解析して特定の情報を取得します
- XML - XML ツリーを解析して特定の情報を取得します
- HTML - DOM ツリーを解析して特定の情報を取得します
- XPath - XPath を使用して DOM ツリーを解析し、特定の情報を取得します
- PDF - PDF ドキュメントからテキストを抽出します。内容は JSON
{"text": "...", "pages": ["..."], "total_pages": N}として公開されるため、textやpages.0などの通常の JSON パスを使用できます
ライブラリとして使用する
go get github.com/PxyUp/fitter
package main
import (
"fmt"
"github.com/PxyUp/fitter/lib"
"github.com/PxyUp/fitter/pkg/config"
"log"
"net/http"
)
func main() {
res, err := lib.Parse(&config.Item{
ConnectorConfig: &config.ConnectorConfig{
ResponseType: config.Json,
Url: "https://random-data-api.com/api/appliance/random_appliance",
ServerConfig: &config.ServerConnectorConfig{
Method: http.MethodGet,
},
},
Model: &config.Model{
ObjectConfig: &config.ObjectConfig{
Fields: map[string]*config.Field{
"my_id": {
BaseField: &config.BaseField{
Type: config.Int,
Path: "id",
},
},
"generated_id": {
BaseField: &config.BaseField{
Generated: &config.GeneratedFieldConfig{
UUID: &config.UUIDGeneratedFieldConfig{},
},
},
},
"generated_array": {
ArrayConfig: &config.ArrayConfig{
RootPath: "@this|@keys",
ItemConfig: &config.ObjectConfig{
Field: &config.BaseField{
Type: config.String,
},
},
},
},
},
},
},
}, nil, nil, nil, nil)
if err != nil {
log.Fatal(err)
}
fmt.Println(res.ToJson())
}
出力:
{
"generated_array": ["id","uid","brand","equipment"],
"my_id": 6000,
"generated_id": "26b08b73-2f2e-444d-bcf2-dac77ac3130e"
}
lib.ParseCtx(ctx, ...) を使用すると、context.Context を渡せます。キャンセルすると、実行中のフェッチ(HTTP リクエスト、ヘッドレスブラウザー、docker コンテナー)が中止され、処理全体に期限が適用されます。lib.Parse は lib.ParseCtx(context.Background(), ...) と同等です。
Fitter の使用方法
またはローカルで使用:
go run cmd/fitter/main.go --path=./examples/config_api.json
引数
- --path - string[""] - Fitter の設定ファイルへのパス
- --url - string[""] - Fitter の設定ファイルの URL
- --verbose - bool[false] - ログ出力を有効にします
- --plugins - string[""] - Fitter のプラグインへのパス
- --log-level - enum["info", "error", "debug", "fatal"] - ログレベルを設定します(verbose が true の場合のみ)
Fitter_CLI の使用方法
またはローカルで使用:
go run cmd/cli/main.go --path=./examples/cli/config_cli.json
引数
- --path - string[""] - Fitter_CLI の設定ファイルへのパス
- --url - string[""] - Fitter_CLI の設定ファイルの URL
- --copy - bool[false] - 情報をクリップボードにコピーします
- --pretty - bool[true] - 結果を読みやすく整形します(コピーにも適用されます)
- --verbose - bool[false] - ログ出力を有効にします
- --omit-error-pretty - bool[false] - pretty が無効な場合に値をそのまま出力します
- --plugins - string[""] - Fitter のプラグインへのパス
- --log-level - enum["info", "error", "debug", "fatal"] - ログレベルを設定します(verbose が true の場合のみ)
- --input - string[""] - 書式設定に使用する入力値を指定します。例:
--input=\""124"\"--input=124--input='{"test": 5}'
./fitter_cli_${VERSION} --path=./examples/cli/config_cli.json --copy=true
fitter_cli auth — OAuth2 アカウントに接続する
OAuth2 コネクター設定用の(リフレッシュ)トークンを保存する、一度限りの対話型ログインです。
# device flow (default when the provider supports it): no callback, works headless
./fitter_cli_${VERSION} auth --provider github --client-id <ID> --client-secret <SECRET> --token-file ~/.fitter/tokens/github.json
# custom provider without preset
./fitter_cli_${VERSION} auth --auth-url https://.../authorize --token-url https://.../token --client-id <ID> --token-file ./token.json
引数:
- --provider - 既知のエンドポイントが設定されたプリセット:
github|google|microsoft|gitlab|spotify - --client-id / --client-secret - OAuth2 アプリの認証情報(一部のデバイスフローではシークレットなしで動作します)
- --token-file - 受け取ったトークンの保存先(権限は0600);
oauth2.token_fileで同じパスを指定してください - --flow -
auto(利用可能ならデバイス、そうでなければブラウザー)、device(URLにアクセスしてコードを入力)、またはbrowser(PKCEを使用したlocalhostコールバック。デフォルトのポートは8988です。アプリのコールバックURLとしてhttp://127.0.0.1:8988/callbackを登録してください) - --scopes - スコープをカンマ区切りで指定します
- --auth-url/--token-url/--device-auth-url/--auth-style - プリセットのないプロバイダー用のエンドポイント上書き設定
- --port - int[8988] - ブラウザーフローのコールバックポート(環境変数
FITTER_AUTH_PORT);デフォルトの場合、プロバイダーに登録するコールバックURLはhttp://127.0.0.1:8988/callbackです - --listen - ブラウザーフローのバインドアドレス。デフォルトは
127.0.0.1です。コンテナー内では、公開ポートからリスナーに接続できるよう0.0.0.0を設定してください(環境変数FITTER_AUTH_LISTEN) - --redirect-url - リッスンアドレスと異なる場合にプロバイダーに登録するコールバックURL。例:Dockerのポートマッピング(環境変数
FITTER_AUTH_REDIRECT_URL) - --no-browser - 認証URLのみを表示します
Docker内での実行については、DockerでのOAuth2アカウントを参照してください。
ログイン後、すぐに使用できるoauth2設定ブロックがコマンドから出力されます。コネクターはアクセストークンを自動的に更新し、ローテーションされたリフレッシュトークンをトークンファイルに書き戻すため、ログインが必要なのは一度だけです。
fitter_cli browser-login — 実際のログインセッションを再利用する
API/OAuth のないサイトの場合:実際のブラウザーウィンドウ(画面表示あり)で一度手動ログインします。パスワード、2FA、SSO、CAPTCHA など、どの認証方式でも使用できます。その後、セッションを保存して、ヘッドレススクレイピングで storage_state_file を使います。
./fitter_cli_${VERSION} browser-login --url https://example.com/login --storage-state ~/.fitter/sessions/example.json
# a browser window opens; log in, then press Enter in the terminal to save the session
引数:
- --url - 開くログインページ(必須)
- --storage-state - セッション(Cookie + localStorage、権限 0600)の保存先。
playwright.storage_state_fileで同じパスを指定してください(必須) - --browser - 列挙型["Chromium", "FireFox", "WebKit"]、デフォルトは "Chromium"。スクレイピング設定と同じ値を使用してください。サイトによってはセッションをブラウザーフィンガープリントに紐付ける場合があります
- --install - bool[false] - 最初に Playwright ブラウザーをインストールします
- --indexeddb - bool[false] - スナップショットに IndexedDB を含めます(Firebase Auth など)
コマンドを再実行すると、まず既存の状態が読み込まれるため、最初からログインし直さずにセッションを拡張/更新できます。スクレイピングコネクターも実行ごとに更新された Cookie を書き戻すため、定期的に使用する限りセッションを維持できます。ディスプレイが必要です。Docker 内で実行する場合は、このコマンドをホスト上で実行し、ファイルをマウントしてください。Docker でのブラウザーセッションを参照してください。
例:
- サーバーバージョン HackerNews + Quotes + Guardian News - API + HTML + XPath パーサーを使用
- Chromium バージョン Guardian News + Quotes - HTML パーサー + ブラウザーエミュレーションを使用
- Docker バージョン Docker バージョン:Guardian News + Quotes - HTML パーサー + Docker イメージのブラウザーを使用
- Playwright バージョン Playwright バージョン:Guardian News + Quotes - HTML パーサー + Playwright フレームワークのブラウザーを使用
- Playwright バージョン Playwright バージョン:England Cities + Weather - HTML + XPath パーサー + Playwright フレームワークのブラウザーを使用
- JSON バージョン ページネーションを生成 - 静的コネクターを使用してページネーション配列を生成
- サーバーバージョン 現在時刻を取得 - URL から時刻を取得してフォーマット
Fitter_Agent の使い方
Fitter Agent は、Claude を使用して自然言語のリクエストを Fitter の設定に変換し、自動的に実行する AI 搭載の CLI です。
またはローカルで:
export ANTHROPIC_API_KEY=<your-anthropic-api-key>
go run cmd/agent/main.go
引数
- --api-key - string[""] - Anthropic API キー。キーがシェルの履歴に残らないよう、
ANTHROPIC_API_KEY環境変数を使用することをおすすめします - --model - string["claude-opus-4-8"] - 使用する Claude モデル
- --effort - 列挙型["low", "medium", "high", "xhigh", "max"] - 推論の労力。デフォルトは "high" です。設定をより速く/安価に生成するには下げ、難しい抽出には上げてください
- --verbose - bool[false] - ログを有効にします
- --log-level - 列挙型["info", "error", "debug", "fatal"] - ログレベルを設定します
- --plugins - string[""] - Fitter のプラグインのパス
- --chromium-limit - uint[0] - 同時に実行する Chromium インスタンス数の上限
- --docker-limit - uint[0] - 同時に実行する Docker コンテナー数の上限
- --playwright-limit - uint[0] - 同時に実行する Playwright インスタンス数の上限
動作の仕組み
┌─────────────────────────────────────────────────────────────────┐
│ 1. User enters natural language request │
│ "Get top 5 HackerNews stories with titles and scores" │
│ ↓ │
│ 2. Claude returns a config in a schema-constrained response │
│ ↓ │
│ 3. Agent validates it; on failure the error is handed back │
│ to Claude to repair (up to 3 attempts) │
│ ↓ │
│ 4. Agent displays config and asks for confirmation │
│ ↓ │
│ 5. On confirmation, executes via lib.Parse() │
│ ↓ │
│ 6. Returns structured JSON result │
└─────────────────────────────────────────────────────────────────┘
設定の調整
エージェントは会話を保持するため、設定が生成された後はリクエスト全体を言い直さずに、変更内容だけを伝えられます。
> Get top 3 HackerNews stories with titles and scores
refine> Only return 5 items and also include the article URL
new を使うと、現在の設定を忘れて新しいセッションを開始します。
対話型 REPL コマンド
- help - ヘルプメッセージを表示します
- new/reset - 現在の設定を破棄して、新しく開始します
- clear - 画面をクリアします
- exit/quit/q - エージェントを終了します
セッション例
$ export ANTHROPIC_API_KEY=sk-ant-...
$ ./fitter_agent
╔══════════════════════════════════════════════════════════════╗
║ Fitter Agent - AI-Powered Data Extraction ║
╚══════════════════════════════════════════════════════════════╝
Describe what you want to extract. Follow-up messages refine the
previous config. Type 'help' for commands.
> Get top 3 HackerNews stories with titles and scores
┌─ Generated Fitter Config ───────────────────────────────────────
{
"item": {
"connector_config": {
"response_type": "json",
"url": "https://hacker-news.firebaseio.com/v0/topstories.json",
"server_config": { "method": "GET" }
},
"model": {
"array_config": {
"root_path": "@this",
"length_limit": 3,
"item_config": {
"fields": {
"id": { "base_field": { "type": "int" } },
"story": {
"base_field": {
"type": "int",
"generated": {
"model": {
"type": "object",
"connector_config": {
"response_type": "json",
"url": "https://hacker-news.firebaseio.com/v0/item/{PL}.json",
"server_config": { "method": "GET" }
},
"model": {
"object_config": {
"fields": {
"title": { "base_field": { "type": "string", "path": "title" } },
"score": { "base_field": { "type": "int", "path": "score" } }
}
}
}
}
}
}
}
}
}
}
}
}
}
└──────────────────────────────────────────────────────────────────
Execute this config? [y/n]: y
┌─ Result ────────────────────────────────────────────────────────
[
{
"id": 46740029,
"story": { "title": "Show HN: Open-source project", "score": 161 }
},
{
"id": 46737630,
"story": { "title": "Interesting article", "score": 237 }
},
{
"id": 46735644,
"story": { "title": "New technology release", "score": 192 }
}
]
└──────────────────────────────────────────────────────────────────
> exit
Goodbye!
リクエスト例
| リクエスト | 動作 |
|---|---|
Get Bitcoin price from CoinGecko API | 現在の BTC 価格を取得します |
Scrape headlines from news.ycombinator.com with links | CSS セレクターを使って HTML をスクレイピングします |
Get top 5 stories from HackerNews with titles | 入れ子になった API 呼び出しを行います |
Fetch weather data from wttr.in for London | シンプルな API 抽出を行います |
Scrape product names and prices from example.com | ウェブスクレイピングを行います |
サポートされる機能
エージェントは次の設定を生成できます。
- JSON API - GET/POST メソッドを使う REST API
- HTML スクレイピング - CSS セレクターベースの抽出
- XPath スクレイピング - XPath ベースの抽出
- 入れ子になった API 呼び出し - リスト内の各項目の詳細を取得します
- ブラウザーエミュレーション - JavaScript でレンダリングされたページ向けの Playwright
- フォーマット済みフィールド - プレースホルダーを含む URL テンプレート
- 配列の制限 - 結果を N 件に制限します
設定
コネクター
データの取得方法を定義します
type ConnectorConfig struct {
ResponseType ParserType `json:"response_type" yaml:"response_type"`
Url string `json:"url" yaml:"url"`
Attempts uint32 `json:"attempts" yaml:"attempts"`
NullOnError bool `yaml:"null_on_error" json:"null_on_error"`
StaticConfig *StaticConnectorConfig `json:"static_config" yaml:"static_config"`
IntSequenceConfig *IntSequenceConnectorConfig `json:"int_sequence_config" yaml:"int_sequence_config"`
ServerConfig *ServerConnectorConfig `json:"server_config" yaml:"server_config"`
BrowserConfig *BrowserConnectorConfig `yaml:"browser_config" json:"browser_config"`
PluginConnectorConfig *PluginConnectorConfig `json:"plugin_connector_config" yaml:"plugin_connector_config"`
ReferenceConfig *ReferenceConnectorConfig `yaml:"reference_config" json:"reference_config"`
FileConfig *FileConnectorConfig `json:"file_config" yaml:"file_config"`
}
- NullOnError[false] - true に設定すると、すべてのエラーが無視されます
- ResponseType - enum["HTML", "json", "xpath", "XML", "pdf"] - コネクターから返されるデータの形式
- Attempts - コネクターによるデータ取得の試行回数
- Url - リクエスト先のアドレスを定義します。重要:親の値を文字列として挿入できます
https://api.open-meteo.com/v1/forecast?latitude={{{latitude}}}&longitude={{{longitude}}}&hourly=temperature_2m&forecast_days=1
設定には次のいずれかを指定できます。
- ServerConfig
- BrowserConfig
- StaticConfig
- PluginConnectorConfig
- ReferenceConfig
- IntSequenceConfig
- FileConfig
例:
{
"response_type": "xpath",
"attempts": 3,
"url": "https://openweathermap.org/find?q={PL}",
"browser_config": {
"playwright": {
"timeout": 30,
"wait": 30,
"install": false,
"browser": "Chromium"
}
}
}
PluginConnectorConfig
プラグインシステムを使ってコネクターを定義できます。使用するには、Fitter/Cli に次のフラグ(プラグインの場所)を指定する必要があります。
... --plugins=./examples/plugin
--plugins - 指定されたフォルダー内で拡張子が ".so" のファイルをすべて検索します(サブディレクトリは対象外です)
type PluginConnectorConfig struct {
Name string `json:"name" yaml:"name"`
Config json.RawMessage `json:"config" yaml:"config"`
}
{
"name": "connector",
"config": {
"name": "Elon"
}
}
- Name - プラグイン名
- Config - プラグインの JSON 設定
プラグインのビルド方法
プラグインをビルドします
go build -buildmode=plugin -gcflags="all=-N -l" -o examples/plugin/connector.so examples/plugin/connector/connector.go
pl.ConnectorPlugin インターフェースを実装する Plugin 変数をエクスポートしてください
CLI の例:
https://github.com/PxyUp/fitter/blob/master/examples/cli/config_plugin.json#L5
プラグインの例:
package main
import (
"context"
"encoding/json"
"fmt"
"github.com/PxyUp/fitter/pkg/config"
"github.com/PxyUp/fitter/pkg/logger"
"github.com/PxyUp/fitter/pkg/builder"
pl "github.com/PxyUp/fitter/pkg/plugins/plugin"
)
var (
_ pl.ConnectorPlugin = &plugin{}
Plugin plugin
)
type plugin struct {
log logger.Logger
Name string `json:"name" yaml:"name"`
}
func (pl *plugin) Get(ctx context.Context, parsedValue builder.Interfacable, index *uint32, input builder.Interfacable) ([]byte, error) {
return []byte(fmt.Sprintf(`{"name": "%s"}`, pl.Name)), nil
}
func (pl *plugin) SetConfig(cfg *config.PluginConnectorConfig, logger logger.Logger) {
pl.log = logger
if cfg.Config != nil {
err := json.Unmarshal(cfg.Config, pl)
if err != nil {
pl.log.Errorw("cant unmarshal plugin configuration", "error", err.Error())
return
}
}
}
ReferenceConnectorConfig
references から事前取得済みのデータを取得できるコネクターです
type ReferenceConnectorConfig struct {
Name string `yaml:"name" json:"name"`
}
例
https://github.com/PxyUp/fitter/blob/master/examples/cli/config_ref.json#L66
- Name - references マップ内の参照名
IntSequenceConnectorConfig
結果として整数のシーケンスを生成する、改良版の静的コネクターです
type IntSequenceConnectorConfig struct {
Start int `json:"start" yaml:"start"`
End int `json:"end" yaml:"end"`
Step int `json:"step" yaml:"step"`
}
- Start[0] - 生成の開始位置(含みます)
- End[0] - 生成の終了位置(最終結果には含まれません。どの言語の range と同様です)
- Step[1] - シーケンスの間隔
例
{
"start": 0,
"end": 2
// Generate [0, 1]
}
FileConnectorConfig
指定したファイルからデータを取得するコネクタータイプです
type FileConnectorConfig struct {
Path string `yaml:"path" json:"path"`
UseFormatting bool `yaml:"use_formatting" json:"use_formatting"`
}
StaticConnectorConfig
指定した文字列からデータを取得するコネクタータイプです
type StaticConnectorConfig struct {
Value string `json:"value" yaml:"value"`
Raw json.RawMessage `json:"raw" yaml:"raw"`
}
例:
https://github.com/PxyUp/fitter/blob/master/examples/cli/config_static_connector.json#L5
{
"value": "[1,2,3,4,5]"
}
ServerConnectorConfig
golang http.Client を使用してデータを取得するコネクタータイプです(curl のようなサーバー側リクエスト)。
type ServerConnectorConfig struct {
Method string `json:"method" yaml:"method"`
Headers map[string]string `yaml:"headers" json:"headers"`
Timeout uint32 `yaml:"timeout" json:"timeout"`
JsonRawBody json.RawMessage `json:"json_raw_body" yaml:"json_raw_body"`
Body string `yaml:"body" json:"body"`
ErrorOnStatus bool `json:"error_on_status" yaml:"error_on_status"`
Proxy *ProxyConfig `yaml:"proxy" json:"proxy"`
OAuth2 *OAuth2Config `yaml:"oauth2" json:"oauth2"`
}
- Method - GET、POST、PUT、DELETE、PATCH、OPTIONS、HEAD のすべての HTTP メソッドに対応しています
- Headers - リクエスト時に使用するヘッダーを事前に定義します。キー/値に挿入できます
- Timeout[sec] - デフォルトのタイムアウトは 60 秒です。指定した値を使用することもできます
- Body - リクエストの本文です。解析された値を挿入できます
- JsonRawBody - JSON 形式のリクエスト本文です。値を挿入できます
- ErrorOnStatus - 省略可能で、デフォルトは
falseです。trueの場合、HTTP レスポンスステータスが>= 400のとき、エラーボディを解析する代わりに取得エラーとして処理されます(attempts/null_on_errorを経由します)。これにより、取得の失敗と、結果が実際に空である場合を区別できます。falseのままにすると、返されたボディを解析する従来の動作になります。 - Proxy - リクエスト用のプロキシを設定します。設定
- OAuth2 - アクセストークンを自動的に取得/更新し、
Authorizationヘッダーとして送信します。設定
リクエストには、デフォルトで識別可能な
User-Agent(fitter (+https://github.com/PxyUp/fitter))が送信されます。独自のUser-Agentを指定するには、Headersに設定して上書きしてください。
例:
{
"method": "GET",
"proxy": {
"server": "http://localhost:8080",
"username": "pyx"
}
}
OAuth2 config
リクエストの前にアクセストークンを自動取得し、Authorization ヘッダーとして挿入します(headers で設定された値を上書きします)。トークンはメモリにキャッシュされ、有効期限の前に更新されます。401 レスポンスを受け取ると、キャッシュされたトークンを破棄し、新しいトークンを使用してリクエストを 1 回再試行します。
type OAuth2Config struct {
TokenUrl string `json:"token_url" yaml:"token_url"`
GrantType OAuth2GrantType `json:"grant_type" yaml:"grant_type"`
ClientId string `json:"client_id" yaml:"client_id"`
ClientSecret string `json:"client_secret" yaml:"client_secret"`
Scopes []string `json:"scopes" yaml:"scopes"`
RefreshToken string `json:"refresh_token" yaml:"refresh_token"`
EndpointParams map[string]string `json:"endpoint_params" yaml:"endpoint_params"`
AuthStyle string `json:"auth_style" yaml:"auth_style"`
TokenFile string `json:"token_file" yaml:"token_file"`
}
- TokenUrl - トークンエンドポイントの URL。書式設定にも対応しています
- GrantType - enum["client_credentials", "refresh_token"]。デフォルトは "client_credentials" です。ユーザーが一度同意し、長期間有効なリフレッシュトークンを保持する API(Google、Microsoft など)では、"refresh_token" を使用してください
- ClientId/ClientSecret - クライアント認証情報。書式設定にも対応しています。例:
{{{FromEnv=CLIENT_SECRET}}} - Scopes - 要求するスコープ
- RefreshToken - "refresh_token" グラントで必須です。書式設定にも対応しています
- EndpointParams - トークンエンドポイントに渡す追加パラメーター(Auth0 の
audienceなど)。"client_credentials" グラントのみ - AuthStyle - enum["", "header", "params"]。トークンエンドポイントにクライアント認証情報を渡す方法です。Basic 認証ヘッダーまたはリクエストボディを指定します。空の場合は自動検出します
- TokenFile - 実行間でトークンを保持するための省略可能なパス(
~/に対応)。保存されたトークンは RefreshToken より優先され、ローテーションされたリフレッシュトークンはファイルに書き戻されます。GitHub Apps など、使い捨てのリフレッシュトークンを使用するプロバイダーでは必須です。fitter_cli auth を使用して作成してください
例:
{
"method": "GET",
"oauth2": {
"token_url": "https://oauth2.googleapis.com/token",
"grant_type": "refresh_token",
"client_id": "{{{FromEnv=GOOGLE_CLIENT_ID}}}",
"client_secret": "{{{FromEnv=GOOGLE_CLIENT_SECRET}}}",
"refresh_token": "{{{FromEnv=GOOGLE_REFRESH_TOKEN}}}"
}
}
Proxy config
type ProxyConfig struct {
// Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for example
// `http://myproxy.com:3128` or `socks5://myproxy.com:3128`. Short form `myproxy.com:3128`
// is considered an HTTP proxy.
Server string `json:"server" yaml:"server"`
// Optional username to use if HTTP proxy requires authentication.
Username string `json:"username" yaml:"username"`
// Optional password to use if HTTP proxy requires authentication.
Password string `json:"password" yaml:"password"`
}
- Server - プロキシサーバーのスキーム付きアドレス。書式設定にも対応しています
- Username - プロキシのユーザー名(空欄可)。書式設定にも対応しています
- Password - プロキシのパスワード(空欄可)。書式設定にも対応しています
{
"server": "http://localhost:8080",
"username": "pyx"
}
Environment variables
- FITTER_HTTP_WORKER - int[1000] - HTTP ワーカーのデフォルト同時実行数
BrowserConnectorConfig
ブラウザー経由でデータを取得する動作をエミュレートするコネクタータイプです。
type BrowserConnectorConfig struct {
Chromium *ChromiumConfig `json:"chromium" yaml:"chromium"`
Docker *DockerConfig `json:"docker" yaml:"docker"`
Playwright *PlaywrightConfig `json:"playwright" yaml:"playwright"`
}
設定には次のいずれかを指定できます。
- Chromium - ローカルにインストールされた Chromium を使用してデータを取得します
- Docker - データを取得するコンテナーを起動するサービスとして Docker を使用します
- Playwright - データを取得するために Playwright フレームワークを使用します
例:
{
"docker": {
"wait": 10000,
"image": "docker.io/zenika/alpine-chrome:with-node",
"entry_point": "chromium-browser",
"purge": true
}
}
Chromium
ローカルにインストールされた Chromium を使用してデータを取得します。
type ChromiumConfig struct {
Path string `yaml:"path" json:"path"`
Timeout uint32 `yaml:"timeout" json:"timeout"`
Wait uint32 `yaml:"wait" json:"wait"`
Flags []string `yaml:"flags" json:"flags"`
}
- Path - Chromium バイナリへのパス
- Timeout[sec] - Chromium の実行タイムアウト
- Wait[msec] - ページ読み込みのタイムアウト
- Flags - Chromium のフラグ。デフォルト:"--headless"、"--proxy-auto-detect"、"--temp-profile"、"--incognito"、"--disable-logging"、"--disable-extensions"、"--no-sandbox"
例:
{
"path": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
"wait": 10000
}
Docker
データを取得するコンテナを起動するには、Docker を使用します。
type DockerConfig struct {
Image string `yaml:"image" json:"image"`
EntryPoint string `json:"entry_point" yaml:"entry_point"`
Timeout uint32 `yaml:"timeout" json:"timeout"`
Wait uint32 `yaml:"wait" json:"wait"`
Flags []string `yaml:"flags" json:"flags"`
Purge bool `json:"purge" yaml:"purge"`
NoPull bool `yaml:"no_pull" json:"no_pull"`
PullTimeout uint32 `yaml:"pull_timeout" json:"pull_timeout"`
}
Docker のデフォルトイメージ:docker.io/zenika/alpine-chrome
- Image - Docker レジストリのイメージ(レジストリホストを指定します)
- EntryPoint - コンテナ内で実行するコマンド
- Timeout[sec] - コンテナの実行タイムアウト(イメージのプル時間は含みません)
- Wait[msec] - ページの読み込みタイムアウト(Chromium ベースのコンテナでのみ有効です)
- Flags - コンテナの実行コマンドの引数。Chromium ベースの場合のデフォルトは「"--no-sandbox","--headless", "--proxy-auto-detect", "--temp-profile", "--incognito", "--disable-logging", "--disable-gpu"」です
- Purge - 作業完了後にコンテナを削除するかどうか(docker rm のように動作します)
- NoPull - イメージのプルを防止します
- PullTimeout - イメージのプルのタイムアウトを指定します
環境変数
- DOCKER_HOST - string - (EnvOverrideHost) Docker サーバーの URL を設定します。
- DOCKER_API_VERSION - string - (EnvOverrideAPIVersion) 使用する API のバージョンを設定します。最新バージョンを使う場合は空欄にします。
- DOCKER_CERT_PATH - string - (EnvOverrideCertPath) TLS 証明書(ca.pem、cert.pem、key.pem)を読み込むディレクトリを指定します。
- DOCKER_TLS_VERIFY - bool - (EnvTLSVerify) TLS 検証を有効または無効にします(デフォルトでは無効です)
例:
{
"wait": 10000,
"image": "docker.io/zenika/alpine-chrome:with-node",
"entry_point": "chromium-browser",
"purge": true
}
Playwright
Playwright フレームワークを介してブラウザーを実行します。
type PlaywrightConfig struct {
Browser PlaywrightBrowser `json:"browser" yaml:"browser"`
Install bool `yaml:"install" json:"install"`
Timeout uint32 `yaml:"timeout" json:"timeout"`
Wait uint32 `yaml:"wait" json:"wait"`
TypeOfWait *playwright.WaitUntilState `json:"type_of_wait" yaml:"type_of_wait"`
PreRunScript string `json:"pre_run_script" yaml:"pre_run_script"`
PostRunScript string `json:"post_run_script" yaml:"post_run_script"`
Stealth bool `json:"stealth" yaml:"stealth"`
StorageStateFile string `json:"storage_state_file" yaml:"storage_state_file"`
IndexedDB bool `json:"indexed_db" yaml:"indexed_db"`
Proxy *ProxyConfig `yaml:"proxy" json:"proxy"`
}
- Browser - enum["Chromium", "FireFox", "WebKit"] - 使用するブラウザー
- Install - ブラウザーをインストールするかどうか(初回使用時に、組み込みの
playwright-goバージョンに対応するドライバーとブラウザーをダウンロードします。これらがプリインストールされているghcr.io/pxyup/fitter-mcp:playwrightイメージを使う場合は不要です) - Timeout[sec] - Playwright の実行タイムアウト
- Wait[sec] - ページの読み込みタイムアウト
- TypeOfWait - enum["load", "domcontentloaded", "networkidle", "commit"] - 待機するページの状態。デフォルトは「load」です
- PreRunScript[""] - AddInitScript を介して挿入され、ページのスクリプトが実行される前(ドキュメントの作成時、ナビゲーションの完了前)に実行されるスクリプトです。環境のパッチ適用(navigator のオーバーライド、API スタブ)に便利です。読み込まれた DOM にはアクセスできません。プレースホルダー {PL} もサポートしています
- PostRunScript[""] - ページの読み込み後、ページのコンテンツを読み取る前に実行されるスクリプトです。DOM 操作(クリック、スクロール)に便利です。プレースホルダー {PL} もサポートしています
- Stealth[false] - ボット対策を回避するためのスクリプトを追加します
- StorageStateFile[""] - Playwright のストレージ状態 JSON(Cookie と localStorage)へのパス(
~/に対応)です。ナビゲーション前にブラウザーコンテキストへ読み込まれ、各実行後に書き戻されるため、更新されたセッションが維持されます。ヘッドレス実行で実際のログイン状態を再利用できます。ファイルを一度作成するには、fitter_cli browser-login を使用します。ログインとスクレイピングには同じbrowserを使用してください。サイトによってはセッションをブラウザーのフィンガープリントに紐付けている場合があります。書式 もサポートしています - IndexedDB[false] - 永続化するストレージ状態に IndexedDB を含めます(一部の SPA(Firebase Auth など)では、トークンがそこに保存されます)
- Proxy - リクエスト用のプロキシを設定します。設定
例:
{
"timeout": 30,
"wait": 30,
"install": false,
"browser": "Chromium"
}
モデル
モデルでは、スクレイピング結果を定義します。
type Model struct {
ObjectConfig *ObjectConfig `yaml:"object_config" json:"object_config"`
ArrayConfig *ArrayConfig `json:"array_config" yaml:"array_config"`
BaseField *BaseField `json:"base_field" yaml:"base_field"`
IsArray bool `json:"is_array" yaml:"is_array"`
}
設定には次のいずれかを指定できます。
- ObjectConfig - オブジェクト形式の設定
- ArrayConfig - 配列形式の設定
- BaseField - 単一フィールド/生成フィールドの設定
- IsArray - bool[false] - フィールドが配列であることを強制的に指定します(基本フィールドを持つモデルフィールドで使用できます)
例:
{
"object_config": {}
}
ObjectConfig
オブジェクトとフィールドの設定
type ObjectConfig struct {
Fields map[string]*Field `json:"fields" yaml:"fields"`
Field *BaseField `json:"field" yaml:"field"`
ArrayConfig *ArrayConfig `json:"array_config" yaml:"array_config"`
Condition string `json:"condition" yaml:"condition"`
}
- Condition - 任意の条件式です。解決前にソースノードに対して評価され、false の場合はオブジェクト全体が親から省略されます(フィールドは一切解決されません)。
設定には以下のいずれかを指定できます。
- Fields - 各フィールド定義のマップです。キーはフィールド名、値は設定です。
- Field - 配列の要素に使用します。「string」、「int」などの基本型としてデシリアライズされるフィールドです(基本型の配列の場合に使用します)。
- ArrayConfig - 配列の要素に使用します。配列の配列をデシリアライズします。
例:
{
"fields": {
"title": {
"base_field": {
"type": "string",
"path": "type"
}
}
}
}
ArrayConfig
配列とフィールドの設定
type ArrayConfig struct {
RootPath string `json:"root_path" yaml:"root_path"`
Reverse bool `yaml:"reverse" json:"reverse"`
ItemConfig *ObjectConfig `json:"item_config" yaml:"item_config"`
LengthLimit uint32 `json:"length_limit" yaml:"length_limit"`
Condition string `json:"condition" yaml:"condition"`
ItemCondition string `json:"item_condition" yaml:"item_condition"`
StaticConfig *StaticArrayConfig `json:"static_array" yaml:"static_array"`
}
- RootPath - 配列のルート要素、または HTML の解析時に繰り返される要素を見つけるためのセレクターです。配列のサイズは、ルートの子要素の数になります。
- Reverse - bool[false] - 逆順(n から 1)で反復するかどうかを示します。
- LengthLimit - 配列の固定サイズです(生成配列のみ。静的配列には適用されません)。注:ソースの要素数が上限より少ない場合、宣言されたサイズを維持するため、配列の末尾に
nullが追加されます(これは意図した動作です)。ソースと同じ長さにするには、length_limitを省略してください。 - Condition - 任意の条件式です。解決前にソースノードに対して評価され、false の場合は配列全体が親から省略されます。
- ItemCondition - 任意の条件式です。構築された各項目に対して評価されます(fRes - 項目の値、fSrc - ソース要素、fIndex - 項目のインデックス)。false となる項目は配列から除外されます。宣言的なフィルタリングに使用します。static_array には適用されません。
設定には以下のいずれかを指定できます。
- ItemConfig - 配列の各要素の設定です。
- StaticConfig - 静的配列の設定です。
例:
{
"root_path": "#content dt.quote > a",
"item_config": {
"field": {
"type": "string"
}
}
}
Field
フィールド共通の設定
type Field struct {
BaseField *BaseField `json:"base_field" yaml:"base_field"`
ObjectConfig *ObjectConfig `json:"object_config" yaml:"object_config"`
ArrayConfig *ArrayConfig `json:"array_config" yaml:"array_config"`
FirstOf []*Field `json:"first_of" yaml:"first_of"`
}
設定には以下のいずれかを指定できます。
- BaseField - 「string」、「int」などの基本型としてデシリアライズされるフィールドです。
- ObjectConfig - フィールドがネストされたオブジェクトの場合に使用します。
- ArrayConfig - フィールドが配列の場合に使用します。
- FirstOf - 最初に解決された空でないフィールドが選択されます。
例:
{
"base_field": {
"type": "string",
"path": "div.current-temp span.heading"
}
}
BaseField
静的な情報を取得する場合、または新たに生成する場合に使用します。
type BaseField struct {
Type FieldType `yaml:"type" json:"type"`
Path string `yaml:"path" json:"path"`
HTMLAttribute string `json:"html_attribute" yaml:"html_attribute"`
Condition string `json:"condition" yaml:"condition"`
Generated *GeneratedFieldConfig `yaml:"generated" json:"generated"`
FirstOf []*BaseField `json:"first_of" yaml:"first_of"`
}
- FieldType - enum["null", "boolean", "string", "int", "int64", "float", "float64", "array", "object", "html", "raw_string"] - 解析対象の静的フィールドです。重要:html 型は、HTML を返すコネクターでのみ動作します(この場合、HTMLAttribute は効果がありません)。例
- Path - 解析用のセレクターです(配列の子要素の場合は相対パス)。
- HTMLAttribute - goquery による HTML 解析時のみ有効な追加値です。解析する属性を指定できます。
- Condition - 任意の条件式です。抽出された値(fRes/fResJson/fResRaw、fIndex。fSrc はフィールドの解決元ノードで、兄弟ノードも含みます)に対して評価され、false の場合は null を生成する代わりに、フィールドが親オブジェクト/配列から省略されます。Generated より前に評価されるため、条件が false の場合は生成処理(サブリクエスト、ファイルのダウンロード)もスキップされます。
重要:デフォルトでは、「string」型はトリミングされ、すべての特殊文字が置換されます。プレーンな文字列が必要な場合は、「raw_string」を使用してください。
設定には以下のいずれか、または何も指定しないことができます。
例
{
"generated": {
"uuid": {}
}
}
{
"type": "string",
"path": "text()"
}
条件付きフィールド
すべてのフィールドには condition を指定できます。これは expr-lang の式です(定義済みの値)。評価結果が true 以外の場合、そのフィールドは出力から省略されます(キー/項目が消え、null には設定されません)。式が無効な場合もフィールドは省略され、エラーがログに記録されます。
条件の評価タイミング:
- BaseField.
condition- 抽出後に評価されます。fResは抽出された値、fSrcはフィールドの解決元となったノード(その兄弟ノードを含む)です。そのため、fSrc.on_sale == trueを使って、抽出していないデータを条件にフィールドを出力できます。条件が false の場合、生成処理は完全にスキップされます(サブリクエストもファイルのダウンロードも行われません)。 - ObjectConfig.
condition/ ArrayConfig.condition- 解決前に評価されます。fRes/fSrcはソースノードです(json の場合は解析された値、html の場合はテキストコンテンツ)。 - ArrayConfig.
item_condition- 構築された各項目に対して評価されます。fResは項目、fSrcは項目の構築元となったソース要素、fIndexはそのインデックスです。false の項目は除外されます。これは宣言的な配列フィルタリングです。出力に追加せずにソース属性でフィルタリングするには、fSrcを使用します。
配列項目をフィルタリングします。fSrc.in_stock は出力に抽出されていないソース要素を、fRes.price は構築された項目を参照します。
{
"array_config": {
"root_path": "products",
"item_condition": "fSrc.in_stock && fRes.price > 0",
"item_config": {
"fields": {
"title": { "base_field": { "type": "string", "path": "title" } },
"price": { "base_field": { "type": "float", "path": "price" } }
}
}
}
}
値が条件を満たさない場合にキーを省略します:
{
"discount": {
"base_field": {
"type": "float",
"path": "discount_pct",
"condition": "fRes > 0"
}
}
}
特別なケース:
- 静的配列では、省略された項目は
nullのままです(定義上、位置は固定されており、インデックスはずれません)。 - ルートモデル設定が省略された場合、解析結果は
nullになります。 - first_of 内で条件が false の分岐は空として扱われ、次の分岐が試されます。
実行可能な例:examples/config_conditions.json
GeneratedFieldConfig
実行時にフィールドを生成する機能を提供します
type GeneratedFieldConfig struct {
UUID *UUIDGeneratedFieldConfig `yaml:"uuid" json:"uuid"`
Static *StaticGeneratedFieldConfig `yaml:"static" json:"static"`
Formatted *FormattedFieldConfig `json:"formatted" yaml:"formatted"`
Plugin *PluginFieldConfig `yaml:"plugin" json:"plugin"`
Calculated *CalculatedConfig `yaml:"calculated" json:"calculated"`
File *FileFieldConfig `yaml:"file" json:"file"`
Model *ModelField `yaml:"model" json:"model"`
FileStorageField *FileStorageField `json:"file_storage" yaml:"file_storage"`
}
設定には次のいずれかを指定できます:
- UUID - ランダムな UUID V4 を生成します
- Static - 静的なフィールドを生成します
- Formatted - フィールドをフォーマットします
- Model - 別のコネクターとモデルから生成されたモデルです
- Plugin - プラグインフィールドです
- Calculated - 計算フィールドです
- File - ファイルフィールドです(サーバーからファイルをダウンロードします)
- FileStorage - ローカルファイルに保存できるファイルフィールドです
例:
{
"uuid": {}
}
https://github.com/PxyUp/fitter/blob/master/examples/cli/config_cli.json#L58
{
"model": {
"type": "array",
"model": {
"array_config": {
"root_path": "#content dt.quote > a",
"item_config": {
"field": {
"type": "string"
}
}
}
},
"connector_config": {
"response_type": "HTML",
"url": "http://www.quotationspage.com/random.php",
"attempts": 3,
"browser_config": {
"chromium": {
"path": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
"wait": 10000
}
}
}
}
}
UUID
実行時にランダムな UUID V4 を生成します。一意の ID の生成に使用できます
type UUIDGeneratedFieldConfig struct {
Regexp string `yaml:"regexp" json:"regexp"`
}
- Regexp - 生成された UUID の一部を取得するために使用できる照合パターンを指定します
Static
静的なフィールドを生成します
type StaticGeneratedFieldConfig struct {
Type FieldType `yaml:"type" json:"type"`
Value string `json:"value" yaml:"value"`
Raw json.RawMessage `json:"raw" yaml:"raw"`
}
- Type - enum["null", "boolean", "string", "int","int64","float","float64", "array", "object"] - フィールドの型
- Value - フィールドの文字列値
- Raw - フィールドの生の JSON 値
例
{
"type": "int",
"value": "65"
}
{
"type": "array",
"value": "[65,45]"
}
{
"type": "array",
"raw": [65,45]
}
Formatted Field Config
親の base field から値を受け取り、フォーマットされたフィールドを生成します
type FormattedFieldConfig struct {
Template string `yaml:"template" json:"template"`
}
例: https://github.com/PxyUp/fitter/blob/master/examples/cli/config_cli.json#L98
{
"template": "https://news.ycombinator.com/item?id={PL}"
}
ファイルストレージフィールド
フィールドの結果をローカルファイルに保存するために使用できます。
type FileStorageField struct {
Content string `json:"content" yaml:"content"`
Raw json.RawMessage `yaml:"raw" yaml:"raw"`
FileName string `json:"file_name" yaml:"file_name"`
Path string `json:"path" yaml:"path"`
Append bool `json:"append" yaml:"append"`
}
- Content - コンテンツのテンプレート文字列です。重要:[親の値を文字列として挿入](#placeholder-list)できます。
- Raw - フィールドの生の JSON コンテンツです。重要:[親の値を文字列として挿入](#placeholder-list)できます。
- FileName - ファイルを保存するローカルのファイル名です。デフォルトでは、まずヘッダーから FileName の取得を試み、その後 URL から取得します。重要:[親の値を文字列として挿入](#placeholder-list)できます。
- Path - ファイルを保存するローカルの親ディレクトリです。デフォルトのパスはプロセスのディレクトリです。重要:[親の値を文字列として挿入](#placeholder-list)できます。
- Append[false] - ファイルに追記するかどうか
{
"content": "{{{id}}}, {{{message}}}\n",
"append": true,
"file_name": "{{{id}}}.csv",
"path": "/Users/pxyup/fitter/examples/cli/test/csv"
}
ファイルフィールド
サーバーからファイルをダウンロードしてローカルに保存するために使用できます。
type FileFieldConfig struct {
Config *ServerConnectorConfig `yaml:"config" json:"config"`
Url string `yaml:"url" json:"url"`
FileName string `json:"file_name" yaml:"file_name"`
Path string `json:"path" yaml:"path"`
}
- Config - ServerConfig。リクエストの送信にはデフォルトのフィルター http.Client を使用します。
- Url - 画像の URL です。重要:コネクターの URL には[親の値を文字列として挿入](#placeholder-list)できます。
- FileName - ファイルを保存するローカルのファイル名です。デフォルトでは、まずヘッダーから FileName の取得を試み、その後 URL から取得します。重要:[親の値を文字列として挿入](#placeholder-list)できます。
- Path - ファイルを保存するローカルの親ディレクトリです。デフォルトのパスはプロセスのディレクトリです。重要:[親の値を文字列として挿入](#placeholder-list)できます。
このフィールドの結果は、ローカルファイルのパスを表す文字列です。
{
"url": "https://images.shcdn.de/resized/w680/p/dekostoff-gobelinstoff-panel-oriental-cat-46-x-46_P19-KP_2.jpg",
"path": "/Users/pxyup/fitter/bin",
"config": {
"method": "GET"
}
}
URL の伝播あり([親の値を文字列として挿入](#placeholder-list))
{
"url": "https://picsum.photos{PL}",
"path": "/Users/pxyup/fitter/bin",
"config": {
"method": "GET"
}
}
設定例:
https://github.com/PxyUp/fitter/blob/master/examples/cli/config_image.json
https://github.com/PxyUp/fitter/blob/master/examples/cli/config_image_multiple.json
計算フィールド
式に応じて、さまざまな型を生成できるフィールドです。
type CalculatedConfig struct {
Type FieldType `yaml:"type" json:"type"`
Expression string `yaml:"expression" json:"expression"`
}
- Type - 式の結果の型です。\
- Expression - 計算式です(計算式にはこちらのライブラリを使用します)。
定義済みの値
FNull - builder.Nullvalue のエイリアスです。
FNil - nil のエイリアスです。
isNull(value T) - value が FNull かどうかを確認する関数です。
fRes - 解析した基本フィールドの生の結果(適切な型に変換済み)です。
fIndex - 親配列内のインデックスです(親が配列フィールドの場合のみ)。
fResJson - 生の結果を JSON 文字列で表したものです。
fResRaw - バイト形式の結果です。
fSrc - 条件式/item_conditionでのみ使用できます。値の解決元となったソースノードです(JSON の解析値では兄弟要素を含み、HTML ではテキストコンテンツです)。計算式/書式設定式/通知式では使用できません。
FNewLine - 改行区切り文字です。
{
"type": "bool",
"expression": "fRes > 500"
}
プラグインフィールド
fitter 用の外部プラグインとして使用できます。
type PluginFieldConfig struct {
Name string `json:"name" yaml:"name"`
Config json.RawMessage `json:"config" yaml:"config"`
}
- Name - プラグイン名です(拡張子を除いた名前のみ)。
- Config - プラグインの JSON 設定です。
モデルフィールド
モデルおよびコネクターによって実行時に生成されるフィールド型です。
type ModelField struct {
// Type of parsing
ConnectorConfig *ConnectorConfig `yaml:"connector_config" json:"connector_config"`
// Model of the response
Model *Model `yaml:"model" json:"model"`
Type FieldType `yaml:"type" json:"type"`
Path string `yaml:"path" json:"path"`
Expression string `yaml:"expression" json:"expression"`
}
- ConnectorConfig - 使用するコネクターです。重要:コネクターの URL には[親の値を文字列として挿入](#placeholder-list)できます。
- Model - 内部モデルの設定です。
- Type - enum["null", "boolean", "string", "int", "int64", "float", "float64", "array", "object"] - 生成されるフィールドの型です。
- Path - 生成されたフィールドから情報を抽出できない場合に、JSON セレクターを使用して抽出できます。
- Expression - モデルの後処理に使用できる文字列です(Path フィールドは無視されます)。
例:
https://github.com/PxyUp/fitter/blob/master/examples/cli/config_cli.json#L60
{
"type": "array",
"model": {
"array_config": {
"root_path": "#content dt.quote > a",
"item_config": {
"field": {
"type": "string"
}
}
}
}
}
https://github.com/PxyUp/fitter/blob/master/examples/cli/config_weather.json#L37
{
"type": "string",
"path": "temp.temp",
"model": {
"object_config": {
"fields": {
"temp": {
"base_field": {
"type": "string",
"path": "//div[@id='forecast_list_ul']//td/b/a/@href",
"generated": {
"model": {
"type": "string",
"model": {
"object_config": {
"fields": {
"temp": {
"base_field": {
"type": "string",
"path": "div.current-temp span.heading"
}
}
}
}
},
"connector_config": {
"response_type": "HTML",
"attempts": 4,
"url": "https://openweathermap.org{PL}",
"browser_config": {
"playwright": {
"timeout": 30,
"wait": 30,
"install": false,
"browser": "FireFox",
"type_of_wait": "networkidle"
}
}
}
}
}
}
}
}
}
},
"connector_config": {
"response_type": "xpath",
"attempts": 3,
"url": "https://openweathermap.org/find?q={PL}",
"browser_config": {
"playwright": {
"timeout": 30,
"wait": 30,
"install": false,
"browser": "Chromium"
}
}
}
}
静的配列設定
静的(固定長)配列を生成します。
type StaticArrayConfig struct {
Items map[uint32]*Field `yaml:"items" json:"items"`
Length uint32 `yaml:"length" json:"length"`
}
例:
{
"0": {
"base_field": {
"type": "string",
"path": "div.current-temp span.heading"
}
}
}
{
"length": 4,
"0": {
"base_field": {
"type": "string",
"path": "div.current-temp span.heading"
}
}
}
{
"length": 4,
"2": {
"base_field": {
"type": "string",
"path": "div.current-temp span.heading"
}
}
}
プレースホルダー一覧
- {PL} - 値を挿入します
- {INDEX} - 親配列内のインデックスを挿入します
- {HUMAN_INDEX} - 親配列内のインデックスを、人が読みやすい形式で挿入します
- {{{json_path}}} - 伝播された「object」/「array」フィールドから情報を取得します
- {{{RefName=SomeName}}} - 名前で参照値を取得します。例
- {{{RefName=SomeName json.path}}} - 名前で参照値を取得し、JSON パスで値を抽出します。例
- {{{FromEnv=ENV_KEY}}} - 環境変数から値を取得します
- {{{FromExp=fRes + 5 + fIndex}}} - 式から値を取得します。事前定義値
- {{{FromInput=.}}} または {{{FromInput=json.path}}} - トリガーまたはライブラリの入力から値を取得します
- {{{FromFile=./test_file.log}}} - パスを指定してファイルから値を取得します。ファイルの内容にもプレースホルダーを含めることができます
- {{{FromURL=http://localhost:8081}}} - URL からレスポンスを取得します
例:
{{{FromExp="{{{FromEnv=TEST_VAL}}}" + "hello"}}}
Current time is: {PL} with token from TokenRef={{{RefName=TokenRef}}} and TokenObjectRef={{{RefName=TokenObjectRef token}}}
Current time is: {PL} with token from TokenRef={{{RefName=TokenRef}}} and TokenObjectRef={{{RefName=TokenObjectRef token}}}
TokenRef={{{RefName=TokenRef}}} and TokenObjectRef={{{RefName=TokenObjectRef token}}} Object={{{value}}} {PL} Env={{{FromEnv=TEST_VAL}}} {INDEX} {HUMAN_INDEX}
参照
処理を開始する前に事前取得される特殊なマップで、コネクターまたはプレースホルダーで使用できます。
以下の用途に使用できます。
- JWT トークンをキャッシュしてヘッダーで使用する
- 値をキャッシュする
- その他
参照
type Reference struct {
*ModelField
Expire *uint32 `yaml:"expire" json:"expire"`
}
- ModelField - 埋め込み構造体で、同じフィールドを使用できます
- Expire[sec] - 参照の取得後、有効期限が切れるまでの期間です。未設定の場合は無期限にキャッシュされます。0 に設定すると毎回再取得します。n > 0 に設定すると、n 秒間キャッシュされます。
Fitterの場合
type RefMap map[string]*Reference
type Config struct {
// Other Config Fields
Limits *Limits `yaml:"limits" json:"limits"`
References RefMap `json:"references" yaml:"references"`
}
Fitter Cliの場合
type RefMap map[string]*Reference
type CliItem struct {
// Other Config Fields
Limits *Limits `yaml:"limits" json:"limits"`
References RefMap `json:"references" yaml:"references"`
}
- References - map[string]*Reference - キーが ReferenceName(コネクターまたはプレースホルダーで使用可能)、値がReferenceとなるオブジェクトです
- Limits
例
https://github.com/PxyUp/fitter/blob/master/examples/cli/config_ref.json#L2
{
"references": {
"TokenRef": {
"expire": 10,
"connector_config": {
"response_type": "json",
"static_config": {
"value": "\"plain token\""
}
},
"model": {
"base_field": {
"type": "string"
}
}
},
"TokenObjectRef": {
"connector_config": {
"response_type": "json",
"static_config": {
"value": "{\"token\":\"token from object\"}"
}
},
"model": {
"object_config": {
"fields": {
"token": {
"base_field": {
"type": "string",
"path": "token"
}
}
}
}
}
}
}
}
通知機能
項目ごとの任意設定 item.notifier_config は、処理後に解析結果を指定先へ送信します。結果は通常どおり返されます(CLI/MCP 出力、サービスログ)。通知機能はこれに加えて結果を配信します。Fitter(サービスモード)、Fitter_CLI、Fitter_MCP で動作します。
type NotifierConfig struct {
Expression string `yaml:"expression" json:"expression"`
Force bool `json:"force" yaml:"force"`
SendArrayByItem bool `yaml:"send_array_by_item" json:"send_array_by_item"`
Template string `yaml:"template" json:"template"`
// exactly ONE destination:
Console *ConsoleConfig `yaml:"console" json:"console"`
TelegramBot *TelegramBotConfig `yaml:"telegram_bot" json:"telegram_bot"`
Http *HttpConfig `yaml:"http" json:"http"`
Redis *RedisNotifierConfig `json:"redis" yaml:"redis"`
File *FileStorageField `json:"file" yaml:"file"`
}
- Expression - 任意のexpr-lang条件です。評価結果が true の場合にのみ通知します。解析結果は
fRes(解析済みの値)、fResRaw(生バイト列)、fResJson(JSON 文字列)として利用でき、例:len(fResRaw) > 0 - Force - 解析がエラーで終了した場合でも通知します
- SendArrayByItem - 結果が配列の場合、各要素を個別の通知として送信します
- Template - 送信前に結果に適用する任意のテンプレートです。プレースホルダーを使用できます
- Destination -
console、telegram_bot、http、redis、fileのいずれか1つです
送信先の設定:
type HttpConfig struct {
Url string `yaml:"url" json:"url"`
Method string `json:"method" yaml:"method"`
Headers map[string]string `yaml:"headers" json:"headers"`
Timeout uint32 `yaml:"timeout" json:"timeout"`
}
type TelegramBotConfig struct {
Token string `json:"token" yaml:"token"`
UsersId []int64 `json:"users_id" yaml:"users_id"`
Pretty bool `json:"pretty" yaml:"pretty"`
OnlyMsg bool `json:"only_msg" yaml:"only_msg"`
}
type RedisNotifierConfig struct {
Addr string `json:"addr" yaml:"addr"`
Password string `json:"password" yaml:"password"`
DB int `json:"db" yaml:"db"`
Channel string `json:"channel" yaml:"channel"`
}
type ConsoleConfig struct {
OnlyResult bool `json:"only_result" yaml:"only_result"`
}
file送信先では、file フィールド型と同じFileStorageFieldを使用します。
例(examples/config_telegram.json):
{
"item": {
"connector_config": { "...": "..." },
"model": { "...": "..." },
"notifier_config": {
"expression": "len(fResRaw) > 0",
"telegram_bot": {
"token": "{{{FromEnv=TG_TOKEN}}}",
"users_id": [123456],
"pretty": true
}
}
}
}
制限
DDoS やメモリの大量使用を防ぐための制限を設定します。
type Limits struct {
HostRequestLimiter HostRequestLimiter `yaml:"host_request_limiter" json:"host_request_limiter"`
ChromiumInstance uint32 `yaml:"chromium_instance" json:"chromium_instance"`
DockerContainers uint32 `yaml:"docker_containers" json:"docker_containers"`
PlaywrightInstance uint32 `yaml:"playwright_instance" json:"playwright_instance"`
}
- HostRequestLimiter - map[string]int64 - ホスト名ごとの制限です。キーはホスト、値は並列リクエスト数です(サーバーコネクターで使用されます)。
- ChromiumInstance - 並列で実行できるchromiumインスタンス数
- DockerContainers - 並列で実行できるdockerインスタンス数
- PlaywrightInstance - 並列で実行できるplaywrightインスタンス数
https://github.com/PxyUp/fitter/blob/master/examples/cli/config_cli.json#L2
{
"limits": {
"host_request_limiter": {
"hacker-news.firebaseio.com": 5
},
"chromium_instance": 3,
"docker_containers": 3,
"playwright_instance": 3
}
}
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。