Skip to main content
Glama
flydev-fr
by flydev-fr

lazarus.build

Compile Lazarus projects (.lpi) using lazbuild with configurable build modes, target CPU, and OS settings.

Instructions

Build a Lazarus (.lpi) project using lazbuild

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectYesPath to a Lazarus project file (.lpi)
buildModeNoLazarus build mode name (maps to --bm)
cpuNoTarget CPU for lazbuild (e.g. x86_64, i386, aarch64)
osNoTarget OS for lazbuild (e.g. win64, win32, linux)
lazbuildPathNoPath to lazbuild (defaults to "lazbuild")

Implementation Reference

  • Core handler function that validates the Lazarus project (.lpi), constructs lazbuild arguments, and executes the build command.
    async function lazarusBuild({ project, buildMode, cpu, os, lazbuildPath }: { project: string; buildMode?: string; cpu?: string; os?: string; lazbuildPath?: string; }) {
      const projPath = resolve(project);
      if (!existsSync(projPath)) {
        throw new Error(`Project not found: ${projPath}`);
      }
      if (!isLazarusProject(projPath)) {
        throw new Error('Unsupported project type. Provide a .lpi file');
      }
      const args: string[] = ['--build-mode='];
      if (buildMode) args[0] = `--build-mode=${buildMode}`; else args.pop();
      if (cpu) args.push(`--cpu=${cpu}`);
      if (os) args.push(`--os=${os}`);
      args.push('"' + projPath + '"');
      const lazbuild = lazbuildPath || 'lazbuild';
      return await runCommand(lazbuild, args, { cwd: dirname(projPath) });
    }
  • Input schema definition using Zod for validating parameters to the lazarus.build tool.
    const LazarusBuildInput = {
      project: z.string().describe('Path to a Lazarus project file (.lpi)'),
      buildMode: z.string().optional().describe('Lazarus build mode name (maps to --bm)'),
      cpu: z.string().optional().describe('Target CPU for lazbuild (e.g. x86_64, i386, aarch64)'),
      os: z.string().optional().describe('Target OS for lazbuild (e.g. win64, win32, linux)'),
      lazbuildPath: z.string().optional().describe('Path to lazbuild (defaults to "lazbuild")')
    };
  • src/server.ts:269-284 (registration)
    Registration of the 'lazarus.build' tool with MCP server, including description, schema, and thin wrapper handler that calls lazarusBuild and formats MCP response.
    mcpServer.registerTool('lazarus.build', {
      description: 'Build a Lazarus (.lpi) project using lazbuild',
      inputSchema: LazarusBuildInput,
    }, async (req: any) => {
      const { code, stdout, stderr } = await lazarusBuild(req);
      const ok = code === 0;
      return {
        content: [
          { type: 'text', text: ok ? `Lazarus build succeeded for ${basename(req.project)}` : `Lazarus build failed for ${basename(req.project)}` },
          { type: 'text', text: `Exit code: ${code}` },
          { type: 'text', text: '--- STDOUT ---\n' + stdout },
          { type: 'text', text: '--- STDERR ---\n' + stderr }
        ],
        isError: !ok
      };
    });
  • Helper function to check if a file is a Lazarus project file (.lpi), used in lazarusBuild validation.
    function isLazarusProject(file: string) {
      return extname(file).toLowerCase() === '.lpi';
    }

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/flydev-fr/mcp-delphi'

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