Skip to main content
Glama

Validate D2 Code

d2_validate
Read-onlyIdempotent

Catch syntax and semantic errors in D2 source code before rendering. Returns structured valid/error result using WASM, with no d2 binary required.

Instructions

Validate D2 diagram source code for syntax and semantic errors using the WASM engine.

Uses compile step to detect all errors without rendering. No d2 binary required.

Args:

  • d2_code (string): D2 source code to validate

Returns: JSON object: { "valid": boolean, // Whether the code is syntactically and semantically valid "error": string // Error message if invalid (omitted if valid) }

Examples:

  • Check before rendering: validate first, then d2_render only if valid=true

  • Debug syntax: get specific line/column error info

Error Handling:

  • Returns { valid: false, error: "..." } with specific error details

  • Never throws — always returns a structured result

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
d2_codeYesThe D2 diagram source code to validate

Schema Changelog

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

  1. First observedv1.0.0

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already mark it readOnly and idempotent; the description adds meaningful behavior beyond that: uses the WASM engine, performs a compile step, requires no d2 binary, and never throws but always returns a structured result. These details accurately shape agent expectations.

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 organized with clear sections: purpose, args, returns, examples, and error handling. Every sentence contributes useful information, and the core purpose is front-loaded.

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 single-parameter validation tool, this description is complete. It covers what the tool does, how it behaves, what it returns, error handling, and practical usage context. The absence of an output schema is compensated by an explicit return shape in the description.

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 schema already documents d2_code fully. The description repeats the parameter but adds no extra semantic detail beyond what the schema provides, such as max length or requiredness.

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?

Description states a specific verb ('Validate') and resource ('D2 diagram source code'), clarifies scope ('syntax and semantic errors'), and differentiates from siblings by noting it detects errors via compile step without rendering. This lets an agent distinguish it from d2_render and d2_format.

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?

Provides explicit guidance: 'validate first, then d2_render only if valid=true' and 'Debug syntax: get specific line/column error info.' This tells the agent both when to use the tool and how it fits with sibling tools.

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/ItsJooL/d2-mcp'

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