Skip to main content
Glama

Optimize SVG for web

svg_web_optimize

Web-optimize SVG by removing Inkscape editor elements, unused definitions, and rounding coordinates to reduce file size losslessly.

Instructions

Web-optimize an SVG: strip editor metadata, drop dead structure, reduce coordinate precision.

When to use: losslessly shrinking an SVG for the web (direct-DOM, non-destructive). To inspect what WOULD be stripped first use quality_report; for lossy node reduction use simplify_path.

Key params: three reversible cleanups — (1) remove Inkscape/sodipodi editor-only elements, namespaced attributes, and XML comments; (2) drop unreferenced <defs>, every unreferenced id, and empty groups (referenced ids preserved so no #frag / url(#frag) / href breaks); (3) round geometry numbers (path d, transforms, x/y/width/…) to precision decimals (0-8, default 2; root viewBox untouched). keep_ids is an allowlist of ids that must NEVER be stripped as "unreferenced" — pass a deliberate human/a11y id (e.g. one from rename_object) to keep "one clean file with a stable id"; unknown ids are ignored. Re-running on optimized output removes/rounds nothing further.

Return shape: WebOptimizeResult — the reversible-edit fields (operation_id, snapshot_id, before/after preview) plus machine-diffable deltas bytes_before, bytes_after, and removed (a {code: count} map keyed IDENTICALLY to quality_report.opportunities), so an agent on a byte budget can compute the saving without parsing prose or stat-ing the file.

Example: svg_web_optimize(doc_id, precision=2, keep_ids=["header"])

Render and look before you trust this edit: render with render_preview (or live_render_view) and inspect the result before relying on it; restore_snapshot reverts it if it is wrong.

Risk class: medium.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doc_idYes
keep_idsNo
precisionNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
doc_idYes
changedYes
removedYes
summaryNo
bytes_afterYes
snapshot_idYes
bytes_beforeYes
operation_idYes
preview_afterNo
preview_beforeNo
Behavior5/5

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

Beyond annotations, the description details the exact transformations: removal of editor metadata, unreferenced defs/ids, and coordinate rounding. It notes that re-running does nothing further, implying idempotency, and states the risk class as 'medium.' It also mentions the result is reversible via snapshots, which the annotations do not cover. This provides rich behavioral context for safe invocation.

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?

The description is well-structured and front-loaded with a one-line summary. Each section serves a purpose: when to use, key parameters, return shape, example, and safety advice. Every sentence earns its place without redundancy. The length is appropriate for the tool's complexity.

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?

Given the tool's complexity, the description covers all necessary aspects: purpose, usage, parameters, behavior, idempotency, return shape, and risk. The output schema is referenced but not detailed, which is acceptable. The description is self-contained enough for an agent to select and invoke the tool correctly without external documentation.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by explaining each parameter: `precision` (rounding decimals 0-8, default 2), `keep_ids` (allowlist to preserve ids, unknown ids ignored), and `doc_id` (implied via example). It also clarifies the effect of re-running, which is crucial for idempotence. This adds significant meaning beyond the raw schema.

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?

The description clearly states the tool's purpose: 'Web-optimize an SVG: strip editor metadata, drop dead structure, reduce coordinate precision.' It distinguishes from siblings by explicitly mentioning alternatives: 'To inspect what WOULD be stripped first use `quality_report`; for lossy node reduction use `simplify_path`.' The verb 'optimize' combined with specific actions makes the purpose unambiguous.

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?

The description explicitly states when to use this tool: 'losslessly shrinking an SVG for the web (direct-DOM, non-destructive).' It also provides clear alternatives and conditions: 'To inspect what WOULD be stripped first use `quality_report`; for lossy node reduction use `simplify_path`.' Additionally, it advises to 'render and look before you trust this edit' and mentions `restore_snapshot` for reversion, offering complete usage context.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jjjsood/inkscape-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server