Skip to main content
Glama

design_block

Create detailed designs for specific blocks in a component-based system using natural language prompts. Supports Vue, React, and Angular for precise frontend development.

Instructions

Design a specific block. This is the second-stage tool in the block-based design strategy for detailed component design.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockIdYesID of the design block to design
blockInfoNoDetailed information of the block (optional)
integratedContextNoIntegration context (optional): contains the overall strategy and completed block designs to return an updated integrated design snapshot
promptYesSpecific requirement description for the block

Implementation Reference

  • The core handler function `designBlockTool` that implements the tool logic: validates inputs, builds design request, calls `processSmartBlockDesign`, handles integration, formats MCP-compliant response with text and JSON data.
    export async function designBlockTool(args: any): Promise<{ content: any[] }> {
      const startTime = Date.now();
    
      try {
        // Validate input parameters
        if (!args || typeof args.blockId !== 'string' || !args.blockId.trim()) {
          throw new Error('Missing required parameter: blockId is required');
        }
        if (!Array.isArray(args.prompt)) {
          throw new Error('Missing required parameter: prompt is required');
        }
    
        // Build request object
        const request: ComponentDesignRequest = {
          prompt: args.prompt,
          rules: Array.isArray(args.rules) ? args.rules : [],
          aiModel: getRecommendedModel(ModelPurpose.DESIGN), // 使用内置的推荐模型
          component: args.component,
        };
    
        // Process smart block design
        const blockDesign: ComponentDesign = await processSmartBlockDesign(
          request,
          args.blockId,
          args.blockInfo,
          args.integratedContext
        );
    
        // 构建完整的返回结果
        const result: DesignToolResult = {
          success: true,
          data: blockDesign,
          metadata: {
            processingTime: Date.now() - startTime,
            model: request.aiModel,
            timestamp: new Date().toISOString(),
            blockId: args.blockId,
          },
        };
    
        // 如果有集成上下文,尝试集成设计
        let integrated = null;
        if (
          args.integratedContext?.strategy &&
          args.integratedContext?.blockDesigns
        ) {
          try {
            integrated = integrateDesign(args.integratedContext.strategy, [
              ...args.integratedContext.blockDesigns,
              blockDesign,
            ]);
          } catch (e) {
            console.warn('[BlockTool] integrateDesign error:', e);
          }
        }
    
        return {
          content: [
            {
              type: 'text',
              text: formatBlockDesignResult(blockDesign, args.blockId),
            },
            {
              type: 'text',
              text: JSON.stringify({
                result,
                integrated,
                nextAction: integrated
                  ? {
                      tool: 'integrate_design',
                      arguments: {
                        strategy: args.integratedContext?.strategy,
                        blockDesigns: [
                          ...(args.integratedContext?.blockDesigns || []),
                          blockDesign,
                        ],
                      },
                      reason: 'Block design completed, ready for integration',
                    }
                  : null,
              }),
            },
          ],
        };
      } catch (error) {
        console.error('Design block tool error:', error);
    
        const message =
          error instanceof Error ? error.message : 'Unknown error occurred';
        return {
          content: [
            {
              type: 'text',
              text: `❌ Block design failed: ${message}`,
            },
          ],
        };
      }
    }
  • Tool registration in the listTools handler: defines name 'design_block', description, and detailed inputSchema for validation.
    {
      name: 'design_block',
      description:
        'Design a specific block. This is the second-stage tool in the block-based design strategy for detailed component design.',
      inputSchema: {
        type: 'object',
        properties: {
          blockId: {
            type: 'string',
            description: 'ID of the design block to design',
          },
          prompt: {
            type: 'array',
            description: 'Specific requirement description for the block',
            items: {
              type: 'object',
              properties: {
                type: { type: 'string', enum: ['text', 'image'] },
                text: { type: 'string' },
                image: { type: 'string' },
              },
              required: ['type'],
            },
          },
          blockInfo: {
            type: 'object',
            description: 'Detailed information of the block (optional)',
            properties: {
              blockId: { type: 'string' },
              blockType: {
                type: 'string',
                enum: ['layout', 'component', 'logic'],
              },
              title: { type: 'string' },
              description: { type: 'string' },
              priority: { type: 'string', enum: ['high', 'medium', 'low'] },
            },
          },
          integratedContext: {
            type: 'object',
            description:
              'Integration context (optional): contains the overall strategy and completed block designs to return an updated integrated design snapshot',
            properties: {
              strategy: { type: 'object' },
              blockDesigns: { type: 'array' },
            },
          },
        },
        required: ['blockId', 'prompt'],
      },
  • Tool dispatch in the callTool handler: routes 'design_block' calls to the designBlockTool implementation.
    case 'design_block':
      return await designBlockTool(args);
  • TypeScript interface definition for DesignBlock, used in block design strategy and results.
    export interface DesignBlock {
      blockId: string;
      blockType: 'layout' | 'component' | 'logic';
      title: string;
      description: string;
      components: string[];
      dependencies: string[];
      estimatedTokens: number;
      priority: 'high' | 'medium' | 'low';
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions being part of a 'strategy' and 'detailed component design,' but doesn't disclose critical behavioral traits such as whether this is a read or write operation, potential side effects, authentication needs, rate limits, or what the output looks like. For a tool with complex parameters and no annotations, this is a significant gap.

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 concise with two sentences that are front-loaded with the main purpose. Every sentence adds value by specifying the tool's role in a strategy, though it could be slightly more structured to highlight key usage aspects.

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 complexity (4 parameters with nested objects), no annotations, and no output schema, the description is incomplete. It lacks details on behavioral traits, output format, and deeper context for usage, making it inadequate for an agent to fully understand how to invoke this tool effectively in a design workflow.

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 all parameters thoroughly. The description adds no specific parameter semantics beyond implying 'blockId' and 'prompt' are key (as required), but doesn't explain their roles or relationships. Baseline 3 is appropriate as the schema does the heavy lifting.

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 action ('Design') and resource ('a specific block'), and mentions it's part of a 'block-based design strategy for detailed component design.' It distinguishes from siblings by specifying it's the 'second-stage tool' in a strategy, though it doesn't explicitly contrast with sibling tools like 'design_component' or 'integrate_design.'

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 by stating it's the 'second-stage tool in the block-based design strategy,' suggesting it should be used after some initial step. However, it doesn't provide explicit when-to-use guidance, alternatives (e.g., vs. 'design_component'), or exclusions, leaving the agent to infer based on the strategic mention.

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

Related 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/lyw405/mcp-garendesign'

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