Skip to main content
Glama
InsForge

Insforge MCP Server

download-template

Download pre-configured starter templates for React or Next.js projects to initialize new InsForge applications with backend services.

Instructions

CRITICAL: MANDATORY FIRST STEP for all new InsForge projects. Download pre-configured starter template to a temporary directory. After download, you MUST copy files to current directory using the provided command.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
frameYesFramework to use for the template (support React and Next.js)
projectNameNoName for the project directory (optional, defaults to "insforge-react")

Implementation Reference

  • The core handler logic for the 'download-template' tool. Fetches an anonymous API key, creates a temporary directory, executes 'npx create-insforge-app' to download the starter template, and returns instructions for copying files to the current project directory.
        withUsageTracking('download-template', async ({ frame, projectName }) => {
          try {
            // Get the anon key from backend
            const response = await fetch(`${API_BASE_URL}/api/auth/tokens/anon`, {
              method: 'POST',
              headers: {
                'x-api-key': getApiKey(),
                'Content-Type': 'application/json',
              },
            });
    
            const result = await handleApiResponse(response);
            const anonKey = result.accessToken;
    
            if (!anonKey) {
              throw new Error('Failed to retrieve anon key from backend');
            }
    
            // Create temp directory for download
            const tempDir = tmpdir();
            const targetDir = projectName || `insforge-${frame}`;
            const templatePath = `${tempDir}/${targetDir}`;
    
            console.error(`[download-template] Target path: ${templatePath}`);
    
            // Check if template already exists in temp, remove it first
            try {
              const stats = await fs.stat(templatePath);
              if (stats.isDirectory()) {
                console.error(`[download-template] Removing existing template at ${templatePath}`);
                await fs.rm(templatePath, { recursive: true, force: true });
              }
            } catch {
              // Directory doesn't exist, which is fine
            }
    
            const command = `npx create-insforge-app ${targetDir} --frame ${frame} --base-url ${API_BASE_URL} --anon-key ${anonKey} --skip-install`;
    
            // Execute the npx command in temp directory
            const { stdout, stderr } = await execAsync(command, {
              maxBuffer: 10 * 1024 * 1024, // 10MB buffer
              cwd: tempDir,
            });
    
            // Check if command was successful (basic validation)
            const output = stdout || stderr || '';
            if (output.toLowerCase().includes('error') && !output.includes('successfully')) {
              throw new Error(`Failed to download template: ${output}`);
            }
    
            return await addBackgroundContext({
              content: [
                {
                  type: 'text',
                  text: `āœ… React template downloaded successfully
    
    šŸ“ Template Location: ${templatePath}
    
    āš ļø  IMPORTANT: The template is in a temporary directory and NOT in your current working directory.
    
    šŸ”“ CRITICAL NEXT STEP REQUIRED:
    You MUST copy ALL files (INCLUDING HIDDEN FILES like .env, .gitignore, etc.) from the temporary directory to your current project directory.
    
    Copy all files from: ${templatePath}
    To: Your current project directory
    `,
                },
              ],
            });
          } catch (error) {
            const errMsg = error instanceof Error ? error.message : 'Unknown error occurred';
            return {
              content: [
                {
                  type: 'text',
                  text: `Error downloading template: ${errMsg}`,
                },
              ],
              isError: true,
            };
          }
        })
      );
  • Input schema parameters for the download-template tool: 'frame' (required, enum react/nextjs) and 'projectName' (optional string).
    {
      frame: z
        .enum(['react', 'nextjs'])
        .describe('Framework to use for the template (support React and Next.js)'),
      projectName: z
        .string()
        .optional()
        .describe('Name for the project directory (optional, defaults to "insforge-react")'),
    },
  • Registration of the 'download-template' tool on the MCP server within the registerInsforgeTools function, including name, description, schema, and handler.
      server.tool(
        'download-template',
        'CRITICAL: MANDATORY FIRST STEP for all new InsForge projects. Download pre-configured starter template to a temporary directory. After download, you MUST copy files to current directory using the provided command.',
        {
          frame: z
            .enum(['react', 'nextjs'])
            .describe('Framework to use for the template (support React and Next.js)'),
          projectName: z
            .string()
            .optional()
            .describe('Name for the project directory (optional, defaults to "insforge-react")'),
        },
        withUsageTracking('download-template', async ({ frame, projectName }) => {
          try {
            // Get the anon key from backend
            const response = await fetch(`${API_BASE_URL}/api/auth/tokens/anon`, {
              method: 'POST',
              headers: {
                'x-api-key': getApiKey(),
                'Content-Type': 'application/json',
              },
            });
    
            const result = await handleApiResponse(response);
            const anonKey = result.accessToken;
    
            if (!anonKey) {
              throw new Error('Failed to retrieve anon key from backend');
            }
    
            // Create temp directory for download
            const tempDir = tmpdir();
            const targetDir = projectName || `insforge-${frame}`;
            const templatePath = `${tempDir}/${targetDir}`;
    
            console.error(`[download-template] Target path: ${templatePath}`);
    
            // Check if template already exists in temp, remove it first
            try {
              const stats = await fs.stat(templatePath);
              if (stats.isDirectory()) {
                console.error(`[download-template] Removing existing template at ${templatePath}`);
                await fs.rm(templatePath, { recursive: true, force: true });
              }
            } catch {
              // Directory doesn't exist, which is fine
            }
    
            const command = `npx create-insforge-app ${targetDir} --frame ${frame} --base-url ${API_BASE_URL} --anon-key ${anonKey} --skip-install`;
    
            // Execute the npx command in temp directory
            const { stdout, stderr } = await execAsync(command, {
              maxBuffer: 10 * 1024 * 1024, // 10MB buffer
              cwd: tempDir,
            });
    
            // Check if command was successful (basic validation)
            const output = stdout || stderr || '';
            if (output.toLowerCase().includes('error') && !output.includes('successfully')) {
              throw new Error(`Failed to download template: ${output}`);
            }
    
            return await addBackgroundContext({
              content: [
                {
                  type: 'text',
                  text: `āœ… React template downloaded successfully
    
    šŸ“ Template Location: ${templatePath}
    
    āš ļø  IMPORTANT: The template is in a temporary directory and NOT in your current working directory.
    
    šŸ”“ CRITICAL NEXT STEP REQUIRED:
    You MUST copy ALL files (INCLUDING HIDDEN FILES like .env, .gitignore, etc.) from the temporary directory to your current project directory.
    
    Copy all files from: ${templatePath}
    To: Your current project directory
    `,
                },
              ],
            });
          } catch (error) {
            const errMsg = error instanceof Error ? error.message : 'Unknown error occurred';
            return {
              content: [
                {
                  type: 'text',
                  text: `Error downloading template: ${errMsg}`,
                },
              ],
              isError: true,
            };
          }
        })
      );
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that the tool downloads to a temporary directory and requires a follow-up copy command, which adds useful behavioral context. However, it lacks details on permissions, error handling, or what happens if the template already exists, leaving gaps for a mutation tool.

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 front-loaded with critical information ('CRITICAL: MANDATORY FIRST STEP') and uses two concise sentences that earn their place by stating the action, context, and required follow-up. There is no wasted text, making it highly efficient and well-structured.

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 no annotations, no output schema, and 2 parameters with full schema coverage, the description is mostly complete. It covers purpose, usage, and behavioral steps, but as a mutation tool (download implies write operation), it could benefit from more details on side effects or error scenarios. The lack of output schema is mitigated by the clear post-action instructions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/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 both parameters. The description does not add specific parameter details beyond the schema, but it implicitly reinforces the importance of 'frame' by mentioning 'pre-configured starter template' and 'InsForge projects,' aligning with the schema's framework focus. Baseline is 3, but the contextual reinforcement slightly enhances understanding.

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 explicitly states the tool's purpose: 'Download pre-configured starter template to a temporary directory.' It specifies the action (download), resource (starter template), and context (InsForge projects). It clearly distinguishes this from sibling tools like 'create-bucket' or 'run-raw-sql' by focusing on project initialization.

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

Usage Guidelines5/5

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

The description provides explicit usage guidelines: 'CRITICAL: MANDATORY FIRST STEP for all new InsForge projects' indicates when to use it, and 'After download, you MUST copy files to current directory using the provided command' specifies post-action requirements. It implies alternatives are not applicable for this initial step, offering clear context.

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/InsForge/insforge-mcp'

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