Skip to main content
Glama

Word Cloud

render_wordcloud_chart
Read-onlyIdempotent

Visualizes word frequency as a word cloud to identify dominant themes from survey responses, keywords, or topic frequency.

Instructions

Render a word cloud - 'What are the dominant themes?' Words sized by frequency or importance. Great for survey responses, keyword analysis, topic frequency.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesChart title
dataYesArray of words with values
optionsNo
themeNoTheme preset: boardroom, corporate, sales-floor, golden-treasury, clinical, startup, ops-control, tokyo-midnight, zen-garden, consultant, black-tron, black-elegance, black-matrix, forest-amber, forest-earth, sky-light, sky-ocean, sky-twilight, gray-hf, gray-copilot
paletteNoOverride palette only (mix-and-match)
typographyNoOverride typography: professional, luxury, cyberpunk, editorial, mono, bold, system, techno
effectsNoOverride effects: none, subtle, shimmer, neon, energetic

Implementation Reference

  • The main handler function that renders a word cloud chart. It builds the HTML card layout, creates a Chart.js wordCloud instance (using chartjs-chart-wordcloud), scales font sizes linearly between 12-48px based on data values, and registers click/tooltip/export/refresh functionality.
    export function renderWordCloudChart(container: HTMLElement, payload: WordCloudData): void {
      const { title, data, options } = payload;
    
      const theme = resolveTheme(payload.theme, {
        palette: payload.palette,
        typography: payload.typography,
        effects: payload.effects,
      });
      if (theme) applyTheme(container, theme);
    
      container.innerHTML = `
        <div class="chart-view">
          <div class="card chart-card">
            <div class="chart-card__header">
              <div>
                <div class="chart-card__title${theme?.effects.shimmerTitle ? " shimmer-text" : ""}">${escapeHtml(title)}</div>
                <div class="chart-card__subtitle">${data.length} words</div>
              </div>
            </div>
            <div class="chart-card__body">
              <canvas id="chart-canvas"></canvas>
            </div>
          </div>
        </div>
      `;
    
      const canvas = container.querySelector<HTMLCanvasElement>("#chart-canvas")!;
      const palette = resolveColors(options.colors, Math.min(data.length, 10));
    
      // Scale font sizes: largest word = 48px, smallest = 12px
      const maxVal = Math.max(...data.map(d => d.value));
      const minVal = Math.min(...data.map(d => d.value));
      const range = maxVal - minVal || 1;
    
      const chartInstance = new Chart(canvas, {
        type: "wordCloud" as any,
        data: {
          labels: data.map(d => d.text),
          datasets: [{
            data: data.map(d => 12 + ((d.value - minVal) / range) * 36),
            color: data.map((_, i) => palette[i % palette.length]),
          }],
        },
        options: {
          responsive: true,
          maintainAspectRatio: false,
          onClick: (_event, elements) => {
            if (elements.length === 0) return;
            const idx = elements[0].index;
            const item = data[idx];
            if (item) sendClickMessage(`"${item.text}": ${item.value} in "${title}"`);
          },
          plugins: {
            legend: { display: false },
            tooltip: {
              ...tooltipStyle(),
              callbacks: {
                label: (ctx: any) => {
                  const item = data[ctx.dataIndex];
                  return item ? `${item.text}: ${item.value.toLocaleString()}` : "";
                },
              },
            },
          },
        },
      });
    
      deferResize(chartInstance);
      addExportButton(container, chartInstance, title);
      addRefreshButton(container, () => (window as any).__mcpRefresh?.());
    }
  • WordCloudData interface defining the input schema: type ('wordcloud'), title, data (array of WordItem with text/value), options (optional colors), theme, palette, typography, effects.
    interface WordCloudData {
      type: "wordcloud";
      title: string;
      data: WordItem[];
      options: {
        colors?: string[];
      };
      theme?: string;
      palette?: string;
      typography?: string;
      effects?: string;
    }
  • Registers the wordcloud chart type under the tool name 'render_wordcloud_chart' via registerChart(). This maps the 'wordcloud' type from the server response to the render function.
    registerChart("wordcloud", "render_wordcloud_chart", renderWordCloudChart);
  • The registerChart function in shared.ts that manages the chart registry. When the server returns data with type 'wordcloud', the app dispatches to the registered handler via getChartEntry().
    export function registerChart(
      type: string,
      toolName: string,
      render: (root: HTMLElement, data: any) => void,
    ): void {
      CHART_REGISTRY[type] = { toolName, render };
    }
    
    export function getChartEntry(type: string): ChartEntry | undefined {
      return CHART_REGISTRY[type];
    }
    
    export function getTypeToToolMap(): Record<string, string> {
      const map: Record<string, string> = {};
      for (const [type, entry] of Object.entries(CHART_REGISTRY)) {
        map[type] = entry.toolName;
      }
      return map;
    }
  • app.ts handles ontoolresult: parses the server response, looks up the 'wordcloud' type in the chart registry (via getTypeToToolMap/getChartEntry), and calls entry.render (which is renderWordCloudChart).
    app.ontoolinput = (params) => {
      _pendingArgs = (params as any).arguments ?? null;
    };
    
    app.ontoolresult = (result) => {
      // Try structuredContent first, fall back to parsing JSON from content
      let data = (result as any).structuredContent;
      if (!data?.type) {
        const texts = (result as any).content?.filter(
          (c: any) => c.type === "text"
        ) ?? [];
        for (const t of texts) {
          try {
            const parsed = JSON.parse(t.text);
            if (parsed?.type) { data = parsed; break; }
          } catch { /* not JSON, skip */ }
        }
      }
    
      // Store for refresh: resolve tool name from content type + pending args
      if (data?.type && _pendingArgs) {
        const toolMap = getTypeToToolMap();
        const toolName = toolMap[data.type];
        if (toolName) {
          storeLastToolCall(toolName, _pendingArgs);
        }
      }
      _pendingArgs = null;
    
      renderFromData(data);
    };
Behavior2/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, and idempotentHint=true, covering safety. The description adds minimal behavioral context beyond purpose. It does not mention edge cases, data limits, or result format, so it falls short of the extra value expected given the comprehensive annotations.

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 two sentences, immediately communicates the action and purpose, and uses no superfluous words. It is front-loaded with the verb 'Render' and the resource 'word cloud', making it efficient and easy to parse.

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

Completeness3/5

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

Given the tool has 7 parameters (2 required) with a nested data object and no output schema, the description is somewhat minimal. It provides usage examples but does not explain optional parameters like theme or palette. The schema covers param details, but the description could offer more guidance on configuration.

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 high (86%), so baseline is 3. The description does not add any parameter-level information beyond what the schema provides. It neither repeats nor enriches the parameter meanings, resulting in no additional value.

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 'Render a word cloud' and explains that words are sized by frequency or importance. It provides example use cases like survey responses and keyword analysis, which effectively distinguishes it from sibling chart-rendering tools such as render_bar_chart or render_pie_chart.

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

Usage Guidelines4/5

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

The description gives clear contexts for when to use the tool: 'Great for survey responses, keyword analysis, topic frequency.' However, it does not explicitly exclude other use cases or mention alternatives, which would warrant a perfect score.

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/KyuRish/mcp-dashboards'

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