開発 development
IMPORTANT
Adobe LLM Appsは現在Betaにいます。
ここに示す機能、ワークフロー、UIは、必ずしも製品の最終状態を表すものではありません。 Betaに参加するには、llm-apps-beta@adobe.comに電子メールを送信します。
この節では、Adobe LLM Appsのハンドラープロジェクト構造、ローカル開発ワークフロー、テスト設定について説明します。 ハンドラー契約とサンプルコードについては、 アクションハンドラーの記述を参照してください。
プロジェクト構造
リンクされたリポジトリは、次のレイアウトに従います。
your-llm-app/
├── entry.js # Webpack entry — do not modify
├── actions/ # One folder per action
│ ├── search-products/
│ │ └── index.js # Handler (async function)
│ ├── get-product-details/
│ │ └── index.js
│ └── echo/
│ └── index.js
├── test/
│ ├── actions/
│ │ └── search-products.test.js
│ ├── fixtures/
│ │ └── actions.json
│ ├── html-transform.js
│ ├── jest.setup.js
│ └── server.test.js
├── server/
│ └── local.js # Local dev server (port 9080)
├── actions.json # Gitignored — local copy of UI metadata
├── app.config.yaml # Adobe I/O Runtime config
├── webpack.config.js
└── package.json
重要なポイント:
entry.jsはwebpack エントリポイントです。 ビルド時には、すべてのactions/*/index.jsファイルが検出され、1つのdist/index.jsにバンドルされます。 修正しないでください。actions.jsonは許可されています。 ローカル開発用にUIの「アクション」ページからダウンロードします。 デプロイメントの場合、パイプラインはAPIから自動的に書き込みます。- テストは、
actions/内のtest/actions/、ではなくに存在します。 Webpackはactions/以下のすべての要素をデプロイ済みのアーティファクトにバンドルします。テストを共同で配置すると、Adobe I/O Runtimeに送信されます。
ローカル開発
Adobeの資格情報を使用せずに、ローカルでハンドラーを開発およびテストできます。
npm install
npm run dev:local
これにより、webpackでプロジェクトが構築され、http://localhost:9080にプレーン Node.js HTTP サーバーが開始されます。 サーバーはactions/の下にあるハンドラーファイルを自動検出し、MCP ツールとして登録します。
actions.jsonをダウンロード
ローカルサーバーがアクションメタデータ(名前、説明、入力スキーマ)について把握するには、LLM Apps UIのアクションページからactions.jsonをダウンロードし、リポジトリルートに配置します。 これを使用しない場合、サーバーはハンドラーを検出しますが、最小限のメタデータで登録します。
actions.example.jsonを開始点としてactions.jsonにコピーすることもできます。
curlでテスト
# List all registered tools
curl -sX POST "http://localhost:9080" \
-H 'content-type: application/json' \
-H 'accept: application/json;q=1.0, text/event-stream;q=0.5' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
# Call the search-products action
curl -sX POST "http://localhost:9080" \
-H 'content-type: application/json' \
-H 'accept: application/json;q=1.0, text/event-stream;q=0.5' \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"search-products","arguments":{"category":"bagged-coffee"}}}'
MCP Inspectorを使用したテスト
npx @modelcontextprotocol/inspector
Transport Typeをstreamable-httpに、URLをhttp://localhost:9080に設定します。
テスト
ハンドラー単体テストはtest/actions/の下にあり、actions/ レイアウトをミラーリングします。
// test/actions/search-products.test.js
const handler = require('../../actions/search-products/index.js')
test('returns all products when no filter is given', async () => {
const result = await handler({})
expect(result.content[0].text).toContain('product')
expect(result.structuredContent.products.length).toBeGreaterThan(0)
})
test('filters by category', async () => {
const result = await handler({ category: 'bagged-coffee' })
expect(result.structuredContent.products.every(
(p) => p.category === 'bagged-coffee'
)).toBe(true)
})
test('filters by query', async () => {
const result = await handler({ query: 'dark-roast' })
expect(result.structuredContent.products.length).toBeGreaterThan(0)
})
test('returns empty result for unknown category', async () => {
const result = await handler({ category: 'nonexistent' })
expect(result.structuredContent.products).toHaveLength(0)
})
次を使用してテストを実行:
npm test # all tests
npx jest test/actions/search-products # one action only
デプロイメント
手動でビルドまたはデプロイすることはありません。 デプロイメントパイプラインの完全なチュートリアルについては、 アプリのデプロイ を参照してください。
日々のワークフローは次のとおりです。
ステップ
アクション
1. ハンドラーの書き込みまたは編集
actions/<name>/index.js2. メタデータのダウンロード
アクションページ → actions.jsonをダウンロード
3. ローカルにテスト
npm run dev:local4. プッシュコード
git push5. デプロイ
アプリの詳細ページ → デプロイ
recommendation-more-help
llm-apps-help-main-toc