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
| Name | Required | Description | Default |
|---|---|---|---|
| project | Yes | Path to a Lazarus project file (.lpi) | |
| buildMode | No | Lazarus build mode name (maps to --bm) | |
| cpu | No | Target CPU for lazbuild (e.g. x86_64, i386, aarch64) | |
| os | No | Target OS for lazbuild (e.g. win64, win32, linux) | |
| lazbuildPath | No | Path to lazbuild (defaults to "lazbuild") |
Implementation Reference
- src/server.ts:179-194 (handler)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) }); }
- src/server.ts:56-62 (schema)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 }; });
- src/server.ts:175-177 (helper)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'; }