Skip to main content
Glama

test_local_deployment

Test documentation builds and local servers before deploying to GitHub Pages. Configure repository path, static site generator, port, and timeout settings.

Instructions

Test documentation build and local server before deploying to GitHub Pages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repositoryPathYesPath to the repository
ssgYes
portNoPort for local server
timeoutNoTimeout in seconds for build process
skipBuildNoSkip build step and only start server

Implementation Reference

  • The main handler function that executes the test_local_deployment tool logic: parses input schema, changes to repo dir, installs deps, builds site, starts local server, generates test script, and returns structured results with recommendations.
    export async function testLocalDeployment(
      args: unknown,
    ): Promise<{ content: any[] }> {
      const startTime = Date.now();
      const { repositoryPath, ssg, port, timeout, skipBuild } =
        inputSchema.parse(args);
    
      try {
        const config = SSG_CONFIGS[ssg];
        if (!config) {
          throw new Error(`Unsupported SSG: ${ssg}`);
        }
    
        // Change to repository directory
        process.chdir(repositoryPath);
    
        const testResult: LocalTestResult = {
          repositoryPath,
          ssg,
          buildSuccess: false,
          serverStarted: false,
          port,
          testScript: "",
          recommendations: [],
          nextSteps: [],
        };
    
        // Step 1: Check if configuration exists (always check, even if skipBuild)
        const configExists = await checkConfigurationExists(repositoryPath, config);
        if (!configExists) {
          testResult.recommendations.push(
            `Missing configuration file. Expected one of: ${config.configFiles.join(
              ", ",
            )}`,
          );
          testResult.nextSteps.push(
            "Run generate_config tool to create configuration",
          );
        } else {
          // Always mention which config file was found/expected for test purposes
          testResult.recommendations.push(
            `Using ${ssg} configuration: ${config.configFiles.join(" or ")}`,
          );
        }
    
        // Step 2: Install dependencies if needed
        if (config.installCommand && !skipBuild) {
          try {
            const { stderr } = await execAsync(config.installCommand, {
              cwd: repositoryPath,
              timeout: timeout * 1000,
            });
            if (stderr && !stderr.includes("npm WARN")) {
              testResult.recommendations.push(
                "Dependency installation warnings detected",
              );
            }
          } catch (error: any) {
            testResult.recommendations.push(
              `Dependency installation failed: ${error.message}`,
            );
            testResult.nextSteps.push(
              "Fix dependency installation issues before testing deployment",
            );
          }
        }
    
        // Step 3: Build the site (unless skipped)
        if (!skipBuild) {
          try {
            const { stdout, stderr } = await execAsync(config.buildCommand, {
              cwd: repositoryPath,
              timeout: timeout * 1000,
            });
            testResult.buildSuccess = true;
            testResult.buildOutput = stdout;
    
            if (stderr && stderr.trim()) {
              testResult.buildErrors = stderr;
              if (stderr.includes("error") || stderr.includes("Error")) {
                testResult.recommendations.push(
                  "Build completed with errors - review build output",
                );
              }
            }
    
            // Check if build directory was created
            const buildDirExists = await checkBuildOutput(
              repositoryPath,
              config.buildDir,
            );
            if (!buildDirExists) {
              testResult.recommendations.push(
                `Build directory ${config.buildDir} was not created`,
              );
            }
          } catch (error: any) {
            testResult.buildSuccess = false;
            testResult.buildErrors = error.message;
            testResult.recommendations.push(
              "Build failed - fix build errors before deployment",
            );
            testResult.nextSteps.push(
              "Review build configuration and resolve errors",
            );
          }
        } else {
          testResult.buildSuccess = true; // Assume success if skipped
        }
    
        // Step 4: Generate test script
        testResult.testScript = generateTestScript(
          ssg,
          config,
          port,
          repositoryPath,
        );
    
        // Step 5: Try to start local server (non-blocking)
        if (testResult.buildSuccess || skipBuild) {
          const serverResult = await startLocalServer(
            config,
            port,
            repositoryPath,
            10,
          ); // 10 second timeout for server start
          testResult.serverStarted = serverResult.started;
          testResult.localUrl = serverResult.url;
    
          if (testResult.serverStarted) {
            testResult.recommendations.push(
              "Local server started successfully - test manually at the provided URL",
            );
            testResult.nextSteps.push("Verify content loads correctly in browser");
            testResult.nextSteps.push("Test navigation and responsive design");
          } else {
            testResult.recommendations.push(
              "Could not automatically start local server - run manually using the provided script",
            );
            testResult.nextSteps.push(
              "Start server manually and verify it works before GitHub deployment",
            );
          }
        }
    
        // Step 6: Generate final recommendations
        if (testResult.buildSuccess && testResult.serverStarted) {
          testResult.recommendations.push(
            "Local deployment test successful - ready for GitHub Pages",
          );
          testResult.nextSteps.push(
            "Run deploy_pages tool to set up GitHub Actions workflow",
          );
        } else if (testResult.buildSuccess && !testResult.serverStarted) {
          testResult.recommendations.push(
            "Build successful but server test incomplete - manual verification needed",
          );
          testResult.nextSteps.push(
            "Test server manually before deploying to GitHub",
          );
        }
    
        const response: MCPToolResponse<typeof testResult> = {
          success: true,
          data: testResult,
          metadata: {
            toolVersion: "1.0.0",
            executionTime: Date.now() - startTime,
            timestamp: new Date().toISOString(),
          },
          recommendations: [
            {
              type: testResult.buildSuccess ? "info" : "warning",
              title: "Local Deployment Test Complete",
              description: `Build ${
                testResult.buildSuccess ? "succeeded" : "failed"
              }, Server ${
                testResult.serverStarted ? "started" : "failed to start"
              }`,
            },
          ],
          nextSteps: testResult.nextSteps.map((step) => ({
            action: step,
            toolRequired: getRecommendedTool(step),
            description: step,
            priority: testResult.buildSuccess ? "medium" : ("high" as const),
          })),
        };
    
        return formatMCPResponse(response);
      } catch (error) {
        const errorResponse: MCPToolResponse = {
          success: false,
          error: {
            code: "LOCAL_TEST_FAILED",
            message: `Failed to test local deployment: ${error}`,
            resolution:
              "Ensure repository path is valid and SSG is properly configured",
          },
          metadata: {
            toolVersion: "1.0.0",
            executionTime: Date.now() - startTime,
            timestamp: new Date().toISOString(),
          },
        };
        return formatMCPResponse(errorResponse);
      }
    }
  • Zod schema for input validation: requires repositoryPath and ssg, optional port, timeout, skipBuild.
    const inputSchema = z.object({
      repositoryPath: z.string().describe("Path to the repository"),
      ssg: z.enum(["jekyll", "hugo", "docusaurus", "mkdocs", "eleventy"]),
      port: z.number().optional().default(3000).describe("Port for local server"),
      timeout: z
        .number()
        .optional()
        .default(60)
        .describe("Timeout in seconds for build process"),
      skipBuild: z
        .boolean()
        .optional()
        .default(false)
        .describe("Skip build step and only start server"),
    });
  • Configuration object mapping SSG names to their build/serve commands, output dirs, config files, and install commands.
    const SSG_CONFIGS: Record<string, SSGConfig> = {
      jekyll: {
        buildCommand: "bundle exec jekyll build",
        serveCommand: "bundle exec jekyll serve",
        buildDir: "_site",
        configFiles: ["_config.yml", "_config.yaml"],
        installCommand: "bundle install",
      },
      hugo: {
        buildCommand: "hugo",
        serveCommand: "hugo server",
        buildDir: "public",
        configFiles: [
          "hugo.toml",
          "hugo.yaml",
          "hugo.yml",
          "config.toml",
          "config.yaml",
          "config.yml",
        ],
      },
      docusaurus: {
        buildCommand: "npm run build",
        serveCommand: "npm run serve",
        buildDir: "build",
        configFiles: ["docusaurus.config.js", "docusaurus.config.ts"],
        installCommand: "npm install",
      },
      mkdocs: {
        buildCommand: "mkdocs build",
        serveCommand: "mkdocs serve",
        buildDir: "site",
        configFiles: ["mkdocs.yml", "mkdocs.yaml"],
        installCommand: "pip install -r requirements.txt",
      },
      eleventy: {
        buildCommand: "npx @11ty/eleventy",
        serveCommand: "npx @11ty/eleventy --serve",
        buildDir: "_site",
        configFiles: [".eleventy.js", "eleventy.config.js", ".eleventy.json"],
        installCommand: "npm install",
      },
    };
  • Helper to check if required config file exists for the SSG.
    async function checkConfigurationExists(
      repoPath: string,
      config: SSGConfig,
    ): Promise<boolean> {
      for (const configFile of config.configFiles) {
        try {
          await fs.access(path.join(repoPath, configFile));
          return true;
        } catch {
          // File doesn't exist, continue checking
        }
      }
      return false;
    }
Behavior2/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 mentions testing build and server, but doesn't disclose key behavioral traits: whether it modifies files, requires specific permissions, has rate limits, or what the output looks like (e.g., success/failure indicators). For a tool with 5 parameters and no annotations, this leaves significant gaps in understanding its behavior.

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 a single, clear sentence that efficiently conveys the tool's purpose without unnecessary words. It's front-loaded with the core action and context, making it easy to parse. Every part of the sentence earns its place by specifying what is tested and when.

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's complexity (5 parameters, no annotations, no output schema), the description is insufficient. It doesn't explain what 'test' entails (e.g., validation steps, error handling), the output format, or behavioral risks. For a tool that likely involves building and running a server, more detail is needed to ensure safe and correct usage.

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 80%, so the schema documents most parameters well (e.g., 'repositoryPath', 'port', 'timeout', 'skipBuild'). The description adds no parameter-specific information beyond what the schema provides. However, it implicitly contextualizes the parameters by mentioning 'documentation build' and 'local server', which aligns with 'ssg' and 'port'. Baseline 3 is appropriate given high schema coverage.

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: 'Test documentation build and local server before deploying to GitHub Pages.' It specifies the action (test) and the resource (documentation build and local server), and distinguishes it from deployment tools like 'deploy_pages' by focusing on pre-deployment testing. However, it doesn't explicitly differentiate from all siblings (e.g., 'setup_playwright_tests' might also involve testing), so it's not a perfect 5.

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 ('before deploying to GitHub Pages'), suggesting this tool should be used as a pre-deployment check. However, it doesn't provide explicit guidance on when to use it versus alternatives (e.g., 'verify_deployment' or 'simulate_execution'), nor does it mention any prerequisites or exclusions. The implied context is helpful but lacks specificity.

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/tosin2013/documcp'

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