Skip to main content
Glama

Insert SVG fragment

insert_svg_fragment

Insert an SVG fragment into a document under a parent node or the root. Use to graft composed subtrees without file operations.

Instructions

Insert an agent-composed SVG fragment under a parent (parent_id) or the document root.

When to use: grafting one composed subtree into an existing document (no file round-trip). To REPLACE the whole document use set_document_svg; for a single typed shape use the create_* tools.

Key params: svg is ONE element subtree (wrap several siblings in a <g>). parent_id (must exist) sets where it lands, else the document root. unwrap (default True) controls a <svg> root: when True the wrapper <svg> is unwrapped and its children grafted (an empty wrapper is rejected); pass unwrap=False to KEEP an explicit nested <svg> container, inserted as-is (still allowlist-scrubbed; an empty nested <svg> is then allowed). unwrap has no effect on a non-<svg> root, which is always inserted intact. Same hardening as set_document_svg (safe-parse + strict allowlist; <script>, on* handlers, javascript: hrefs, external refs rejected; only same-document #id allowed). A real run REQUIRES a non-empty approval_token. The original/source file is never touched.

Return shape: ComposeResult — an EditResult (operation + pre-mutation snapshot links, reversible via restore_snapshot) extended with the post-adopt validate_document findings (validation).

Example: insert_svg_fragment(doc_id, "<g>...</g>", parent_id="layer1", approval_token="ok"); to keep a nested container: insert_svg_fragment(doc_id, "<svg>...</svg>", unwrap=False, approval_token="ok").

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: HIGH — requires a non-empty approval_token; without it the op is refused and nothing is written.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
svgYes
doc_idYes
unwrapNo
parent_idNo
approval_tokenNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
doc_idYes
changedYes
summaryNo
validationYesStructured, machine-readable validation result for one document. `ok` is True iff there are no `error`-severity findings. `error_count` / `warning_count` are convenience tallies over `findings`.
snapshot_idYes
operation_idYes
preview_afterNo
preview_beforeNo
Behavior5/5

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

Discloses key behaviors: hardening (safe-parse, strict allowlist), approval_token requirement, reversibility via restore_snapshot, original file untouched, return shape with validation. No annotation contradiction.

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

Conciseness4/5

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

Well-structured with sections for usage, parameters, return, example, and risk. Comprehensive but slightly lengthy; every sentence adds value so still highly efficient.

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?

Covers all aspects: purpose, usage, parameters, behavior, return value, examples, safety precautions. With output schema present, return shape is summarized appropriately.

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?

Adds significant meaning beyond schema: explains svg should be one element subtree, unwrap behavior with examples, parent_id requirement, approval_token necessity. Schema coverage is 0% so description fully compensates.

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?

Clearly states 'Insert an agent-composed SVG fragment under a parent or document root.' Distinguishes from siblings by mentioning set_document_svg for replacement and create_* tools for single shapes.

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?

Explicitly provides when to use (grafting composed subtree), when not (use set_document_svg for replace, create_* for single shapes), and suggests using render_preview before trusting.

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