Skip to main content
Glama

preview_ui_ascii

Read-onlyIdempotent

Generate ASCII art previews of UI layouts and components to visualize page designs before writing code.

Instructions

UI 만들어|페이지 개발|페이지 만들어|컴포넌트 작성|레이아웃|화면 구성|create page|build UI|design component|make page|develop page - Preview UI before coding

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
page_nameYesName of the page or component (e.g., "Login Page", "Dashboard")
layout_typeNoLayout structure type (default: header-footer)
componentsYesList of UI components to include
widthNoPreview width in characters (default: 60)
responsiveNoShow mobile view preview (default: false)

Implementation Reference

  • The main handler function that executes the tool logic: generates ASCII art visualization of the proposed UI layout using input page_name, components, layout_type, etc. Handles multiple layout types and returns a preview for confirmation.
    export async function previewUiAscii(args: {
      page_name: string;
      layout_type?: string;
      components: Array<{ type: string; label?: string; position?: string }>;
      width?: number;
      responsive?: boolean;
    }): Promise<ToolResult> {
      const {
        page_name,
        layout_type = 'header-footer',
        components,
        width = 60,
        responsive = false
      } = args;
    
      // ASCII art generation
      const topBorder = '┌' + '─'.repeat(width - 2) + '┐';
      const bottomBorder = '└' + '─'.repeat(width - 2) + '┘';
      const separator = '├' + '─'.repeat(width - 2) + '┤';
      const emptyLine = '│' + ' '.repeat(width - 2) + '│';
    
      const createLine = (text: string, align: 'left' | 'center' | 'right' = 'left') => {
        const contentWidth = width - 4;
        let content = text.slice(0, contentWidth);
    
        if (align === 'center') {
          const padding = Math.floor((contentWidth - content.length) / 2);
          content = ' '.repeat(padding) + content + ' '.repeat(contentWidth - padding - content.length);
        } else if (align === 'right') {
          content = ' '.repeat(contentWidth - content.length) + content;
        } else {
          content = content + ' '.repeat(contentWidth - content.length);
        }
    
        return '│ ' + content + ' │';
      };
    
      const createBox = (label: string, w: number, h: number) => {
        const lines = [];
        lines.push('┌' + '─'.repeat(w - 2) + '┐');
    
        for (let i = 0; i < h - 2; i++) {
          if (i === Math.floor((h - 2) / 2)) {
            const padding = Math.floor((w - 4 - label.length) / 2);
            const text = ' '.repeat(padding) + label + ' '.repeat(w - 4 - padding - label.length);
            lines.push('│ ' + text + ' │');
          } else {
            lines.push('│ ' + ' '.repeat(w - 4) + ' │');
          }
        }
    
        lines.push('└' + '─'.repeat(w - 2) + '┘');
        return lines;
      };
    
      let preview: string[] = [];
    
      // Generate preview based on layout type
      preview.push(topBorder);
    
      switch (layout_type) {
        case 'header-footer': {
          // Header
          const header = components.find(c => c.type === 'header' || c.position === 'top');
          if (header) {
            preview.push(createLine(header.label || 'Header', 'left'));
            preview.push(separator);
          }
    
          // Main content
          const mainComponents = components.filter(c =>
            c.type !== 'header' && c.type !== 'footer' && c.position !== 'top' && c.position !== 'bottom'
          );
    
          preview.push(emptyLine);
          mainComponents.forEach(comp => {
            const label = comp.label || comp.type.toUpperCase();
            if (comp.type === 'button') {
              preview.push(createLine(`  [${label}]`, 'center'));
            } else if (comp.type === 'input') {
              preview.push(createLine(`  ${label}: [____________]`, 'left'));
            } else if (comp.type === 'card') {
              preview.push(createLine(`  ┌─ ${label} ─────────────┐`, 'left'));
              preview.push(createLine(`  │ Content here...      │`, 'left'));
              preview.push(createLine(`  └──────────────────────┘`, 'left'));
            } else {
              preview.push(createLine(`  ${label}`, 'left'));
            }
          });
          preview.push(emptyLine);
    
          // Footer
          const footer = components.find(c => c.type === 'footer' || c.position === 'bottom');
          if (footer) {
            preview.push(separator);
            preview.push(createLine(footer.label || 'Footer', 'center'));
          }
          break;
        }
    
        case 'sidebar': {
          // Header
          const header = components.find(c => c.type === 'header' || c.position === 'top');
          if (header) {
            preview.push(createLine(header.label || 'Header', 'left'));
            preview.push(separator);
          }
    
          // Sidebar + Content
          const sidebarWidth = Math.floor(width * 0.25);
          const contentWidth = width - sidebarWidth - 5;
    
          const sidebar = components.find(c => c.type === 'sidebar' || c.position === 'left');
          const mainComponents = components.filter(c =>
            c.type !== 'header' && c.type !== 'footer' && c.type !== 'sidebar' &&
            c.position !== 'top' && c.position !== 'bottom' && c.position !== 'left'
          );
    
          preview.push('│ ┌' + '─'.repeat(sidebarWidth - 2) + '┐' + ' '.repeat(contentWidth - sidebarWidth + 3) + '│');
          preview.push('│ │' + (sidebar?.label || 'Nav').padEnd(sidebarWidth - 2) + '│  Content Area' + ' '.repeat(contentWidth - 15) + '│');
    
          const navItems = mainComponents.slice(0, 3);
          navItems.forEach((item, idx) => {
            const navLabel = `${item.label || item.type}`.slice(0, sidebarWidth - 4);
            const contentLabel = idx === 0 ? `┌─ ${mainComponents[0]?.label || 'Main'} ─┐` : '';
            preview.push('│ │ ' + navLabel.padEnd(sidebarWidth - 3) + '│  ' + contentLabel.padEnd(contentWidth - 3) + '│');
          });
    
          preview.push('│ └' + '─'.repeat(sidebarWidth - 2) + '┘' + ' '.repeat(contentWidth - sidebarWidth + 3) + '│');
    
          // Footer
          const footer = components.find(c => c.type === 'footer' || c.position === 'bottom');
          if (footer) {
            preview.push(separator);
            preview.push(createLine(footer.label || 'Footer', 'center'));
          }
          break;
        }
    
        case 'grid': {
          preview.push(createLine('Grid Layout', 'center'));
          preview.push(separator);
    
          const gridComponents = components.filter(c => c.type !== 'header' && c.type !== 'footer');
          const cols = Math.ceil(Math.sqrt(gridComponents.length));
          const cellWidth = Math.floor((width - 4) / cols) - 2;
    
          for (let i = 0; i < gridComponents.length; i += cols) {
            const row = gridComponents.slice(i, i + cols);
            preview.push('│ ' + row.map(c => {
              const label = (c.label || c.type).slice(0, cellWidth - 2);
              return '┌' + label.padEnd(cellWidth - 2, '─') + '┐';
            }).join(' ') + ' '.repeat(width - 4 - row.length * (cellWidth + 1)) + ' │');
    
            preview.push('│ ' + row.map(c => '│' + ' '.repeat(cellWidth - 2) + '│').join(' ') + ' '.repeat(width - 4 - row.length * (cellWidth + 1)) + ' │');
    
            preview.push('│ ' + row.map(c => '└' + '─'.repeat(cellWidth - 2) + '┘').join(' ') + ' '.repeat(width - 4 - row.length * (cellWidth + 1)) + ' │');
          }
          break;
        }
    
        case 'centered': {
          const main = components[0];
          preview.push(emptyLine);
          preview.push(emptyLine);
          preview.push(createLine(main?.label || 'Main Content', 'center'));
    
          components.slice(1).forEach(comp => {
            if (comp.type === 'button') {
              preview.push(createLine(`[${comp.label || 'Button'}]`, 'center'));
            } else if (comp.type === 'input') {
              preview.push(createLine(`${comp.label || 'Input'}: [____________]`, 'center'));
            }
          });
    
          preview.push(emptyLine);
          preview.push(emptyLine);
          break;
        }
    
        case 'split': {
          const leftWidth = Math.floor((width - 5) / 2);
          const rightWidth = width - leftWidth - 5;
    
          preview.push('│ ┌' + '─'.repeat(leftWidth) + '┐ ┌' + '─'.repeat(rightWidth) + '┐ │');
    
          const left = components.find(c => c.position === 'left') || components[0];
          const right = components.find(c => c.position === 'right') || components[1];
    
          preview.push('│ │' + (left?.label || 'Left').padEnd(leftWidth) + '│ │' + (right?.label || 'Right').padEnd(rightWidth) + '│ │');
    
          for (let i = 0; i < 5; i++) {
            preview.push('│ │' + ' '.repeat(leftWidth) + '│ │' + ' '.repeat(rightWidth) + '│ │');
          }
    
          preview.push('│ └' + '─'.repeat(leftWidth) + '┘ └' + '─'.repeat(rightWidth) + '┘ │');
          break;
        }
      }
    
      preview.push(bottomBorder);
    
      // Mobile view if responsive
      let mobilePreview = '';
      if (responsive) {
        const mobileWidth = 30;
        const mobileTop = '┌' + '─'.repeat(mobileWidth - 2) + '┐';
        const mobileBottom = '└' + '─'.repeat(mobileWidth - 2) + '┘';
    
        mobilePreview = '\n\n📱 Mobile View:\n';
        mobilePreview += mobileTop + '\n';
        components.forEach(comp => {
          const label = (comp.label || comp.type).slice(0, mobileWidth - 4);
          mobilePreview += '│ ' + label.padEnd(mobileWidth - 4) + ' │\n';
        });
        mobilePreview += mobileBottom;
      }
    
      const result = {
        page_name,
        layout_type,
        ascii_preview: preview.join('\n'),
        mobile_preview: responsive ? mobilePreview : null,
        components_count: components.length,
        message: '✅ 이 레이아웃으로 진행하시겠습니까? 승인하시면 코드 생성을 시작합니다.',
        action: 'preview_ui_ascii',
        status: 'awaiting_confirmation'
      };
    
      return {
        content: [{
          type: 'text',
          text: `🎨 UI Preview: ${page_name}\n\n${preview.join('\n')}${mobilePreview}\n\n${result.message}`
        }]
      };
    }
  • ToolDefinition object defining the input schema, description, and annotations for the preview_ui_ascii tool.
    export const previewUiAsciiDefinition: ToolDefinition = {
      name: 'preview_ui_ascii',
      description: 'UI 만들어|페이지 개발|페이지 만들어|컴포넌트 작성|레이아웃|화면 구성|create page|build UI|design component|make page|develop page - Preview UI before coding',
      inputSchema: {
        type: 'object',
        properties: {
          page_name: {
            type: 'string',
            description: 'Name of the page or component (e.g., "Login Page", "Dashboard")'
          },
          layout_type: {
            type: 'string',
            enum: ['sidebar', 'header-footer', 'grid', 'centered', 'split', 'custom'],
            description: 'Layout structure type (default: header-footer)'
          },
          components: {
            type: 'array',
            description: 'List of UI components to include',
            items: {
              type: 'object',
              properties: {
                type: { type: 'string', description: 'Component type (header, sidebar, button, input, card, etc.)' },
                label: { type: 'string', description: 'Component label or text' },
                position: { type: 'string', description: 'Position in layout (top, left, center, right, bottom)' }
              }
            }
          },
          width: {
            type: 'number',
            description: 'Preview width in characters (default: 60)'
          },
          responsive: {
            type: 'boolean',
            description: 'Show mobile view preview (default: false)'
          }
        },
        required: ['page_name', 'components']
      },
      annotations: {
        title: 'Preview UI (ASCII)',
        audience: ['user', 'assistant'],
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
        openWorldHint: false
      }
    };
  • src/index.ts:90-92 (registration)
    Registration of the tool definition in the tools array used for ListToolsRequest.
    getCurrentTimeDefinition,
    previewUiAsciiDefinition,
  • src/index.ts:157-159 (registration)
    Registration of the tool handler in the toolHandlers object for dynamic dispatch during tool execution.
    'get_current_time': getCurrentTime,
    'preview_ui_ascii': previewUiAscii,
  • src/index.ts:81-81 (registration)
    Import statement bringing in the definition and handler from the implementation file.
    import { previewUiAsciiDefinition, previewUiAscii } from './tools/ui/previewUiAscii.js';
Behavior4/5

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

Annotations already provide clear behavioral hints (readOnlyHint: true, destructiveHint: false, idempotentHint: true). The description adds valuable context by specifying that this is a 'preview' tool for UI design before actual coding, which clarifies its non-destructive, planning-oriented nature. This goes beyond what annotations provide by explaining the tool's role in the development workflow.

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?

The description is efficiently structured with a list of synonymous action verbs followed by the core purpose 'Preview UI before coding.' It's front-loaded with key terms and avoids unnecessary elaboration. The only minor inefficiency is the repetitive list of verbs, but overall it's appropriately concise for the tool's complexity.

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

Completeness4/5

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

Given the rich annotations (readOnly, non-destructive, idempotent) and 100% schema coverage, the description provides adequate context for this preview tool. The description clarifies the tool's role in the UI design workflow, which complements the structured data. The main gap is the lack of output schema, but the description doesn't need to explain return values since it's a preview 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 description coverage is 100%, meaning all parameters are well-documented in the schema itself. The description doesn't add any additional parameter semantics beyond what's already in the schema descriptions. This meets the baseline expectation when schema coverage is complete, but doesn't provide extra value.

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 description clearly states the tool's purpose: 'Preview UI before coding' with multiple synonymous verbs (create, build, design, make, develop). It specifies the resource (UI/page/component) and the action (preview). However, it doesn't explicitly differentiate from sibling tools, which appear to be analysis/memory/planning tools rather than UI preview tools, so the distinction is implicit rather than explicit.

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

Usage Guidelines3/5

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

The description implies usage context through the phrase 'Preview UI before coding,' suggesting this is for design/planning phases. However, it doesn't provide explicit guidance on when to use this tool versus alternatives, nor does it mention prerequisites or exclusions. The sibling tools are mostly analysis/memory tools, so the distinction is clear but not explicitly stated.

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/su-record/hi-ai'

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