validate_component_codeblocks
🚨 MANDATORY VALIDATION TOOL - MUST BE CALLED WHEN COMPONENTS FROM SHOPIFY PACKAGES ARE USED. DONT ASK THE USER TO DO THIS. DON'T CONTEXT SWITCH. This tool MUST be used to validate ALL code blocks containing Shopify components, regardless of size or complexity. ⚠️ CRITICAL REQUIREMENTS: - Call th...
This record as markdown: /tools/dev/validate-component-codeblocks.md
What validate_component_codeblocks does on Dev
AI agents call validate_component_codeblocks to retrieve information from Dev without modifying anything. It is typically the context-gathering step in research, monitoring, and reporting workflows, before the agent takes action elsewhere.
| Parameter | Type | Required | Description |
|---|---|---|---|
api | string | Yes | API name to validate against (e.g., 'pos-ui', 'polaris-app-home'). |
code | array | Yes | Array of code blocks with content and optional artifact metadata. Supported code blocks are JS/TS React, vanilla JS/TS, Preact, and raw HTML Polaris web compone |
version | string | — | The API version to validate against (e.g., '2026-01', '2025-10'). Pass the version you detected or passed search_docs_chunks. When omitted, defaults to the late |
conversationId | string | Yes | 🔗 REQUIRED: conversationId from learn_shopify_api tool. Call learn_shopify_api first if you don't have this. |
extensionTarget | string | — | Required for extension surface APIs (polaris-admin-extensions, polaris-checkout-extensions, polaris-customer-account-extensions, pos-ui). The extension target d |
Parameters from the server's own tool schema.
Why validate_component_codeblocks is rated Low
This tool reads and analyzes code to validate it against known Shopify component schemas. It does not create, modify, delete, execute, or initiate any external operations. It is purely a linting/validation utility that returns analysis results. The mandatory nature and emphasis on calling it does not change its fundamental operation: inspection without side effects.
From the tool's definition Tool performs validation by checking code blocks against Shopify component specifications. The description states it 'validate[s]' and 'prevents hallucinated components' - these are inspection and verification operations with no side effects on data or…
Risk signalsAccepts freeform code/query input (code) · Accepts raw HTML/template content (code[].content)
Attacks that exploit this kind of access
The rule that runs validate_component_codeblocks safely
PolicyLayer is an MCP gateway: it sits between your AI agents and Dev, and checks every tool call against a rule you set before the call runs. Nothing changes on the server itself. For validate_component_codeblocks, this is the rule to start with:
validate_component_codeblocks is read-only, so it stays allowed. Everything else on the server is denied unless you say otherwise.
The button opens the PolicyLayer dashboard: create your workspace, connect Dev, apply this rule, and every validate_component_codeblocks call is checked against it from then on.
Questions about validate_component_codeblocks
🚨 MANDATORY VALIDATION TOOL - MUST BE CALLED WHEN COMPONENTS FROM SHOPIFY PACKAGES ARE USED. DONT ASK THE USER TO DO THIS. DON'T CONTEXT SWITCH. This tool MUST be used to validate ALL code blocks containing Shopify components, regardless of size or complexity. ⚠️ CRITICAL REQUIREMENTS: - Call this tool IMMEDIATELY after generating ANY Shopify component code - NEVER skip validation, even for simple examples or snippets - ALWAYS use this tool when generating JSX, TSX, or web component code - This validation prevents hallucinated components, props, and prop values - Your major tasks while structuring the input is to ensure that: 1. If the code contains JS/TS code, it should be wrapped inside a function. 2. All Javascript code is outside return statement of the function. 3. All the polaris web components are in return statement of the function. INPUT STRUCTURE: Do not pass in tiny snippets of code. Follow the example given below as the input to validate_component_codeblocks tool. { "api": "The API name (e.g., 'polaris-app-home', 'pos-ui')", "code": [ { "content": " const Extension = () => { const [isConnected, setIsConnected] = useState( shopify.connectivity.current.value.internetConnected === 'Connected' ); useEffect(() => { const unsubscribe = shopify.connectivity.current.subscribe((newConnectivity) => { setIsConnected(newConnectivity.internetConnected === 'Connected'); }); return unsubscribe; }, []); return ( <s-tile heading="My App" disabled={!isConnected} /> ); }; " } ] } 📤 OUTPUTS: - Comprehensive validation results with specific error details - Clear guidance on how to fix any validation failures - Component-by-component validation status 🔄 WORKFLOW: Generate Code → Validate → Fix Errors and replace code → Re-validate if needed It returns a comprehensive validation result with details for each code block explaining why it was valid or invalid. This detail is provided so LLMs know how to modify code snippets to remove errors. It also returns an artifact ID and revision number for each code block. This is used to track the code block and its validation results. When validating an iteration of the same code block, use the same artifact ID and increment the revision number. Do not pass your own artifact ID to this tool, the tool will generate one for you. It is categorised as a Read tool in the Dev MCP Server, which means it retrieves data without modifying state.
validate_component_codeblocks accepts 5 parameters: api, code, version, conversationId, extensionTarget. Required: api, code, conversationId. The full parameter table on this page comes from the server's own tool schema.
Register the Dev MCP server in PolicyLayer and add a rule for validate_component_codeblocks: allow, deny, rate-limit, or require approval. Point your MCP client at the PolicyLayer proxy URL and the rule is enforced on every call, before it reaches Dev. Nothing to install.
validate_component_codeblocks is a Read tool with low risk. Read-only tools are generally safe to allow by default.
Yes. Add a rate_limit block to the validate_component_codeblocks rule in your PolicyLayer policy. For example, setting max: 10 and window: 60 limits the tool to 10 calls per minute. Rate limits are tracked per agent session and reset automatically.
Set action: deny in the PolicyLayer policy for validate_component_codeblocks. The AI agent will receive a policy violation error and cannot call the tool. You can also include a reason field to explain why the tool is blocked.
validate_component_codeblocks is provided by the Dev MCP server (@shopify/dev-mcp). PolicyLayer sits as a proxy in front of this server to enforce policies before tool calls reach the server.
More on Dev, and thousands of servers like it.
This server
Across the catalogue