---
title: "corestack_varnish_vcl_validate"
url: https://docs.corefinity.com/mcp/tools/corestack_varnish_vcl_validate
type: tool
last_updated: 2026-11-13
feature: varnish
related:
  - https://docs.corefinity.com/api/reference/varnish/check-site-varnish-vcl.md
  - https://docs.corefinity.com/guides/sites/software-and-services/varnish.md
---
# corestack_varnish_vcl_validate

**Check custom Varnish VCL.** Checks custom Varnish VCL without saving it: the policy, then a compile. Diagnostics carry hook, line and column. Use it before corestack_varnish_vcl_update. Scope: read.

- Scope: `read`
- Runs as a task: no

## When to use it

Check custom Varnish VCL without saving it: the same checks a save runs. First the policy (`corestack_varnish_policy_get`), then a compile of the platform VCL with your hooks inserted, on the row's Varnish version (or on `varnish_version`, to check before a version change). Run it before every `corestack_varnish_vcl_update`.

The answer is `{valid, diagnostics, test}`. Each diagnostic has the `hook`, the `line` and `column` in that hook, `severity` (`error` or `warning`), `kind` (`policy`, `compile` or `advice`), a `code` for policy findings (`VN-POL-nn`, `VN-WARN-nn`, `VN-LIM-nn`) and the `message`. Warnings never block a save. The compile runs in a sandbox and can take up to a minute; when it cannot run, `test` says so and the policy findings still answer (a save then compiles again before Varnish loads the VCL).

## Inputs

- `site_id` (integer, ≥ 1, required): the row, a Magento 2 site or one of its environments.
- `hooks` (object, required): `recv`, `backend_response`, `deliver`, each text or null for empty. A hook left out is checked as it is now.
- `varnish_version` (string, at most 8 characters): compile on another offered version, such as `8.0`, instead of the row's own.

### Input schema

```json
{
  "additionalProperties": false,
  "properties": {
    "hooks": {
      "additionalProperties": false,
      "description": "Left out: the current hook.",
      "properties": {
        "backend_response": {
          "maxLength": 49152,
          "type": [
            "string",
            "null"
          ]
        },
        "deliver": {
          "maxLength": 49152,
          "type": [
            "string",
            "null"
          ]
        },
        "recv": {
          "maxLength": 49152,
          "type": [
            "string",
            "null"
          ]
        }
      },
      "type": "object"
    },
    "site_id": {
      "minimum": 1,
      "type": "integer"
    },
    "varnish_version": {
      "description": "Compile on another version, e.g. 8.0.",
      "maxLength": 8,
      "type": "string"
    }
  },
  "required": [
    "site_id",
    "hooks"
  ],
  "type": "object"
}
```

## Refusals

- `varnish_not_offered`: the row is not a Magento 2 site.
- `invalid_arguments`: a malformed input, or a `varnish_version` that is not offered.
- `managed_elsewhere` (message: "This site is managed by another control panel"): another control panel manages this site, so use that control panel for it. This is refused before anything else about the site, as in the Control Panel and the API. Nothing was done.
- The refusals every tool can answer: `invalid_arguments`, `tenant_mismatch`, `scope_required`, `pin_refused`, `rate_limited`, `temporarily_unavailable`, `internal_error` (corestack://guides/how-this-server-works).

## Example

```json
{
  "name": "corestack_varnish_vcl_validate",
  "arguments": {
    "site_id": 4211,
    "hooks": {
      "recv": "if (req.url ~ \"^/stockcheck/\") {\n    return (pass);\n}\n"
    }
  }
}
```

## Prompt

```text
Using the Corefinity MCP server, call corestack_varnish_vcl_validate with site_id 4211, hooks {"recv":"if (req.url ~ \"^/stockcheck/\") {\n    return (pass);\n}\n"}. (Check custom Varnish VCL.) Tell me what it returned.
```

## The same task elsewhere

- Endpoint: [POST /api/corestack/sites/{site}/varnish/vcl/validate](https://docs.corefinity.com/api/reference/varnish/check-site-varnish-vcl.md)
- Guide: [Varnish](https://docs.corefinity.com/guides/sites/software-and-services/varnish.md)
