[DEVPL-4067] Add data_custom_code_tool for freeform head/footer custom code#131
Closed
bertenator wants to merge 1 commit into
Closed
[DEVPL-4067] Add data_custom_code_tool for freeform head/footer custom code#131bertenator wants to merge 1 commit into
bertenator wants to merge 1 commit into
Conversation
Wrap the freeform Custom Code Data API
(/v2/{sites|pages}/:id/custom_code/freeform[/:location]) behind a new
data_custom_code_tool with get/set actions for site and page head/footer
code. Mirrors the existing authenticated-fetch pattern (workflows.ts); the
API enforces scopes, the Custom Code entitlement, and the feature gate, so
the tool is a thin token-forwarding wrapper.
The underlying Data API (DEVPL-4351, rolled out to 100%) was live but had no
MCP tool exposing it.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
viratatwebflow
left a comment
Collaborator
There was a problem hiding this comment.
We do have this
https://github.com/webflow/mcp-remote-cloudflare-server/pull/128
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
data_custom_code_toolthat exposes Webflow's freeform custom code (raw<head>/ footer code blocks on a site or page) through the MCP server. The Data API endpoints/v2/{sites|pages}/:id/custom_code/freeform[/:location]are live, but no MCP tool wrapped them, so MCP clients had no way to read or write freeform head/footer code.What's added
One
data_custom_code_tool(actions array, consistent with the other data tools):get_site_freeform_code— GET a site's head/footer freeform code (omitlocationfor both)set_site_freeform_code— PUT (atomic replace) a site's head or footerget_page_freeform_code— GET a page's head/footer freeform code (optionallocale_id)set_page_freeform_code— PUT (atomic replace) a page's head or footerHow it works
Mirrors the existing
data_workflows_tool: a thin authenticatedfetchto the Data API using the caller's OAuth token. All access control — read/write scopes, the Custom Code entitlement, and the feature gate — is enforced API-side, so this stays a thin wrapper with no SDK change.How to test
Prereqs: connect the MCP server to a client (Claude Desktop / Cursor / MCP Inspector) with a token that has
sites:read|write+pages:read|writeand a workspace/site with the Custom Code entitlement. Grab aSITE_IDand aPAGE_ID(e.g. viadata_sites_tool/data_pages_tool).Natural-language prompts:
Read the freeform head and footer custom code on page PAGE_ID.Add <meta name="robots" content="noindex"> to the head custom code on page PAGE_ID, then read it back to confirm.Put a small console.log script in the footer custom code of page PAGE_ID.Show the site-wide freeform head and footer code for site SITE_ID.Add an Inter Google Font <link> tag to the site-wide head code for site SITE_ID.Clear the footer code on page PAGE_ID by setting it to an empty string.Direct tool calls (MCP Inspector):
{ "actions": [ { "get_page_freeform_code": { "page_id": "PAGE_ID" } } ] }{ "actions": [ { "set_page_freeform_code": { "page_id": "PAGE_ID", "location": "head", "content": "<meta name=\"robots\" content=\"noindex\">" } } ] }{ "actions": [ { "set_site_freeform_code": { "site_id": "SITE_ID", "location": "head", "content": "<link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/css2?family=Inter&display=swap\">" } } ] }What to verify:
set_*followed by aget_*returns the samecontent.get_*with nolocationreturns both head and footer; withlocationreturns just that block.*:writescope → scope/authorization errorset_page_freeform_codewith a non-primarylocale_id→ validation error (page freeform code is single-locale today)contentover the custom-code character limit → validation errorTesting (build)
npx tsc --noEmit— passes, no type errorsnpm run build(tsup) — succeeds(No test suite exists in this repo; verification is typecheck + build.)
Follow-up
Jira
🤖 Generated with Claude Code