Skip to main content
Glama

sanitize_svg

Removes XSS payloads, scripts, event listeners, external entities, and XML bombs from untrusted SVG strings so they can be safely embedded or processed.

Instructions

Sanitize an untrusted SVG string to eliminate XSS attacks, scripts, event listeners (onload, onclick), external entity injections, and XML bombs.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "svg": "<svg>"
    },
    "name": "sanitize_svg"
  }
}

Input Schema

NameRequiredDescriptionDefault
svgYesThe raw SVG markup string to sanitize (max 512KB).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.1

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden, and it does disclose the specific classes of content stripped, which is genuine added context. However, it does not say whether offending content is removed versus causing an error, whether malformed SVG is rejected, or whether output is safe to re-sanitize — meaningful gaps for a security-relevant transform.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One front-loaded sentence with no filler; the threat enumeration is dense but each item contributes distinct information about scope. Nothing could be removed without losing content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, so the description should indicate what comes back — the sanitized markup string, a cleaned copy plus a list of removed nodes, or a pass/fail verdict. Without that, an agent knows the input contract but not the return shape or failure mode.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and the single parameter already documents itself as raw SVG markup capped at 512KB, so the description adds no meaning beyond it. Baseline 3 applies when the schema fully documents the inputs.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb and resource ("Sanitize an untrusted SVG string") and enumerates the threat classes removed (XSS, scripts, event listeners, external entities, XML bombs), which makes the function unambiguous. It does not explicitly contrast itself with the icon-retrieval siblings, but the operation is obviously distinct from search_icons or svg_to_data_uri.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The word "untrusted" implies the intended trigger — sanitize before embedding user-supplied markup — but the description never states when to use this versus svg_to_data_uri, nor any exclusions or ordering constraints. Usage must be inferred from the adjective rather than from explicit guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.