Skip to main content
Glama

Execute Mermaid SDK code

execute
Read-only

Run JavaScript in an isolated sandbox; return a value. No promises, async/await, dynamic import, or type annotations. SVG/ASCII/layout enforce security:'strict', embedFontImport:false.

SDK: type DiagramKind='flowchart'|'state'|'sequence'|'timeline'|'class'|'er'|'journey'|'architecture'|'xychart'|'pie'|'quadrant'|'gantt'|'mindmap'|'gitgraph'|'radar'|'sankey'|'c4'|'packet'|'kanban'|'requirement'|'treemap'|'ishikawa'|'block'|'eventmodeling'|'zenuml' type MutationOp={kind:string;[field:string]:unknown} type Result<T,E={code:string;message:string}>={ok:true;value:T}|{ok:false;error:E} type ExternalFamilyId=family:${string};interface SourceLocation{readonly line:number;readonly col:number;}interface SourceMap{readonly nodes:ReadonlyMap<string,SourceLocation>;readonly edges:ReadonlyMap<string,SourceLocation>;readonly groups:ReadonlyMap<string,SourceLocation>;readonly labels:ReadonlyMap<string,SourceLocation>;readonly spans?:SourceMapSpans;}interface SourceMapSpans{readonly preserved:PreservedSourceSpans;readonly nodes:ReadonlyMap<string,SourceSpan>;readonly edges:ReadonlyMap<string,SourceSpan>;readonly groups:ReadonlyMap<string,SourceSpan>;readonly labels:ReadonlyMap<string,SourceSpan>;readonly metadata?:ReadonlyMap<string,ReadonlyMap<string,{readonly key:SourceSpan;readonly value:SourceSpan;}>>;}interface PreservedSourceSpans{readonly source:SourceSpan;readonly wrapper?:SourceSpan;readonly frontmatter?:SourceSpan;readonly initDirectives?:readonly SourceSpan[];readonly accessibilityDirectives?:readonly SourceSpan[];readonly header:SourceSpan;readonly body:SourceSpan;}interface SourceSpan{readonly start:SourceSpanPoint;readonly end:SourceSpanPoint;}interface SourceSpanPoint{readonly offset:number;readonly line:number;readonly col:number;}interface SourcePreservationReceipt{readonly version:1;readonly classification:'unsupported'|'inventory-only'|'unknown';readonly source:string;readonly header:string;readonly upstreamFamilyId?:string;readonly mermaidVersion:string;readonly spans?:PreservedSourceSpans;}interface ParseError{readonly code:string;readonly message:string;readonly line?:number;readonly col?:number;readonly preservation?:SourcePreservationReceipt;readonly help?:string;}type RenderedRegionKind='node'|'edge'|'label'|'canvas'|'group'|'cluster'|'lane'|'band'|'compartment'|'plot'|'ring';interface RenderedRegion{id:string;kind:RenderedRegionKind;elementId?:string;parentId?:string;bounds:{x:number;y:number;w:number;h:number;};cellSpans?:Array<{row:number;start:number;end:number;}>;occludedCellSpans?:Array<{row:number;start:number;end:number;}>;sourceLine?:number;}type DiagramActionKind='href'|'call'|'callback';type DiagramActionSecurity='safe'|'unsafe'|'source-only'|'unsupported';interface DiagramActionRecord{id?:string;regionId?:string;family:DiagramKind;target:string;action:DiagramActionKind;raw:string;line?:number;href?:string;tooltip?:string;security:DiagramActionSecurity;executable:false;message?:string;}interface LayoutRect{x:number;y:number;w:number;h:number;}interface ExtensionIdentity{readonly id:${Kind}:${string};readonly kind:Kind;readonly version:string;readonly compatibility:ExtensionCompatibility;readonly provenance:ExtensionProvenance;}interface ExtensionCompatibility{readonly[contract:string]:string|undefined;readonly core?:string;readonly scene?:string;}interface ExtensionProvenance{readonly owner:string;readonly source:string;readonly reference?:string;}type CheckMermaidSpec=readonly string[]|CheckMermaidObjectSpec;interface CheckMermaidObjectSpec{include?:readonly string[];exclude?:readonly string[];exact?:boolean;}interface CheckMermaidResult{ok:boolean;missing:string[];unexpected:string[];facts:string[];}interface CreateMermaidOptions{c4Variant?:C4Variant;direction?:Direction;}type C4Variant='C4Context'|'C4Container'|'C4Component'|'C4Dynamic'|'C4Deployment';type Direction='TD'|'TB'|'LR'|'BT'|'RL'; interface ValidDiagram{readonly kind:DiagramKind;readonly source:SourceMap} interface ExtensionValidDiagram{ readonly kind:ExternalFamilyId readonly descriptorIdentity:ExtensionIdentity<'family'> readonly source:SourceMap } interface PreservedValidDiagram{ readonly kind:ExternalFamilyId readonly source:SourceMap readonly body:{ readonly kind:'preserved' readonly representation:'opaque'|'unknown' readonly source:string readonly preservation:SourcePreservationReceipt readonly spans:PreservedSourceSpans readonly diagnostic:{ readonly code:'UNSUPPORTED_FAMILY'|'UNKNOWN_HEADER'|'FAMILY_DESCRIPTOR_MISMATCH' readonly message:string readonly help:string } } } type ParsedDiagram=ValidDiagram|ExtensionValidDiagram|PreservedValidDiagram type Narrow=(d:ParsedDiagram)=>ValidDiagram|null interface RenderedLayout{version:1;kind:DiagramKind|ExternalFamilyId;nodes:unknown[];edges:unknown[];groups:unknown[];labels?:Array<{id:string;text:string;bounds?:LayoutRect;container?:LayoutRect;visibility?:'visible'|'hidden'|'semantic'}>;regions?:RenderedRegion[];actions?:DiagramActionRecord[];bounds:{w:number;h:number}} interface ResolvedScene{version:2;family:string;width:number;height:number;svg:string} interface VerifyResult{ok:boolean;warnings:unknown[];layout:RenderedLayout;checks?:{renderability:'passed'|'failed'|'not-checked';sourceLoss:'detected'|'not-detected';taskCorrectness:'not-checked'}} type MermaidConfigScalar=string|number|boolean|null type MermaidConfigValue=MermaidConfigScalar|MermaidConfigValue[]|{[key:string]:MermaidConfigValue|undefined} type MermaidRuntimeConfig={[key:string]:MermaidConfigValue|undefined} interface StyleColors{bg?:string;fg?:string;line?:string;accent?:string;muted?:string;surface?:string;border?:string} type SceneStyleRole="node"|"edge"|"edge-label"|"group"|"group-header"|"label"|"actor"|"lifeline"|"activation"|"message"|"block"|"note"|"class-box"|"member"|"entity"|"attribute"|"relationship"|"cardinality"|"pie-slice"|"legend"|"bar"|"series"|"point"|"axis"|"grid"|"plate"|"section"|"task"|"milestone"|"marker-line"|"rail"|"period"|"event"|"score"|"actor-pill"|"service"|"junction"|"icon"|"title"|"defs"|"prelude"|"chrome" type ExactSceneStyleRole="node"|"edge"|"group"|"group-header"|"label"|"actor"|"relationship"|"pie-slice"|"legend"|"bar"|"series"|"point"|"task"|"milestone" type BindableSceneStyleRole="group-header"|"actor"|"relationship"|"pie-slice"|"legend"|"bar"|"series"|"point"|"task"|"milestone" type RoleStyleSpec={"fontFamily"?:string;"fontSize"?:number;"fontWeight"?:number;"letterSpacing"?:number;"textTransform"?:"uppercase"|"lowercase"|"capitalize";"textColor"?:string;"paddingX"?:number;"paddingY"?:number;"cornerRadius"?:number;"lineWidth"?:number;"bendRadius"?:number;"fillColor"?:string;"borderColor"?:string;"strokeColor"?:string;"headerFillColor"?:string;"cue"?:"none"|"outline"|"double-line"|"pattern"} type RoleStyleFor=R extends"node"|"actor"?Pick<RoleStyleSpec,"borderColor"|"cornerRadius"|"fillColor"|"fontSize"|"fontWeight"|"letterSpacing"|"lineWidth"|"paddingX"|"paddingY"|"textColor"|"textTransform">:R extends"edge"|"relationship"?Pick<RoleStyleSpec,"bendRadius"|"fontSize"|"fontWeight"|"letterSpacing"|"lineWidth"|"strokeColor"|"textColor"|"textTransform">:R extends"group"?Pick<RoleStyleSpec,"borderColor"|"cornerRadius"|"fillColor"|"fontFamily"|"fontSize"|"fontWeight"|"headerFillColor"|"letterSpacing"|"lineWidth"|"paddingX"|"paddingY"|"textColor"|"textTransform">:R extends"group-header"?Pick<RoleStyleSpec,"borderColor"|"cue"|"fillColor"|"fontFamily"|"fontSize"|"fontWeight"|"letterSpacing"|"lineWidth"|"strokeColor"|"textColor"|"textTransform">:R extends"label"?Pick<RoleStyleSpec,"fontSize"|"fontWeight"|"letterSpacing"|"textColor"|"textTransform">:R extends"pie-slice"|"task"|"milestone"?Pick<RoleStyleSpec,"borderColor"|"cue"|"fillColor"|"lineWidth"|"strokeColor">:R extends"legend"?Pick<RoleStyleSpec,"borderColor"|"fillColor"|"lineWidth"|"strokeColor"|"textColor">:R extends"bar"|"point"?Pick<RoleStyleSpec,"borderColor"|"fillColor"|"lineWidth"|"strokeColor">:R extends"series"?Pick<RoleStyleSpec,"borderColor"|"lineWidth"|"strokeColor">:never type RoleStyles={[R in ExactSceneStyleRole]?:Readonly<RoleStyleFor>} type SemanticBindingChannel="category" interface SemanticBinding{channel:SemanticBindingChannel;value:string;slot:string;role?:BindableSceneStyleRole} type BrandConstraint={kind:"contrast";action:'warn'|'error';role?:SceneStyleRole;minimum?:number}|{kind:"accent-area";action:'warn'|'error';maxFraction:number}|{kind:"mono-role";action:'warn'|'error';role:SceneStyleRole} interface StyleSpec{"formatVersion"?:1;"$schema"?:string;"name"?:string;"blurb"?:string;"colors"?:StyleColors;"font"?:string;"roles"?:RoleStyles;"semanticSlots"?:Readonly<Record<string,Readonly>>;"bindings"?:readonly SemanticBinding[];"constraints"?:readonly BrandConstraint[];"stroke"?:"crisp"|"jittered"|"freehand";"roughness"?:number;"bowing"?:number;"passes"?:number;"strokeWidth"?:number;"fill"?:"none"|"hachure"|"solid"|"wash";"hachureAngle"?:number;"hachureGap"?:number;"fillWeight"?:number;"washOpacity"?:number;"washEdge"?:number;"backdrop"?:"plain"|"paper-ruled"|"grid";"intent"?:"premium"|"draft"|"lofi";"mono"?:boolean} type StyleInput=string|StyleSpec type ArchitectureVisualOverrides=Readonly<Record<string,unknown>> interface SharedRenderOptions{layoutHints?:{ranks?:Record<string,number>;adjacent?:string[][];shortEdges?:string[]};graphLayout?:{backend:'elk'|'agentic';fallback?:'none'|'elk'};layoutSafety?:'report'|'strict';bg?:string;fg?:string;line?:string;accent?:string;muted?:string;surface?:string;border?:string;font?:string;style?:StyleInput|StyleInput[];padding?:number;nodeSpacing?:number;layerSpacing?:number;wrappingWidth?:number;componentSpacing?:number;transparent?:boolean;interactive?:boolean;shadow?:boolean;class?:{hierarchicalNamespaces?:boolean};kanban?:{maxWidth?:number};pie?:{maxWidth?:number};radar?:{maxWidth?:number};architecture?:{visual?:ArchitectureVisualOverrides};timeline?:{maxWidth?:number};journey?:{experienceCurve?:boolean};gantt?:{dependencyArrows?:boolean;criticalPath?:boolean};mermaidConfig?:MermaidRuntimeConfig;embedFontImport?:boolean;compact?:boolean;idPrefix?:string;security?:'default'|'strict';ganttToday?:string;seed?:number;} interface ConfigDiagnostic{code:'INEFFECTIVE_CONFIG';field:string;message:string} interface TerminalProjectionDiagnostic{code:string;feature:string;message:string;cell?:{column:number;row:number}} interface SvgRenderOptions extends SharedRenderOptions{onConfigDiagnostic?:(diagnostic:ConfigDiagnostic)=>void;} interface AsciiRenderOptions extends SharedRenderOptions{useAscii?:boolean;paddingX?:number;paddingY?:number;boxBorderPadding?:number;colorMode?:'auto'|'none'|'ansi16'|'ansi256'|'truecolor'|'html';theme?:{fg?:string;border?:string;line?:string;arrow?:string;accent?:string;bg?:string;corner?:string;junction?:string};maxWidth?:number;targetWidth?:number;onConfigDiagnostic?:(diagnostic:ConfigDiagnostic)=>void;onProjectionDiagnostic?:(diagnostic:TerminalProjectionDiagnostic)=>void;} interface LayoutRenderOptions extends SharedRenderOptions{debug?:boolean;regions?:boolean;actions?:boolean;onConfigDiagnostic?:(diagnostic:ConfigDiagnostic)=>void;} interface RenderArtifactDiagnostic{code:string;message?:string;reference?:string;feature?:string;input?:string;canonicalId?:string;removal?:{release:string;date:string}} interface CapabilityResolution{readonly id:${string}:${string};readonly range:string;readonly level:'required'|'preferred'|'optional';readonly status:'selected'|'unsupported'|'incompatible';readonly version?:string} type CapabilityDecision=Readonly<{version:1;accepted:boolean;resolutions:readonly CapabilityResolution[]}>;interface RenderExecutionDecision{readonly family:{readonly id:string;readonly version:string};readonly backend:{readonly mode:'scene';readonly requestedId:string;readonly selectedId:string;readonly version:string;readonly hostPolicy:boolean}|{readonly mode:'family-svg'};readonly digest:string;} type GraphLayoutDecision=Readonly<{requested:'elk'|'agentic';fallback:'none'|'elk';selected:'elk'|'agentic';reason?:string;attempts:readonly Readonly<{backend:'elk'|'agentic';outcome:'selected'|'unsupported'|'candidate-rejected';reason?:string}>[];implementation:string;role?:'primary'|'companion'}>;interface RenderRequestReceipt{version:2;output:'svg'|'png'|'ascii'|'unicode'|'html'|'layout';sharedRequestDigest:string;requestDigest:string;appearanceDigest:string;capabilityDecision:CapabilityDecision;diagnostics?:readonly RenderArtifactDiagnostic[];graphicalProjectionDigest?:string;executionDecision?:RenderExecutionDecision;layoutDecisions?:readonly GraphLayoutDecision[]} interface RenderedSvg{svg:string;receipt:RenderRequestReceipt} interface RenderedAscii{text:string;receipt:RenderRequestReceipt;terminalStyle:Record<string,unknown>;outputPolicy:Record<string,unknown>} interface RenderedLayoutArtifact{layout:VerifyResult['layout'];receipt:RenderRequestReceipt} declare const mermaid:Record<'asFlowchart'|'asState'|'asSequence'|'asTimeline'|'asClass'|'asEr'|'asJourney'|'asArchitecture'|'asXyChart'|'asPie'|'asQuadrant'|'asGantt'|'asMindmap'|'asGitGraph'|'asRadar'|'asSankey'|'asC4'|'asPacket'|'asKanban'|'asRequirement'|'asTreemap'|'asIshikawa'|'asBlock'|'asEventModeling'|'asZenUML',Narrow>&{ parseRegisteredMermaid(source:string):Result<ParsedDiagram,ParseError[]> createMermaid(kind:DiagramKind,opts?:CreateMermaidOptions):ValidDiagram buildMermaid(kind:DiagramKind,ops:MutationOp[],opts?:CreateMermaidOptions):Result<ValidDiagram,{code:string;message:string;opIndex:number}> mutate(diagram:ValidDiagram,op:MutationOp):Result //Opaque Class:add_member/remove_member;Flowchart:set_label/rename_node.Save source;warnings remain. mutatePreservingSource(d:ParsedDiagram,op:MutationOp):Result<{source:string;diagram:ParsedDiagram}> verifyMermaid(input:ParsedDiagram|string,opts?:{suppress?:string[];labelCharCap?:number;renderOptions?:SharedRenderOptions}):VerifyResult analyzeMermaid(diagram:ValidDiagram):Record<string,unknown> analyzeMermaidSource(source:string):Result<Record<string,unknown>> describeMermaidFacts(diagram:ValidDiagram):string[] describeMermaidFactsSource(source:string):Result<string[]> checkMermaid(diagram:ValidDiagram,spec:CheckMermaidSpec):CheckMermaidResult checkMermaidSource(source:string,spec:CheckMermaidSpec):Result serializeMermaid(diagram:ParsedDiagram):string renderResolvedScene(input:ParsedDiagram|string,opts?:SvgRenderOptions):ResolvedScene renderMermaidSVG(input:ParsedDiagram|string,opts?:SvgRenderOptions):string renderMermaidSVGWithReceipt(input:ParsedDiagram|string,opts?:SvgRenderOptions):RenderedSvg renderMermaidASCII(input:ParsedDiagram|string,opts?:AsciiRenderOptions):string renderMermaidASCIIWithReceipt(input:ParsedDiagram|string,opts?:AsciiRenderOptions):RenderedAscii layoutMermaidWithReceipt(input:ParsedDiagram|string,opts?:LayoutRenderOptions):RenderedLayoutArtifact describeOps(family:DiagramKind):Record<string,{name:string;required:boolean;type:string;note?:string}[]> opSignatures(family:DiagramKind):string[] }

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "execute"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesJavaScript to execute; mermaid.* SDK is global.
timeoutMsNoOptional CPU-time budget (default 5000ms, max 30000ms).

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / additionalProperties
      Added value: +false
  2. Changed2 schema fields changed
    • addedInput schema / properties / timeoutMs / minimum
      Added value: +1
    • changedInput schema / properties / timeoutMs / type
      Previous value: -"number"New value: +"integer"
  3. First observed

TDQS

B3.1/5.0
Behavior4/5

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

Annotations already declare readOnly, non-destructive, closed-world behavior, so the safety profile is covered. The description adds genuinely useful execution constraints an agent could not otherwise know: no promises/async/await/dynamic import/type annotations, plus enforced security:'strict' and embedFontImport:false. It stops short of describing failure behavior (throw vs. Result envelope) or what 'return a value' permits.

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

Conciseness2/5

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

The first two sentences are well front-loaded and earn their place, but they are followed by thousands of tokens of raw TypeScript interface and type declarations that no agent needs in order to select or invoke the tool. The signal-to-noise ratio is poor and the payload is wildly disproportionate to a two-parameter tool.

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

Completeness2/5

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

There is no output schema, and the description does not explain the return contract — whether the agent must use an explicit return statement, what serialization applies to returned values, or how sandbox errors and timeouts surface. It over-invests in SDK type surface while under-specifying the actual call-and-return contract for a high-complexity execution tool.

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 coverage is 100% — both code and timeoutMs are described in the schema, including the 5000ms default and 30000ms cap. The description's SDK listing adds indirect meaning about what code may call (the mermaid global surface), but it never explicitly addresses the parameters, so the baseline 3 applies.

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

Purpose4/5

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

The opening line gives a specific verb and resource: 'Run JavaScript in an isolated sandbox; return a value,' and immediately scopes the runtime ('mermaid.* SDK is global'). It is clear what the tool does, but it never distinguishes itself from siblings like build, mutate, render_svg, or verify, which all appear to be narrower entry points into the same SDK.

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

Usage Guidelines2/5

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

There is no guidance on when to reach for execute versus the sibling tools that wrap the same SDK (render_svg, verify, mutate, build). The description lists runtime restrictions but never states a selection rule such as 'use this for custom multi-step SDK workflows' or 'prefer render_svg for a single render.'

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.