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_id method. If not, write it first (check the V2 API gotcha below before you do).
  • deep_merge is importable from unifi-core. Tests live in packages/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_data to accept all field names and compatible types from the read surface. Check tests/unit/test_tool_field_symmetry.py before 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.

2. Implement the four-step pattern

Installs
3
GitHub Stars
425
First Seen
Apr 29, 2026
myco:implement-update-tool-fetch-merge-put — sirkirby/unifi-mcp