{"id":66635,"plugin_id":"plugin_asdk_app_6a5104583be08191a0f29f096fe1aca6","kind":"skill","collection_source":"plugin_package","comparison_source":null,"observed_at":"2026-10-28T12:27:43.664Z","digest":"a7e0388955a0df24eac69102d0ed189d1f6b7e84bdb398dd4e3acf972659c303","against":null,"payload":{"description":"Configures a V2 inventory import (feed pipeline) for an existing Motive dealer through api_docs and execute: reads the dealer, finds the feed source, enables Inventory Feed V2, creates the pipeline and the pipeline step, creates the V1 import feed record, reads the vendor file, and starts the inventory sync. Use when the user asks to set up, add, configure, or fix an inventory import, import feed, feed pipeline, or vendor feed (vAuto, HomeNet, DealerOn, and others) for a dealer, or gives a dealer id with a vendor name and a filename or dealer code.\n","included_files":[],"name":"inventory-import-setup","skill_md_contents":"---\nname: inventory-import-setup\ndescription: >\n  Configures a V2 inventory import (feed pipeline) for an existing Motive dealer\n  through api_docs and execute: reads the dealer, finds the feed source, enables\n  Inventory Feed V2, creates the pipeline and the pipeline step, creates the V1\n  import feed record, reads the vendor file, and starts the inventory sync. Use\n  when the user asks to set up, add, configure, or fix an inventory import,\n  import feed, feed pipeline, or vendor feed (vAuto, HomeNet, DealerOn, and\n  others) for a dealer, or gives a dealer id with a vendor name and a filename\n  or dealer code.\n---\n\n# Inventory import configuration (V2 feed pipeline)\n\nThis skill connects one dealer to one vendor inventory file. You do all work with the MCP tools `search_docs`, `api_docs`, and `execute`. No MCP method creates a dealer or a feed source. Those records must exist before you start.\n\nThe procedure has five phases. Each phase that writes data is one `execute` call. Do not divide a phase into more calls. Each call costs time.\n\n## Terms\n\nUse these words. Do not use a different word for the same object.\n\n- Feed source: the saved definition of a vendor file. It has the host, the file format, and the default field mappings. Motive owners manage feed sources. You only read them.\n- Pipeline: the ordered list of pipeline steps for one dealer. One dealer has one pipeline or no pipeline.\n- Pipeline step: one feed source and one filename, attached to one pipeline.\n- V1 import feed record: the older feed record on the dealer. A V2 import needs this record.\n- Inventory sync: one manual import of the vendor file.\n- Change set: the audit group for all writes in one task.\n\n## Values you need before you write\n\nGet these three values from the user:\n\n- The dealer id, or a dealer name that you can search.\n- The feed source name (for example, vAuto).\n- The filename or dealer code from the vendor (for example, MP4131).\n\nIf the feed source needs a secret or a username, and the user did not give it, stop and ask. Do not write credentials that the user did not give.\n\n## Tools\n\n| Tool          | Use                                               |\n| ------------- | ------------------------------------------------- |\n| `api_docs`    | Read one method. This tool is not `ctx.api_docs`. |\n| `search_docs` | Find a method by keyword.                         |\n| `execute`     | Send `async def run(ctx): ...`. No imports.       |\n\nRead `api_docs` for a method the first time that you use it in a session. Read it again if a call fails with HTTP 422. Do not read every method before you start.\n\n`commit` is a short string. `commit=True` fails.\n\n## Change set rules\n\n- A read-only call does not open a change set.\n- The first write does not send `change_set_id`. It sends `commit=\"...\"`.\n- Each later write sends the same `change_set_id`.\n- One `commit` string for each phase.\n- If you also configure pricing for this dealer, use the same `change_set_id` for both skills.\n\n## Procedure\n\nCopy this checklist and mark each phase when it is done.\n\n```\n- [ ] Phase 1. Get the values from the user\n- [ ] Phase 2. Read the dealer and the feeds\n- [ ] Phase 3. Write the import\n- [ ] Phase 4. Start the inventory sync\n- [ ] Phase 5. Report\n```\n\n### Phase 1. Get the values from the user\n\nGet the three values in \"Values you need before you write\". If a value is missing, ask for it. Ask one time, in one message.\n\n### Phase 2. Read the dealer and the feeds\n\nThis phase is one read-only `execute` call. Do not send `commit`.\n\n```python\nasync def run(ctx):\n    dealer, feeds, sources, connections = await ctx.gather(\n        ctx.get_dealer(dealer_id),\n        ctx.get_import_feeds(dealer_id),\n        ctx.list_feed_sources(),\n        ctx.get_feed_connections(dealer_id),\n    )\n    v2_on = bool(dealer.get(\"inventory_feed_v2_enabled\"))\n    pipeline = None\n    if v2_on:\n        pipeline = await ctx.get_feed_pipeline(dealer_id)\n    source = None\n    for s in sources or []:\n        if s.get(\"name\") == \"vAuto\":\n            source = s\n            break\n    return {\n        \"dealer\": {\n            \"id\": dealer.get(\"id\"),\n            \"name\": dealer.get(\"name\"),\n            \"domain\": dealer.get(\"domain\"),\n            \"inventory_feed_v2_enabled\": v2_on,\n        },\n        \"import_feed\": (feeds or {}).get(\"import_feed\"),\n        \"connections\": connections,\n        \"pipeline\": pipeline,\n        \"source\": None if source is None else {\n            \"id\": source.get(\"id\"),\n            \"name\": source.get(\"name\"),\n            \"transport_type\": source.get(\"transport_type\"),\n            \"payload_format\": source.get(\"payload_format\"),\n            \"requires_step_secret\": source.get(\"requires_step_secret\"),\n            \"requires_step_username\": source.get(\"requires_step_username\"),\n            \"locked\": source.get(\"locked\"),\n        },\n    }\n```\n\nReplace `\"vAuto\"` with the feed source name from the user.\n\nRecord these values from the result:\n\n- The dealer name and `inventory_feed_v2_enabled`\n- `import_feed` (a record, or `null`)\n- `pipeline` (a record, or `null`)\n- The feed source `id`, `transport_type`, `payload_format`, `requires_step_secret`, and `requires_step_username`\n\nIf `source` is `null`, stop. Tell the user that no feed source has that name. Give the user the names from `list_feed_sources`.\n\nIf `pipeline` has a step for this feed source, stop and tell the user. Do not create a second pipeline step.\n\nDo not call `get_feed_pipeline` when `inventory_feed_v2_enabled` is `false`. The call fails with HTTP 403. The code above obeys this rule.\n\n### Phase 3. Write the import\n\nThis phase is one `execute` call. It does up to five writes and one read. Do not send `change_set_id`, unless the pricing skill opened a change set. Send `commit`.\n\nBuild the filename before you write:\n\n- If the feed source is FTP or SFTP with `payload_format: \"csv\"`, add `.csv` to the dealer code. Example: `MP4131` becomes `MP4131.csv`.\n- If the feed source is XML, also set `execution_settings.parse_settings.records_path`. Read `api_docs(method=\"create_feed_pipeline_step\")` for the format.\n- If the feed source is a managed API, use the dealer code with no extension.\n\nSet `V2_ON`, `HAS_PIPELINE`, and `HAS_IMPORT_FEED` from the Phase 2 result. Then send this code:\n\n```python\nasync def run(ctx):\n    V2_ON = False\n    HAS_PIPELINE = False\n    HAS_IMPORT_FEED = False\n    SOURCE_ID = 91\n    IMPORT_TYPE = \"vAuto\"\n    FILENAME_STEM = \"MP4131\"\n    FILENAME = \"MP4131.csv\"\n\n    out = {}\n\n    if not V2_ON:\n        await ctx.update_dealer(dealer_id, inventory_feed_v2_enabled=True)\n        out[\"v2_enabled\"] = True\n\n    if not HAS_PIPELINE:\n        pipeline = await ctx.create_feed_pipeline(dealer_id, enabled=True)\n        out[\"pipeline_id\"] = pipeline.get(\"id\")\n\n    sources = await ctx.list_feed_sources()\n    source = None\n    for s in sources or []:\n        if s.get(\"id\") == SOURCE_ID:\n            source = s\n            break\n\n    step = await ctx.create_feed_pipeline_step(\n        dealer_id,\n        feed_source_id=SOURCE_ID,\n        name=source.get(\"name\"),\n        enabled=True,\n        execution_settings={\"filename\": FILENAME},\n        mapping_settings=source.get(\"mapping_settings\"),\n    )\n    out[\"step_id\"] = step.get(\"id\")\n\n    if not HAS_IMPORT_FEED:\n        feed = await ctx.create_import_feed(\n            dealer_id,\n            import_type=IMPORT_TYPE,\n            filename=FILENAME_STEM,\n            include_new=True,\n            include_used=True,\n        )\n        out[\"import_feed_id\"] = (feed.get(\"import_feed\") or feed).get(\"id\")\n\n    sample = await ctx.read_feed_pipeline_step_file(dealer_id, step.get(\"id\"), max_rows=2)\n    out[\"row_count\"] = sample.get(\"row_count\")\n    out[\"headers\"] = (sample.get(\"headers\") or [])[:5]\n    return out\n```\n\n`commit=\"Configure vAuto MP4131 inventory import for dealer <id>\"`\n\nRules for this call:\n\n- A locked feed source has its own `mapping_settings`. Copy them to the step. Do not write mappings by hand for a locked feed source.\n- The V1 import feed record uses the filename stem, with no `.csv`.\n- `import_type` must match a V1 import type name. The locked feed source name is usually the same (`vAuto`, `HomeNet`). If you are not sure, read `api_docs(method=\"create_import_feed\")`.\n- If the feed source needs a secret, send `secret=...` as a top-level argument to `create_feed_pipeline_step`.\n\nRecord `change_set_id`, `pipeline_id`, `step_id`, `import_feed_id`, `row_count`, and `headers` from the result.\n\nIf the file read fails, the step exists with a wrong filename. Do not create a second step. Correct the filename with `update_feed_pipeline_step(dealer_id, step_id, execution_settings={\"filename\": ...})`. Then read the file again. Do not start the sync until the file read succeeds.\n\n### Phase 4. Start the inventory sync\n\nDo this phase as part of the configuration. The words \"set up\", \"add\", \"configure\", and \"fix\" include this phase. Do not do this phase if the user says configure only, skip the sync, or do not import vehicles yet.\n\nThis phase is one `execute` call. Send the `change_set_id` from Phase 3.\n\n```python\nasync def run(ctx):\n    active = await ctx.get_import_feed_active_progress(dealer_id)\n    if active:\n        return {\"skipped\": True, \"active\": active}\n    result = await ctx.sync_import_feed(dealer_id)\n    return {\"correlation_id\": result.get(\"correlation_id\")}\n```\n\n`commit=\"Start inventory sync for dealer <id>\"`\n\nRecord the `correlation_id`.\n\nDo not wait for the sync in this skill. If you also configure pricing for this dealer, do that work while the sync is active. Then read the progress one time:\n\n```python\nasync def run(ctx):\n    return await ctx.get_import_feed_active_progress(dealer_id)\n```\n\nThe sync is complete when this call gives `null`. A file with 400 vehicles takes some minutes.\n\n### Phase 5. Report\n\nGive the user these values:\n\n- Dealer id and dealer name\n- Feed source name and filename\n- Pipeline id and pipeline step id\n- V1 import feed id\n- Row count and the first five headers from Phase 3\n- Change set id\n- The `correlation_id` and the last progress that you read, if you started the sync\n\n## Errors\n\n| Error                                    | Cause                                   | Action                                                     |\n| ---------------------------------------- | --------------------------------------- | ---------------------------------------------------------- |\n| `GET .../feed_pipeline (HTTP 403)`       | `inventory_feed_v2_enabled` is `false`  | Do not call it. Phase 3 enables V2.                        |\n| `HTTP 422` on `create_feed_pipeline`     | The dealer has a pipeline               | Set `HAS_PIPELINE = True`. Send Phase 3 again.             |\n| `HTTP 422: Import feed is required`      | No V1 import feed record                | Call `create_import_feed` alone. Then read the file again. |\n| `read_feed_pipeline_step_file` fails     | Wrong filename                          | Correct it with `update_feed_pipeline_step`. Read again.   |\n| `name 'next' is not defined`             | The sandbox blocks some Python builtins | Use a `for` loop.                                          |\n| `Dunder attribute access is not allowed` | The sandbox blocks `__*` attributes     | Do not use `__name__`, `__dict__`, or similar.             |\n| `sync_import_feed` refuses               | An import is active                     | Wait. Then read `get_import_feed_active_progress` again.   |\n| `commit=True` rejected                   | `commit` is a string, not a boolean     | Send a short summary string.                               |\n\nIf Phase 3 fails after some writes, the change set has those writes. Do not send the whole phase again without change. If the step does not exist, set the `HAS_*` flags to match the writes that succeeded. Then send the phase again with the `change_set_id`. If the step exists, do only the calls that did not succeed.\n\n## References\n\n- `skill://dealer-setup/references/feeds-and-inventory.md`: the feed audit during general dealer setup.\n"},"changes":[],"summary":"First saved snapshot. No earlier version is available for comparison.","summary_kind":"deterministic","summary_metadata":{}}