Skip to main content
Glama

compose

Combine multiple text blocks into a single layout by arranging them side by side or stacked, with control over spacing and alignment.

Instructions

Combine multiple text blocks side-by-side or stacked.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blocksYesText blocks to combine
modeNoLayout modehorizontal
gapNoGap between blocks (spaces for horizontal, blank lines for vertical)
alignNoVertical alignment for horizontal modetop
separatorNoSeparator string for vertical mode

Implementation Reference

  • The compose() function that implements the core logic for combining text blocks horizontally (side-by-side) or vertically (stacked). Handles alignment (top/middle/bottom), gaps, and optional separator strings.
    export function compose(blocks: string[], options: ComposeOptions = {}): string {
      if (blocks.length === 0) return '';
      if (blocks.length === 1) return blocks[0];
    
      const { mode = 'horizontal', gap = 1, align = 'top', separator } = options;
    
      if (mode === 'vertical') {
        if (separator) {
          return blocks.join('\n' + separator + '\n');
        }
        const spacer = '\n' + '\n'.repeat(gap);
        return blocks.join(spacer);
      }
    
      // Horizontal mode
      const split = blocks.map((b) => b.split('\n'));
      const widths = split.map((lines) => Math.max(...lines.map((l) => l.length), 0));
      const maxHeight = Math.max(...split.map((lines) => lines.length));
      const gapStr = ' '.repeat(gap);
    
      // Pad each block to maxHeight with alignment
      const padded = split.map((lines, i) => {
        const w = widths[i];
        const normalized = lines.map((l) => l.padEnd(w));
        const diff = maxHeight - normalized.length;
        const empty = ' '.repeat(w);
    
        if (diff === 0) return normalized;
    
        let topPad = 0;
        if (align === 'middle') topPad = Math.floor(diff / 2);
        else if (align === 'bottom') topPad = diff;
        const bottomPad = diff - topPad;
    
        return [
          ...Array(topPad).fill(empty),
          ...normalized,
          ...Array(bottomPad).fill(empty),
        ];
      });
    
      const result: string[] = [];
      for (let row = 0; row < maxHeight; row++) {
        result.push(padded.map((lines) => lines[row]).join(gapStr));
      }
    
      return result.join('\n');
    }
  • Type definitions for ComposeMode, ComposeAlign, and ComposeOptions used by the compose tool.
    export type ComposeMode = 'horizontal' | 'vertical';
    export type ComposeAlign = 'top' | 'middle' | 'bottom';
    
    export interface ComposeOptions {
      mode?: ComposeMode;
      gap?: number;
      align?: ComposeAlign;
      separator?: string;
    }
  • src/mcp.ts:228-242 (registration)
    Registration of the 'compose' MCP tool with server.tool(), defining the Zod schema for blocks, mode, gap, align, and separator, and calling the imported compose() function.
    server.tool(
      'compose',
      'Combine multiple text blocks side-by-side or stacked.',
      {
        blocks: z.array(z.string()).min(1).max(MAX_COMPOSE_BLOCKS).describe('Text blocks to combine'),
        mode: z.enum(['horizontal', 'vertical']).default('horizontal').describe('Layout mode'),
        gap: z.number().min(0).max(MAX_COMPOSE_GAP).default(1).describe('Gap between blocks (spaces for horizontal, blank lines for vertical)'),
        align: z.enum(['top', 'middle', 'bottom']).default('top').describe('Vertical alignment for horizontal mode'),
        separator: z.string().max(80).optional().describe('Separator string for vertical mode'),
      },
      async ({ blocks, mode, gap, align, separator }) => {
        const result = compose(blocks, { mode: mode as any, gap, align: align as any, separator });
        return { content: [{ type: 'text', text: result }] };
      }
    );
  • Constants MAX_COMPOSE_BLOCKS (10) and MAX_COMPOSE_GAP (10) used as limits in the compose tool schema.
    export const MAX_COMPOSE_BLOCKS = 10;
    export const MAX_COMPOSE_GAP = 10;
Behavior2/5

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

No annotations are provided, so the description bears full responsibility. It only states the basic operation without detailing behavior like handling unequal block lengths, whitespace, or output format, leaving significant ambiguity.

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?

A single concise sentence that immediately conveys the purpose. It is well-sized but could benefit from slightly more detail without becoming verbose.

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?

Given the tool has 5 parameters, no output schema, and no annotations, the description is too sparse. It fails to explain return values or provide context for using the parameters, leaving the agent underinformed.

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?

The schema already documents all parameters with descriptions, achieving 100% coverage. The description adds no additional meaning beyond the schema, so baseline score of 3 is appropriate.

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 clearly states the tool combines text blocks side-by-side or stacked, specifying the verb and resource. It effectively distinguishes from sibling tools like search or animate, which handle different operations.

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?

No guidance on when to use this tool versus alternatives or when not to use it. The description lacks any context about prerequisites or appropriate use cases.

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/rxolve/artscii'

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