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

delphi.build

Build Delphi .dproj or .groupproj projects using MSBuild with RAD Studio environment configuration for Windows development workflows.

Instructions

Build a Delphi .dproj or .groupproj using MSBuild with RAD Studio environment

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectYesPath to a Delphi .dproj or .groupproj file
configurationNoRelease
platformNoWin64
msbuildPathNoOptional path to msbuild.exe to use
rsvarsPathNoOptional path to rsvars.bat to initialize RAD Studio env

Implementation Reference

  • Core handler function that executes the Delphi project build using MSBuild, including environment setup with rsvars.bat, argument preparation, and command execution.
    async function buildWithMSBuild({ project, configuration, platform, msbuildPath, rsvarsPath }: { project: string; configuration?: string; platform?: string; msbuildPath?: string; rsvarsPath?: string; }) { const projPath = resolve(project); if (!existsSync(projPath)) { throw new Error(`Project not found: ${projPath}`); } if (!isDelphiProject(projPath)) { throw new Error('Unsupported project type. Provide a .dproj or .groupproj file'); } const { rsvars, msbuild } = resolveDefaults(); const rsvarsFinal = rsvarsPath || rsvars; const msbuildFinal = msbuildPath || msbuild || 'msbuild'; // Prepare MSBuild arguments const args = [ '"' + projPath + '"', '/t:Build', configuration ? `/p:Config=${configuration}` : '', platform ? `/p:Platform=${platform}` : '' ].filter(Boolean); // If rsvars is available, run in a single shell using cmd and call if (rsvarsFinal && existsSync(rsvarsFinal)) { const cmd = 'cmd'; const composite = [ '/s', '/c', `"@echo off && call \"${rsvarsFinal}\" && ${msbuildFinal} ${args.join(' ')}"` ]; return await runCommand(cmd, composite); } // Otherwise, rely on msbuild directly (if in PATH or explicit) return await runCommand(msbuildFinal, args); }
  • Zod-based input schema defining parameters for the delphi.build tool: project path, configuration, platform, msbuild and rsvars paths.
    const BuildInput = { project: z.string().describe('Path to a Delphi .dproj or .groupproj file'), configuration: z.string().optional().default(process.env.DELPHI_CONFIG || 'Release'), platform: z.string().optional().default(process.env.DELPHI_PLATFORM || 'Win32'), msbuildPath: z.string().optional().describe('Optional path to msbuild.exe to use'), rsvarsPath: z.string().optional().describe('Optional path to rsvars.bat to initialize RAD Studio env') };
  • src/server.ts:216-231 (registration)
    MCP server registration of the 'delphi.build' tool, specifying description, input schema, and inline handler that calls buildWithMSBuild and formats the response.
    mcpServer.registerTool('delphi.build', { description: 'Build a Delphi .dproj or .groupproj using MSBuild with RAD Studio environment', inputSchema: BuildInput, }, async (req: any) => { const { code, stdout, stderr } = await buildWithMSBuild(req); const ok = code === 0; return { content: [ { type: 'text', text: ok ? `Build succeeded for ${basename(req.project)}` : `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 }; });
  • Utility function to spawn and manage child processes for running build commands, capturing stdout, stderr, and exit code.
    function runCommand(cmd: string, args: string[], options: { cwd?: string, env?: NodeJS.ProcessEnv } = {}) { return new Promise<{ code: number | null, stdout: string, stderr: string }>((resolvePromise) => { const child = spawn(cmd, args, { cwd: options.cwd, env: { ...process.env, ...options.env }, shell: true, // allow .bat/.cmd wrappers on Windows windowsHide: true }); let stdout = ''; let stderr = ''; child.stdout.on('data', (d) => { stdout += d.toString(); }); child.stderr.on('data', (d) => { stderr += d.toString(); }); child.on('close', (code) => resolvePromise({ code, stdout, stderr })); }); }
  • Helper to check if a file is a Delphi project file (.dproj or .groupproj).
    function isDelphiProject(file: string) { const ext = extname(file).toLowerCase(); return ext === '.dproj' || ext === '.groupproj';
  • Helper to resolve default paths for rsvars.bat and msbuild from environment variables.
    function resolveDefaults() { const rsvars = process.env.RSVARS_BAT || process.env.RSVARS_PATH; const msbuild = process.env.MSBUILD_PATH; return { rsvars, msbuild }; }

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