custom-code-management

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Custom Code Management

自定义代码管理

Concepts

概念

Webflow custom code: register (store script) → apply (attach to site). Inline scripts only via MCP (max 10,000 chars).
Webflow自定义代码:注册(存储脚本)→ 应用(附加到站点)。仅可通过MCP添加内联脚本(最多10,000字符)。

Important note

重要提示

ALWAYS use Webflow MCP tools for all operations: Use the following tools for all operations:
  • data_scripts_tool
    with actions
    list_registered_scripts
    /
    list_applied_scripts
    - List scripts
  • data_scripts_tool
    with action
    add_inline_site_script
    - Register inline script (no
    <script>
    tags)
  • data_scripts_tool
    with action
    delete_all_site_scripts
    - Remove ALL scripts (no selective delete)
  • data_sites_tool
    with action
    list_sites
    - List available sites
所有操作请务必使用Webflow MCP工具: 所有操作请使用以下工具:
  • data_scripts_tool
    配合动作
    list_registered_scripts
    /
    list_applied_scripts
    - 列出脚本
  • data_scripts_tool
    配合动作
    add_inline_site_script
    - 注册内联脚本(无需
    <script>
    标签)
  • data_scripts_tool
    配合动作
    delete_all_site_scripts
    - 移除所有脚本(不支持选择性删除)
  • data_sites_tool
    配合动作
    list_sites
    - 列出可用站点

Instructions

操作步骤

View Scripts

查看脚本

  1. Call
    data_sites_tool
    with action
    list_sites
    if needed, then call both list tools in parallel
  2. Display registration and application status
  1. 如有需要,调用
    data_sites_tool
    并使用动作
    list_sites
    ,然后并行调用两个列表工具
  2. 显示脚本的注册和应用状态

Add Script

添加脚本

  1. Gather: name, code, location (header/footer)
  2. Validate: under 10,000 chars, no
    <script>
    tags
  3. Preview with character count, require "add" to confirm
  4. Call
    data_scripts_tool
    with action
    add_inline_site_script
    with displayName, sourceCode, version, location, canCopy
  5. Remind user to publish
  1. 收集信息:名称、代码、位置(页眉/页脚)
  2. 验证:字符数不超过10,000,无
    <script>
    标签
  3. 预览字符数,需用户确认输入**"add"**才可继续
  4. 调用
    data_scripts_tool
    并使用动作
    add_inline_site_script
    ,传入displayName、sourceCode、version、location、canCopy参数
  5. 提醒用户发布站点

Remove Scripts

移除脚本

  1. List current scripts
  2. Warn: removes ALL scripts (no selective delete)
  3. Require "delete all" to confirm
  4. Remind user to publish
  1. 列出当前所有脚本
  2. 警告:此操作会移除所有脚本(不支持选择性删除)
  3. 需用户确认输入**"delete all"**才可继续
  4. 提醒用户发布站点

Constraints

限制条件

  • Max 10,000 characters per script
  • Do NOT include
    <script>
    tags (Webflow adds them)
  • displayName + version must be unique
  • Site-level only (no page-specific via MCP)
  • Hosted scripts not available via MCP
  • 每个脚本最多10,000字符
  • 请勿包含
    <script>
    标签(Webflow会自动添加)
  • displayName + version组合必须唯一
  • 仅支持站点级脚本(MCP不支持页面级脚本)
  • MCP不支持托管脚本

Response Format

响应格式

After adding a script, respond with the script name, location, and version. Suggest using the
safe-publish
skill to publish changes.
添加脚本后,返回脚本名称、位置和版本。建议使用
safe-publish
技能发布更改。