Skip to main content
Glama

Update Existing Diagram

diagrams_update
DestructiveIdempotent

Replace an existing PlantUML or Mermaid diagram file with new full content, after validating basic syntax to prevent overwriting invalid sources.

Instructions

Replace the full content of an existing PlantUML or Mermaid diagram file.

This performs a full-content replace, not a partial edit — pass the complete new diagram source. To create a new diagram, use diagrams_create (or set create_if_missing=true here).

Performs a basic, dependency-free syntax check before writing (not full validation): PlantUML must include @startuml/@enduml boundaries; Mermaid must start with a known diagram declaration. Clearly invalid or empty sources are rejected without overwriting the existing file.

Args:

  • relative_path (string): Path to the diagram, relative to the diagrams root

  • content (string): Full new diagram source text

  • create_if_missing (boolean): Create the file instead of erroring if it doesn't exist (default: false)

Returns: JSON with schema: { "relative_path": string, "updated": true }

Examples:

  • Use when: "Add a new field to the User class diagram" -> read current content with diagrams_get first, then call diagrams_update with the modified full content

  • Don't use when: The file doesn't exist yet and you don't want auto-creation (use diagrams_create)

Error Handling:

  • Returns "Error: No diagram found at ''" if the file doesn't exist and create_if_missing is false

  • Returns "Error: ... does not have a recognized diagram extension" if the extension isn't recognized

  • Returns "Error: Invalid PlantUML diagram (basic check): ..." if PlantUML source is empty or missing @startuml/@enduml boundaries (original file left unchanged)

  • Returns "Error: Invalid Mermaid diagram (basic check): ..." if Mermaid source is empty or has no recognized diagram declaration (original file left unchanged)

  • Returns "Error: Refused to access path outside the diagrams root" if relative_path attempts to escape the diagrams directory

  • Unexpected internal failures return a generic "Error: Unexpected internal error ..." with isError:true and are logged to stderr without source, paths, or secrets

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesNew full PlantUML or Mermaid source text that replaces the existing content.
relative_pathYesPath to the existing diagram, relative to the diagrams root.
create_if_missingNoIf true and no diagram exists at relative_path, create it instead of failing (default: false).

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

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

The description adds substantial behavior beyond the annotations: it discloses the pre-write syntax check, clarifies it is not full validation, states rejection conditions, and assures the original file is left unchanged on invalid input. This complements destructiveHint=true and idempotentHint=true without contradicting them.

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 long but well-structured with labeled sections, and the core behavior is front-loaded in the first paragraph. Every sentence serves a purpose, including the detailed error-handling list, which is practically useful for agents.

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 mutation tool with no output schema, the description is complete: it specifies the return shape, error cases, validation behavior, file-overwrite semantics, and sibling alternatives. An agent has enough information to invoke the tool correctly and anticipate failures.

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 description coverage is 100%, so the baseline is 3 even though the description mostly restates the parameter meanings. It does add mild context (e.g., 'pass the complete new diagram source' and create_if_missing behavior), but it does not uncover anything fundamentally beyond the 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 states a specific verb ('Replace') and resource ('existing PlantUML or Mermaid diagram file'), and explicitly clarifies it is a full-content replace rather than a partial edit. It differentiates itself from diagrams_create by naming the sibling tool and the create_if_missing alternative.

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?

Usage guidance is explicit: it says when to use this tool, when not to, and names alternatives. The 'Use when' and 'Don't use when' examples directly instruct agents to read current content with diagrams_get first and to prefer diagrams_create for new files unless auto-creation is desired.

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

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/mohammad-emad-dev/diagrams-mcp-server'

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