Skip to main content
Glama

Upload SVG markup to Card Builder media

card_builder_upload_svg
DestructiveIdempotent

Sanitize SVG markup and upload it to the Card Builder media directory, returning a reference URI. Use for publishing generated or hand-written SVG as media.

Instructions

Sanitize SVG markup and upload it to the Card Builder media directory.

svg_content must start with <svg or <?xml. .svg is appended to filename if missing; the result is stored under www/card_builder/<path>/<filename>. svg_content is always sanitized first: <script>, <style>, <foreignObject>, <iframe>, <embed>, <object> and other non-presentation elements are stripped with their subtree, along with every on*= handler and any href/xlink:href pointing at javascript: or an external/ data:image/svg+xml URL — see sanitize_svg for the allowlist. This matters because the file becomes public, unauthenticated, under /local/, where an unsanitized SVG opened directly executes embedded script as stored XSS into an admin session. _write_media_file writes with no existence check, so uploading onto an existing path/ filename silently overwrites it, with no backup.

Use when: publishing generated or hand-written SVG markup as media. Not for: an SVG file on disk — use card_builder_upload_media_from_path; a remote SVG URL — use card_builder_upload_image_from_url. Returns: {reference, path, url} — reference is the cb-media://local/card_builder/<filename> URI for a block-image's mediaReference prop. Errors: {"error": "not_svg" | "file_too_large" | "path_not_allowed" | "svg_too_complex"} on invalid, unsafe, or oversized input. Limits: capped at _MAX_MEDIA_UPLOAD_BYTES (15 MiB), then _SVG_MAX_ELEMENTS elements after parsing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoSub-folder under www/card_builder/ to upload into. Empty string uploads to the root.
filenameYesBare target filename, e.g. 'gradient-bg'. '.svg' is appended if missing.
svg_contentYesRaw SVG markup, starting with '<svg' or '<?xml ...'.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv0.25.1
    • addedInput schema / properties / filename / description
      Added value: +"Bare target filename, e.g. 'gradient-bg'. '.svg' is appended if missing."
    • addedInput schema / properties / path / description
      Added value: +"Sub-folder under www/card_builder/ to upload into. Empty string uploads to the root."
    • addedInput schema / properties / svg_content / description
      Added value: +"Raw SVG markup, starting with '<svg' or '<?xml ...'."
  2. Addedv0.18.1

TDQS

A4.9/5.0
Behavior5/5

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

Goes well beyond the annotations (readOnlyHint=false, destructiveHint=true, idempotentHint=true): it names the elements/attributes stripped during sanitization, explains the public-unauthenticated stored-XSS consequence that motivates it, and warns that _write_media_file performs no existence check so re-uploading silently overwrites with no backup. Operational limits (15 MiB, _SVG_MAX_ELEMENTS) and the exact error codes are also disclosed.

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?

Long but front-loaded and segmented with explicit 'Use when:', 'Not for:', 'Returns:', 'Errors:' and 'Limits:' markers, so an agent can stop reading after the first sentence if it only needs the gist. Every sentence carries distinct information; the security rationale earns its length by justifying the sanitization behavior.

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

Completeness5/5

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

For a destructive, security-sensitive write tool, the description covers prerequisites (svg_content format), side effects (sanitization, silent overwrite), limits, error codes, and the return shape's use for a block-image mediaReference prop. Even though an output schema exists, the extra detail on the reference URI adds task-level context rather than redundancy.

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

Parameters4/5

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

Schema description coverage is 100%, so baseline is 3, but the description still adds value: it specifies the resulting storage location 'www/card_builder/<path>/<filename>' and the sanitization applied to svg_content. The remaining param facts ('.svg' auto-append, '<svg'/'<?xml' prefix) largely restate the schema, so it only modestly exceeds baseline.

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

Purpose5/5

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

States a precise verb+resource ('Sanitize SVG markup and upload it to the Card Builder media directory') and draws boundaries against two named siblings ('an SVG file on disk — use card_builder_upload_media_from_path; a remote SVG URL — use card_builder_upload_image_from_url'). An agent can identify and disambiguate this tool without opening any schema.

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

Usage Guidelines5/5

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

Explicit 'Use when: publishing generated or hand-written SVG markup as media' plus an explicit 'Not for:' clause routing to card_builder_upload_media_from_path and card_builder_upload_image_from_url. The condition that selects each alternative is stated, leaving nothing to inference.

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

Deploy Server

Other Tools