Skip to content

Feat mcp bulk attributes - #55

Merged
dbose merged 2 commits into
mainfrom
feat-mcp-bulk-attributes
Oct 15, 2026
Merged

dbose merged 2 commits into
mainfrom
feat-mcp-bulk-attributes

Conversation

@dbose

@dbose dbose commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Create entities and add attributes in bulk via MCP

Building a wide entity through the agent/MCP surface was create_entity + N separate add_attribute calls. For a 54-column entity that’s 55 round trips and 55 full load → mutate → save → validate cycles, and any mid-sequence failure left a half-built entity. (This came from real Copilot usage.)

What it does — one validated transaction, both create and update paths
create_entity(..., attributes=[...]) builds the entity shell and all its columns in a single call. Pass [{name, domain?, role?, nullable?}] (domain defaults to string, nullable to true).
update_entity’s add_attribute now accepts a list as well as a single object — widening an existing entity by many columns in one transaction.
Both are all-or-nothing: a duplicate column name (against existing columns or earlier in the same batch) rejects the whole batch before anything is written.
New ids come back as created_ids / attribute_ids (entity first, then each column in order) so an agent can feed them straight into create_key_group with no re-read — the composite-PK “money path.”

Backward compatibility

created_id (scalar) is preserved as the first id, so existing single-create callers are unchanged. The bulk ids are surfaced as created_ids on both the MCP tools and the HTTP /api/command response (added in 6b37fe0), so a canvas/API caller can reference new columns without a re-read. The CLI has no bulk path; the preview/propose map intentionally keeps one primary id per change.

dbose added 2 commits October 14, 2026 12:58
…ction)

create_entity + N add_attribute calls was O(N) MCP round trips AND O(N) full
load/save/validate cycles — building a 54-column entity meant 55 calls, and a
mid-sequence failure left a half-built entity. Add a bulk path end to end:

- core: new add_attributes command adds many columns to one entity in a single
  load->append-all->one save->one validate; create_entity takes an optional
  inline attributes list. Both share _append_attribute, which rejects a
  duplicate name against existing columns AND earlier in the same batch, so the
  whole batch is all-or-nothing. CommandResult gains created_ids (the full list;
  created_id stays the first id for back-compat).
- mcp: create_entity gains an attributes param; update_entity's add_attribute
  accepts EITHER one object or a list. New ids come back as created_ids /
  attribute_ids so an agent can build a composite key from them with no re-read.
- server: add_attributes is proposable (SME PR flow); preview records a bulk
  change's primary (first) id, mirroring apply_command.

Tests: core (inline create, bulk add, all-or-nothing on dup, empty-list reject,
supplied-id parity) + mcp (one-call wide entity, list add, dup roll-back, and
the create->key-group-from-returned-ids money path). Full suite 999 passed.
The MCP tools returned every minted id from a bulk create_entity/add_attributes, but the
HTTP command route returned only created_id (the first id) — a canvas/API caller doing a
bulk create got the entity id and lost the new attribute ids, forcing a re-read to
reference the columns. Echo created_ids on the response when a command minted more than one
id, matching the MCP _write convention; single-create responses are unchanged (created_id
alone).

Test: HTTP bulk create_entity returns entity id + each column id in order; single create
has created_id and no created_ids.
@dbose
dbose merged commit 97b9e75 into main Oct 15, 2026
2 checks passed
@dbose dbose mentioned this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant