Skip to main content
Glama
restforge

@restforge-dev/mcp-server

Official
by restforge

Get Init Template

setup_get_init_template
Read-onlyIdempotent

Retrieve default db-connection.env template content without writing files. Compare current configuration against template defaults for drift detection.

Instructions

Get raw template content of db-connection.env without writing any file. Useful as reference after current file has been modified, or for comparing current config against template defaults (drift detection).

USE WHEN:

  • The agent needs to see template defaults after the current file has been modified

  • Comparing current config with template (drift detection)

  • Restoring template content reference without re-running init

  • The user asks things like "show me the default template", "lihat template config default", "apa isi template defaultnya", "what does the default config look like", "bandingkan dengan template asli", "compare against the original template"

DO NOT USE FOR:

  • Generating new config files in the project -> use 'setup_init_config'

  • Reading current config -> use 'setup_read_env'

  • Getting structured schema (JSON) -> use 'setup_get_config_schema'

This tool runs: npx restforge-cli config:template in the given cwd. This tool is READ-ONLY and safe to call repeatedly. No file is written. Requires restforgejs >= 2.3.1.

PRESENTATION GUIDANCE:

  • Match the user's language. If the user writes in Indonesian, respond in Indonesian.

  • Never mention internal tool names in the reply to the user. Describe actions by what they do (e.g. "install the package", "set up the initial config", "show the active configuration").

  • Speak in plain language. Summarise what the template contains (sections present, total parameters); do not paste the entire template body unless the user explicitly asks for it.

  • When a precondition is not met (e.g. the package is not installed), frame it as a question or next-step suggestion rather than an error.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdYesAbsolute path of the project folder (must have restforgejs installed in node_modules)

Implementation Reference

  • The main handler function 'registerSetupGetInitTemplate' that registers the 'setup_get_init_template' tool with the MCP server. It checks the precondition (restforgejs installed), runs 'npx restforge-cli config:template', and returns the template content as a read-only preview.
    export function registerSetupGetInitTemplate(server: McpServer): void {
      server.registerTool(
        'setup_get_init_template',
        {
          title: 'Get Init Template',
          description: `Get raw template content of db-connection.env without writing any file.
    Useful as reference after current file has been modified, or for comparing
    current config against template defaults (drift detection).
    
    USE WHEN:
    - The agent needs to see template defaults after the current file has been modified
    - Comparing current config with template (drift detection)
    - Restoring template content reference without re-running init
    - The user asks things like "show me the default template", "lihat template config default",
      "apa isi template defaultnya", "what does the default config look like",
      "bandingkan dengan template asli", "compare against the original template"
    
    DO NOT USE FOR:
    - Generating new config files in the project -> use 'setup_init_config'
    - Reading current config -> use 'setup_read_env'
    - Getting structured schema (JSON) -> use 'setup_get_config_schema'
    
    This tool runs: npx restforge-cli config:template in the given cwd.
    This tool is READ-ONLY and safe to call repeatedly. No file is written.
    Requires restforgejs >= 2.3.1.
    
    PRESENTATION GUIDANCE:
    - Match the user's language. If the user writes in Indonesian, respond in Indonesian.
    - Never mention internal tool names in the reply to the user. Describe actions by what they do (e.g. "install the package", "set up the initial config", "show the active configuration").
    - Speak in plain language. Summarise what the template contains (sections present, total parameters); do not paste the entire template body unless the user explicitly asks for it.
    - When a precondition is not met (e.g. the package is not installed), frame it as a question or next-step suggestion rather than an error.`,
          inputSchema: {
            cwd: z.string().min(1).describe('Absolute path of the project folder (must have restforgejs installed in node_modules)'),
          },
          annotations: {
            title: 'Get Init Template',
            readOnlyHint: true,
            idempotentHint: true,
          },
        },
        async ({ cwd }) => {
          const projectCwd = resolve(cwd);
    
          // Precondition check: restforgejs must be installed before this CLI command can run.
          // Treated as a non-error precondition per the authoring guide §3.4.
          try {
            await access(join(projectCwd, 'node_modules', 'restforgejs'));
          } catch {
            return {
              content: [
                {
                  type: 'text',
                  text: `Precondition not met: the RESTForge package is not installed in this project.
    
    Project path: ${projectCwd}
    Expected location: node_modules/restforgejs
    
    For the assistant:
    - The default config template can only be retrieved once the RESTForge package is installed locally.
    - Suggest installing the package first, then retry getting the template.
    - When explaining to the user, say something like "the RESTForge package isn't installed yet — should I install it first?". Do not mention internal tool names.`,
                },
              ],
              isError: false, // per §3.4
            };
          }
    
          // Run subprocess with NODE_ENV=production to suppress legacy banner output.
          // stripFinalNewline=false to preserve byte-perfect template content
          // (matches the trailing newline in db-connection.env file written by `restforge-cli init`).
          const result = await execProcess(
            'npx',
            ['restforge-cli', 'config:template'],
            {
              cwd: projectCwd,
              timeout: 15_000,
              env: { NODE_ENV: 'production' },
              stripFinalNewline: false,
            }
          );
    
          // CLI failure: real error per §3.4; structured per §3.5.
          if (!result.success) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Failed to retrieve the configuration template.
    
    Project path: ${projectCwd}
    Command: ${result.command}
    Exit code: ${result.exitCode}
    
    --- CLI output ---
    stdout:
    ${result.stdout}
    
    stderr:
    ${result.stderr}
    --- end CLI output ---
    
    For the assistant:
    - Tell the user that the default template could not be retrieved.
    - A common cause is an older RESTForge version that does not yet expose the template command (requires restforgejs >= 2.3.1). Suggest upgrading the package as a likely fix.
    - Do not paste the raw stdout/stderr unless the user explicitly asks. Do not mention internal tool names.`,
                },
              ],
              isError: true, // per §3.4
            };
          }
    
          // Success: one-line summary + labeled facts + fenced template body per §3.5.
          return {
            content: [
              {
                type: 'text',
                text: `Configuration template retrieved successfully.
    
    Project path: ${projectCwd}
    Source: restforge-cli (matches the template that 'init' would write into config/db-connection.env)
    Note: this is a read-only preview; no file was written.
    
    --- Template (db-connection.env) ---
    ${result.stdout}--- end Template (db-connection.env) ---
    
    For the assistant:
    - Confirm to the user that the default template is available.
    - Summarise the template in plain language: which sections are present (database, license, optional Live Sync / Redis / Kafka / Logging) and the total parameter count.
    - Do not paste the full template body unless the user explicitly asks for it. If the user is doing drift detection, the full template content is available between the fenced markers above for programmatic comparison.
    - Do not mention internal tool names.`,
              },
            ],
          };
        }
      );
    }
  • Input schema definition for the tool: requires a 'cwd' string parameter (absolute path of the project folder). Also includes tool description, annotations (readOnlyHint, idempotentHint), and detailed usage guidance.
        {
          title: 'Get Init Template',
          description: `Get raw template content of db-connection.env without writing any file.
    Useful as reference after current file has been modified, or for comparing
    current config against template defaults (drift detection).
    
    USE WHEN:
    - The agent needs to see template defaults after the current file has been modified
    - Comparing current config with template (drift detection)
    - Restoring template content reference without re-running init
    - The user asks things like "show me the default template", "lihat template config default",
      "apa isi template defaultnya", "what does the default config look like",
      "bandingkan dengan template asli", "compare against the original template"
    
    DO NOT USE FOR:
    - Generating new config files in the project -> use 'setup_init_config'
    - Reading current config -> use 'setup_read_env'
    - Getting structured schema (JSON) -> use 'setup_get_config_schema'
    
    This tool runs: npx restforge-cli config:template in the given cwd.
    This tool is READ-ONLY and safe to call repeatedly. No file is written.
    Requires restforgejs >= 2.3.1.
    
    PRESENTATION GUIDANCE:
    - Match the user's language. If the user writes in Indonesian, respond in Indonesian.
    - Never mention internal tool names in the reply to the user. Describe actions by what they do (e.g. "install the package", "set up the initial config", "show the active configuration").
    - Speak in plain language. Summarise what the template contains (sections present, total parameters); do not paste the entire template body unless the user explicitly asks for it.
    - When a precondition is not met (e.g. the package is not installed), frame it as a question or next-step suggestion rather than an error.`,
          inputSchema: {
            cwd: z.string().min(1).describe('Absolute path of the project folder (must have restforgejs installed in node_modules)'),
          },
          annotations: {
            title: 'Get Init Template',
            readOnlyHint: true,
            idempotentHint: true,
  • Registration point: imports 'registerSetupGetInitTemplate' from './get-init-template.js' and calls it on line 21 within the 'registerSetupTools' function that registers all setup tools.
    import { registerSetupGetInitTemplate } from './get-init-template.js';
    
    export function registerSetupTools(server: McpServer): void {
      registerSetupCreateFolder(server);
      registerSetupInstallPackage(server);
      registerSetupInitConfig(server);
      registerSetupWriteEnv(server);
      registerSetupReadEnv(server);
      registerSetupUpdateEnv(server);
      registerSetupValidateConfig(server);
      registerSetupGetConfigSchema(server);
      registerSetupGetInitTemplate(server);
    }
  • The 'execProcess' helper function used by the handler to execute 'npx restforge-cli config:template' via execa, supporting options like cwd, timeout, env, and stripFinalNewline.
    export async function execProcess(
      command: string,
      args: string[],
      options: ExecOptions = {}
    ): Promise<ExecResult> {
      const { cwd = process.cwd(), timeout = 60_000, env, stripFinalNewline = true } = options;
      const fullCommand = `${command} ${args.join(' ')}`;
    
      // Merge env: parent env first, custom env overrides
      const mergedEnv = env ? { ...process.env, ...env } : undefined;
    
      try {
        const result = await execa(command, args, {
          cwd,
          timeout,
          reject: false,
          stripFinalNewline,
          ...(mergedEnv ? { env: mergedEnv } : {}),
        });
        return {
          success: result.exitCode === 0,
          stdout: result.stdout,
          stderr: result.stderr,
          exitCode: result.exitCode ?? -1,
          command: fullCommand,
        };
      } catch (error) {
        const e = error as ExecaError;
        return {
          success: false,
          stdout: e.stdout?.toString() ?? '',
          stderr: e.stderr?.toString() ?? e.message,
          exitCode: e.exitCode ?? -1,
          command: fullCommand,
        };
      }
    }
Behavior5/5

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

Annotations already set readOnlyHint=true and idempotentHint=true. The description adds context: 'Runs npx restforge-cli config:template', 'READ-ONLY and safe to call repeatedly', 'No file is written', and a version requirement. No contradiction with annotations.

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?

Well-structured with clear sections (USE WHEN, DO NOT USE FOR). Front-loaded with core purpose. Presentation guidance is extra but relevant. Could be slightly more concise by merging some points, but overall efficient.

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

Completeness5/5

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

Given one parameter and no output schema, the description fully explains what the tool does, when to use it, its safety profile, and internal command. Includes version prerequisite. No gaps.

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?

Only one parameter (cwd) with high schema description coverage (100%). The schema already explains 'Absolute path of the project folder (must have restforgejs installed)'. Description doesn't add significant new parameter info beyond restating the requirement.

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 states 'Get raw template content of db-connection.env without writing any file.' It clearly identifies the resource (template content), action (get), and key behavior (no file writing). It distinguishes from siblings like setup_init_config and setup_read_env.

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?

Provides explicit use cases (drift detection, comparing config after modification) and a 'DO NOT USE FOR' section listing three sibling tools with their purposes. Includes example user queries in multiple languages.

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/restforge/restforge-mcp'

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