Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix(mcp): drop updatedBy injection for accounting_upsertFixedAssetUsageLog

Sidwebworks5446eff19efa
diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
index 9b94d1381a..bdd88c159a 100644
--- a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json
@@ -1,5 +1,5 @@
{
- "generated": "2026-07-01T02:25:57.401Z",
+ "generated": "2026-07-01T13:02:38.180Z",
"totalTools": 1249,
"modules": 15,
"tools": [
@@ -2832,8 +2832,7 @@
],
"injectAuth": [
"companyId",
- "createdBy",
- "updatedBy"
+ "createdBy"
],
"schema": {
"type": "object",
diff --git a/scripts/generate-mcp.ts b/scripts/generate-mcp.ts
index ff52f78a73..d468633229 100644
--- a/scripts/generate-mcp.ts
+++ b/scripts/generate-mcp.ts
@@ -78,13 +78,19 @@ const DESCRIPTION_OVERRIDES: Record<string, string> = {
};
// Per-tool overrides of the auto-computed injectAuth set. The default rule
-// (insert* → companyId + createdBy + updatedBy) is unsound for append-only
-// ledger tables that have no updatedBy column: the injected field leaks into the
-// INSERT payload and PostgREST rejects it ("column updatedBy does not exist").
-// inventory_insertManualInventoryAdjustment writes itemLedger, which has only
-// createdAt/createdBy.
+// (insert* → companyId + createdBy + updatedBy) is wrong for tools that spread
+// their argument object straight into an INSERT on an append-only ledger table.
+// Those tables now carry an updatedBy column (schema uniformity, migration
+// 20260701143512), but by convention it must stay NULL — an "edit" is a new
+// offsetting row, never an in-place mutation. Injecting updatedBy would stamp it
+// on the ledger row and destroy the "untouched since creation" guarantee, so we
+// drop it here. Both tools below insert([data]) where data is built from the
+// spread of their injected args:
+// - inventory_insertManualInventoryAdjustment → itemLedger
+// - accounting_upsertFixedAssetUsageLog → fixedAssetUsageLog
const INJECT_AUTH_OVERRIDES: Record<string, AuthField[]> = {
inventory_insertManualInventoryAdjustment: ["companyId", "createdBy"],
+ accounting_upsertFixedAssetUsageLog: ["companyId", "createdBy"],
};
// ---------------------------------------------------------------------------