Skip to main content
Glama
webflow

Webflow

Official
by webflow

Add Inline Site Script

add_inline_site_script

Add custom inline scripts to Webflow sites for header or footer placement, enabling functionality like analytics or custom interactions within character limits.

Instructions

Register an inline script for a site. Inline scripts are limited to 2000 characters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
site_idYesUnique identifier for the site.
requestYesRequest schema to register an inline script for a site.

Implementation Reference

  • Handler function that registers an inline script with Webflow API, fetches existing scripts, adds the new one with location mapping, upserts custom code, and returns the registration response.
    async ({ site_id, request }) => {
      const registerScriptResponse = await getClient().scripts.registerInline(
        site_id,
        {
          sourceCode: request.sourceCode,
          version: request.version,
          displayName: request.displayName,
          canCopy: request.canCopy !== undefined ? request.canCopy : true,
        },
        requestOptions
      );
    
      let existingScripts: any[] = [];
      try {
        const allScriptsResponse =
          await getClient().sites.scripts.getCustomCode(
            site_id,
            requestOptions
          );
        existingScripts = allScriptsResponse.scripts || [];
      } catch (error) {
        formatErrorResponse(error);
        existingScripts = [];
      }
    
      const newScript = {
        id: registerScriptResponse.id ?? " ",
        location:
          request.location === "footer"
            ? ScriptApplyLocation.Footer
            : ScriptApplyLocation.Header,
        version: registerScriptResponse.version ?? " ",
        attributes: request.attributes,
      };
    
      existingScripts.push(newScript);
    
      const addedSiteCustomCoderesponse =
        await getClient().sites.scripts.upsertCustomCode(
          site_id,
          {
            scripts: existingScripts,
          },
          requestOptions
        );
    
      return formatResponse(registerScriptResponse);
    }
  • Zod input schema for the add_inline_site_script tool, defining fields like sourceCode, version, displayName, location, etc.
    export const RegisterInlineSiteScriptSchema = z
      .object({
        sourceCode: z
          .string()
          .describe(
            "The inline script source code (hosted by Webflow). Inline scripts are limited to 2000 characters."
          ),
        version: z
          .string()
          .describe(
            "A Semantic Version (SemVer) string, denoting the version of the script."
          ),
        canCopy: z
          .boolean()
          .optional()
          .describe(
            "Indicates whether the script can be copied on site duplication and transfer."
          ),
        displayName: z
          .string()
          .describe(
            "User-facing name for the script. Must be between 1 and 50 alphanumeric characters."
          ),
        location: z
          .string()
          .optional()
          .describe(
            'Location where the script is applied. Allowed values: "header", "footer".'
          ),
        attributes: z
          .record(z.any())
          .optional()
          .describe(
            "Developer-specified key/value pairs to be applied as attributes to the script."
          ),
      })
      .describe("Request schema to register an inline script for a site.");
  • Tool registration call for 'add_inline_site_script' with title, description, input schema (including site_id and request schema), and handler reference.
      "add_inline_site_script",
      {
        title: "Add Inline Site Script",
        description:
          "Register an inline script for a site. Inline scripts are limited to 2000 characters. ",
        inputSchema: z.object({
          site_id: z.string().describe("Unique identifier for the site."),
          request: RegisterInlineSiteScriptSchema,
        }),
      },
      async ({ site_id, request }) => {
        const registerScriptResponse = await getClient().scripts.registerInline(
          site_id,
          {
            sourceCode: request.sourceCode,
            version: request.version,
            displayName: request.displayName,
            canCopy: request.canCopy !== undefined ? request.canCopy : true,
          },
          requestOptions
        );
    
        let existingScripts: any[] = [];
        try {
          const allScriptsResponse =
            await getClient().sites.scripts.getCustomCode(
              site_id,
              requestOptions
            );
          existingScripts = allScriptsResponse.scripts || [];
        } catch (error) {
          formatErrorResponse(error);
          existingScripts = [];
        }
    
        const newScript = {
          id: registerScriptResponse.id ?? " ",
          location:
            request.location === "footer"
              ? ScriptApplyLocation.Footer
              : ScriptApplyLocation.Header,
          version: registerScriptResponse.version ?? " ",
          attributes: request.attributes,
        };
    
        existingScripts.push(newScript);
    
        const addedSiteCustomCoderesponse =
          await getClient().sites.scripts.upsertCustomCode(
            site_id,
            {
              scripts: existingScripts,
            },
            requestOptions
          );
    
        return formatResponse(registerScriptResponse);
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the 2000-character limit, which is useful context beyond the schema. However, it lacks critical details: whether this is a mutation (implied by 'Register'), authentication requirements, rate limits, idempotency, error handling, or what happens on success/failure. For a tool that likely creates resources, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('Register an inline script for a site') and adds a key constraint. There is no wasted verbiage, repetition, or unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (mutation tool with nested objects, no output schema, and no annotations), the description is incomplete. It lacks information on behavioral traits (e.g., side effects, permissions), output expectations, error cases, and how it integrates with sibling tools like 'site_registered_scripts_list'. The 2000-character limit is helpful but insufficient for full contextual understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters (site_id and request object with its properties). The description adds minimal value by reiterating the 2000-character limit for inline scripts, which is already in the schema's sourceCode description. No additional parameter context is provided beyond what the schema offers.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Register') and resource ('inline script for a site'), specifying it's for inline scripts with a character limit. It distinguishes from sibling tools like 'site_registered_scripts_list' (which lists scripts) and 'delete_all_site_scripts' (which removes them). However, it doesn't explicitly contrast with potential alternatives for script management beyond the listed siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description mentions the character limit but doesn't indicate prerequisites (e.g., site access), scenarios for inline vs. external scripts, or comparisons to other script-related tools in the sibling list. Usage context is implied but not explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/webflow/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server