# DUPLICATE: Bricks MCP writes strip backslashes from Code element (javascriptCode)

**URL:** <https://forum.bricksbuilder.io/t/duplicate-bricks-mcp-writes-strip-backslashes-from-code-element-javascriptcode/40743>\
**Category:** Bugs\
**Tags:** v2-4-4\
**Created:** [October 31, 2026, 7:42am UTC](https://forum.bricksbuilder.io/t/duplicate-bricks-mcp-writes-strip-backslashes-from-code-element-javascriptcode/40743 "2026-10-31T07:42:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![serdar](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/s/d26b3c/32.png) [@serdar](https://forum.bricksbuilder.io/u/serdar)\
**Post date:** [October 31, 2026, 7:42am UTC](https://forum.bricksbuilder.io/t/duplicate-bricks-mcp-writes-strip-backslashes-from-code-element-javascriptcode/40743/1 "2026-10-31T07:42:47Z")

</div>

Hi,

Environment: Bricks 2.4.4, WordPress 7.1.4, Bricks MCP abilities called through the MCP adapter (mcp-adapter-execute-ability).

Steps:

1. bricks/duplicate-post on template 7557 → draft template 7763.  
The Code element’s javascriptCode is copied correctly, backslashes intact.
2. bricks/set-page-elements on 7763 with the same element tree (flat format),  
javascriptCode sent unchanged.
3. bricks/get-page-elements on 7763.

Expected: javascriptCode unchanged.

Actual: every backslash is removed. Examples from the stored value:  
before: return price.toFixed(2).replace(/\d(?=(\d{3})+.)/g, ‘$&,’);  
after: return price.toFixed(2).replace(/d(?=(d{3})+.)/g, ‘$&,’);  
before: originalPrice.match(/(.+?)/);  
after: originalPrice.match(/(.+?)/);  
The save returned success (changed: true, new revisionId), so the corruption is silent.

It is not limited to set-page-elements. Second test on a fresh duplicate (7767):

- set-page-elements with the backslashes doubled stored the code correctly;
- then bricks/update-element on a different element (root section, setting \_cssClasses)  
returned success, and the Code element’s javascriptCode had lost all its backslashes again.  
So any MCP write re-saves the whole document and strips backslashes from every element.

Also seen: bricks/update-element on the Code element itself with the original value fails  
with bricks\_conflict\_document\_write\_conflict (“The Bricks document changed while it was  
being saved. No candidate data was committed.”).

Impact: one MCP write to any page or template holding JavaScript with regular expressions  
or escaped characters silently breaks that code on every page using it.  
We found it on draft copies; the live template was not touched.

Suspected cause: the element data is saved with update\_post\_meta() without wp\_slash(),  
so WordPress’ wp\_unslash() removes the backslashes. The builder’s own save does not have  
this problem.

---

<div class="post-metadata">

**Author:** ![timmse](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/timmse/32/1192_2.png) [@timmse](https://forum.bricksbuilder.io/u/timmse)\
**Post date:** [November 2, 2026, 6:36am UTC](https://forum.bricksbuilder.io/t/duplicate-bricks-mcp-writes-strip-backslashes-from-code-element-javascriptcode/40743/3 "2026-11-02T06:36:27Z")

</div>

Thanks for the detailed report. This matches the issue already tracked here: WIP: 2.4.4: element-writing abilities strip every backslash from settings — CSS icons become “2197” and Code elements silently disappear. An internal fix has been merged and is expected in an upcoming release, subject to testing. We’ll update that thread once it’s fixed.

For now, please avoid MCP element writes on pages or templates containing backslashes in code, including updates to unrelated elements.

---

<div class="post-metadata">

**Author:** ![timmse](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/timmse/32/1192_2.png) [@timmse](https://forum.bricksbuilder.io/u/timmse)\
**Post date:** [November 2, 2026, 6:36am UTC](https://forum.bricksbuilder.io/t/duplicate-bricks-mcp-writes-strip-backslashes-from-code-element-javascriptcode/40743/4 "2026-11-02T06:36:30Z")

</div>

Closed on November 2, 2026, 6:36am UTC


