scan_container
MCP tool that audits a GTM JSON export passed in the call. No page fetch, no GTM-ID lookup.
On this page 6
Summary
- tool —
scan_container - purpose — audit a GTM container passed as JSON; nothing is fetched
- rest equivalent —
POST /v1/scan(same rule engine; the REST response has nofindings_shownand returns all findings unlesstop_nis set) - rate limit — 200/day per user
- synchronous — yes
The MCP tool that audits a GTM container you already have. It runs the same rule engine as scan_url and returns the same result shape. Nothing is fetched, so container.from_cache is always null.
When to use it
Use scan_container when the container JSON is in the conversation, for example a GTM export the user uploaded or pasted. With only a URL or a GTM ID, use scan_url; it fetches and parses the container for you. To run one named rule, use evaluate_rule.
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
data | object | required | The GTM JSON export exactly as downloaded from GTM (it has a containerVersion key), or container data already parsed by TagManifest (it has tags, triggers and variables arrays). |
category | string | optional | Return only findings in one category: consent, ga4, ads, ecommerce, security, pii, performance, quality, organization, dead-code. |
tier | string | optional | Return only findings in one tier: error, warning, optimization, info. |
top_n | number | optional | Maximum findings to return, most important first (by tier, then severity). Default 25. 0 returns the totals and no findings. |
Synchronous. The tool returns when the audit completes. No polling, no webhooks. No network fetch takes place.
Returns
The tool result is one text block. Its text is a JSON object with the same fields as scan_url: container, health_score, findings_total, findings_shown, findings_truncated, by_category, by_tier, then findings. The health score and the totals come before the findings list.
container.gtm_id and container.name are read from the export. container.from_cache is always null, because no container is fetched.
The example below is the result for a small test container with ten findings, called with top_n: 3.
Full result
{
"container": {
"gtm_id": "GTM-EXAMPLE",
"name": "Example container",
"tag_count": 4,
"trigger_count": 1,
"variable_count": 0,
"from_cache": null
},
"health_score": {
"score": 49,
"grade": "D",
"label": "Patterns Found",
"deductions": {
"error": 32,
"warning": 8,
"optimization": 11,
"info": 0,
"byCategory": {
"ga4": 3,
"security": 2,
"ads": 2,
"consent": 2
}
},
"caps": {
"error": 35,
"warning": 20,
"optimization": 25,
"info": 0
},
"functionalIssueCount": 9
},
"findings_total": 10,
"findings_shown": 3,
"findings_truncated": true,
"by_category": {
"ga4": 4,
"security": 2,
"ads": 2,
"consent": 2
},
"by_tier": {
"error": 4,
"warning": 2,
"optimization": 3,
"info": 1
},
"findings": [
{
"rule_id": "ga4-param-pii-risk",
"title": "GA4 event parameters with PII-risk names",
"severity": "critical",
"tier": "error",
"category": "ga4",
"finding_count": 1,
"affected_items": [
{ "id": "2", "name": "GA4 - Contact form", "piiParams": ["email"] }
],
"affected_items_total": 1,
"action": "Remove PII parameters",
"recommendation": "Remove PII parameters entirely, or rename them to non-PII names and hash the values with SHA-256 before sending."
},
{
"rule_id": "ga4-pii-parameter-names",
"title": "GA4 parameters with PII-suggesting names",
"severity": "critical",
"tier": "error",
"category": "ga4",
"finding_count": 1,
"affected_items": [
{ "id": "2", "name": "GA4 - Contact form", "piiParams": ["email"] }
],
"affected_items_total": 1,
"action": "Remove or hash PII data",
"recommendation": "Remove PII parameters, or hash them with SHA-256 before sending. Ensure any user-provided data sent to GA4 is properly anonymized."
},
{
"rule_id": "eval-usage",
"title": "eval() usage detected",
"severity": "high",
"tier": "error",
"category": "security",
"finding_count": 1,
"affected_items": [
{ "id": "4", "name": "Legacy chat widget" }
],
"affected_items_total": 1,
"action": "Remove eval() usage",
"recommendation": "Refactor to avoid eval(). Use JSON.parse() for data, or restructure the logic to avoid dynamic code execution."
}
]
}
In health_score, caps is the most each tier can take off the score: 35 for errors, 20 for warnings, 25 for optimizations, 0 for info. deductions.byCategory counts the findings that fed the score in each category. It is a count, not points. See Health score.
Errors
- Bad arguments come back as a JSON-RPC error with code
-32602. This covers a missingdata, an argument the tool does not accept (for examplecategoriesforcategory; the message suggests the nearest name), acategoryortiervalue that does not exist, atop_nthat is negative or not a number, and adatathat is not an object. These are checked before the rate limit, so they do not count against it. - A scan that fails comes back as a normal tool result with
isError: trueand a plain message in the text block. The usual cause is adataobject that is not a GTM container: it must be a GTM export (withcontainerVersion) or a parsed container. These calls do count against the rate limit. - Rate limit comes back as a JSON-RPC error with code
-32603and the messageRate limit exceeded for scan_container: 201/200. Resets at <time>.The HTTP status is 200. MCP responses carry noX-RateLimit-*headers. The limit resets at midnight UTC.
Try saying
Natural-language prompts that route to this tool through an agent:
- "I've uploaded my GTM export. Can you audit it for consent issues?"
- "Here's my container JSON. What's the health score and what are the top errors?"
- "Scan this GTM file and show only the
ga4findings."
For agents wired to your own application:
You have access to TagManifest's MCP server. Use the scan_container
tool to audit a GTM container JSON the user provides. The tool
requires a `data` object (the GTM export, as downloaded) and optionally
accepts `category`, `tier`, and `top_n` (default 25). The result starts
with the health score and findings_total, then lists findings most
important first (by tier, then severity).
See also
- scan_url — audit by URL or GTM ID when you don't have the JSON in hand
- evaluate_rule — run a single rule against a container
- Health score — how findings translate to the score
Examples
{
"tool": "scan_container",
"arguments": {
"data": {
"exportFormatVersion": 2,
"containerVersion": {
"container": { "publicId": "GTM-EXAMPLE", "name": "Example container" },
"tag": [],
"trigger": [],
"variable": []
}
},
"top_n": 3
}
}
{
"container": {
"gtm_id": "GTM-EXAMPLE",
"name": "Example container",
"tag_count": 4,
"trigger_count": 1,
"variable_count": 0,
"from_cache": null
},
"health_score": {
"score": 49,
"grade": "D",
"label": "Patterns Found",
"deductions": {
"error": 32,
"warning": 8,
"optimization": 11,
"info": 0,
"byCategory": {
"ga4": 3,
"security": 2,
"ads": 2,
"consent": 2
}
},
"caps": {
"error": 35,
"warning": 20,
"optimization": 25,
"info": 0
},
"functionalIssueCount": 9
},
"findings_total": 10,
"findings_shown": 3,
"findings_truncated": true,
"by_category": {
"ga4": 4,
"security": 2,
"ads": 2,
"consent": 2
},
"by_tier": {
"error": 4,
"warning": 2,
"optimization": 3,
"info": 1
},
"findings": [
{
"rule_id": "ga4-param-pii-risk",
"title": "GA4 event parameters with PII-risk names",
"severity": "critical",
"tier": "error",
"category": "ga4",
"finding_count": 1,
"affected_items": [
{
"id": "2",
"name": "GA4 - Contact form",
"piiParams": [
"email"
]
}
],
"affected_items_total": 1,
"action": "Remove PII parameters",
"recommendation": "Remove PII parameters entirely, or rename them to non-PII names and hash the values with SHA-256 before sending."
},
{
"rule_id": "ga4-pii-parameter-names",
"title": "GA4 parameters with PII-suggesting names",
"severity": "critical",
"tier": "error",
"category": "ga4",
"finding_count": 1,
"affected_items": [
{
"id": "2",
"name": "GA4 - Contact form",
"piiParams": [
"email"
]
}
],
"affected_items_total": 1,
"action": "Remove or hash PII data",
"recommendation": "Remove PII parameters, or hash them with SHA-256 before sending. Ensure any user-provided data sent to GA4 is properly anonymized."
},
{
"rule_id": "eval-usage",
"title": "eval() usage detected",
"severity": "high",
"tier": "error",
"category": "security",
"finding_count": 1,
"affected_items": [
{
"id": "4",
"name": "Legacy chat widget"
}
],
"affected_items_total": 1,
"action": "Remove eval() usage",
"recommendation": "Refactor to avoid eval(). Use JSON.parse() for data, or restructure the logic to avoid dynamic code execution."
}
]
}