Create a cart transform or order validation Function extension with the Shopify CLI and define the target API type in your extension TOML.
Write your input query in the `input.graphql` file requesting only the fields your function needs; the maximum input query size (excluding comments) is 3,000 bytes.
Keep calculated query cost at or below 30 and ensure no list-type argument or variable exceeds 100 elements.
Return a `FunctionRunResult` with errors array; each error object includes a `localizedMessage` and optionally targets specific cart line items by ID.
Store any merchant-configurable thresholds as metafields on the Function owner and read them via the input query; metafield values over 10,000 bytes are not returned.
Test locally with `shopify app function run` feeding a sample JSON input; validate the instruction count stays within the limit before deploying.
Known gotchas
The raw request body for the input query is capped at 3,000 bytes — over-requesting fields silently truncates or causes the Function to receive partial data.
Function output is capped at 250 KB; returning large serialized error trees can hit this limit and result in a generic checkout failure.
Metafields with values exceeding 10,000 bytes are silently omitted from the function input, so large JSON configs must be split or stored elsewhere.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp