myco:implement-update-tool-fetch-merge-put
Installation
SKILL.md
Implementing an Update Tool: The Fetch-Merge-Put Pattern
All update tools in unifi-mcp follow the fetch-merge-put pattern. Skipping the fetch step causes silent data loss — the PUT wipes every field not included in the payload. Five tools shipped with this bug (issue #113) before the pattern was standardized. This skill teaches you how to do it right.
Prerequisites
- The resource's manager already has a
get_<resource>_by_idmethod. If not, write it first (check the V2 API gotcha below before you do). deep_mergeis importable fromunifi-core. Tests live inpackages/unifi-core/tests/test_merge.py— run them after any merge logic change.- The create tool for this resource already exists. Update tools assume the object exists; if it doesn't, the caller should use create, not update.
- The field symmetry rule (issue #137) requires
update_datato accept all field names and compatible types from the read surface. Checktests/unit/test_tool_field_symmetry.pybefore opening a PR.
Steps
1. Read the golden path reference first
Before writing any code, read network_manager.py:update_network. It is the canonical implementation of the pattern. Let it orient your mental model before you look at the resource you're adding.