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

fpc.build

Compile Pascal source files (.lpr/.pas) using the Free Pascal Compiler to generate executable binaries with configurable CPU/OS targets and search paths.

Instructions

Build with Free Pascal Compiler (fpc) for a Pascal program or project file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYesPath to a Pascal program (.lpr/.pas) or unit to compile with FPC
outputNoOptional output binary path/name
definesNoConditional defines, e.g. FOO=1
unitPathsNoAdditional unit search paths (-Fu)
includePathsNoAdditional include search paths (-Fi)
cpuNoTarget CPU, e.g. x86_64, i386, aarch64
osNoTarget OS, e.g. win64, win32, linux
fpcPathNoPath to fpc compiler (defaults to "fpc")

Implementation Reference

  • Inline asynchronous handler function for the 'fpc.build' tool. It invokes buildWithFpc with the request parameters, checks the exit code, and returns a structured response with stdout/stderr content blocks.
    }, async (req: any) => {
      const { code, stdout, stderr } = await buildWithFpc(req);
      const ok = code === 0;
      return {
        content: [
          { type: 'text', text: ok ? `FPC build succeeded for ${basename(req.source)}` : `FPC build failed for ${basename(req.source)}` },
          { type: 'text', text: `Exit code: ${code}` },
          { type: 'text', text: '--- STDOUT ---\n' + stdout },
          { type: 'text', text: '--- STDERR ---\n' + stderr }
        ],
        isError: !ok
      };
    });
  • Zod-based input schema definition for the 'fpc.build' tool, specifying parameters such as source file, output, defines, paths, target CPU/OS, and fpc path.
    const FpcBuildInput = {
      source: z.string().describe('Path to a Pascal program (.lpr/.pas) or unit to compile with FPC'),
      output: z.string().optional().describe('Optional output binary path/name'),
      defines: z.array(z.string()).optional().describe('Conditional defines, e.g. FOO=1'),
      unitPaths: z.array(z.string()).optional().describe('Additional unit search paths (-Fu)'),
      includePaths: z.array(z.string()).optional().describe('Additional include search paths (-Fi)'),
      cpu: z.string().optional().describe('Target CPU, e.g. x86_64, i386, aarch64'),
      os: z.string().optional().describe('Target OS, e.g. win64, win32, linux'),
      fpcPath: z.string().optional().describe('Path to fpc compiler (defaults to "fpc")')
    };
  • src/server.ts:251-254 (registration)
    Registration of the 'fpc.build' MCP tool, specifying its name, description, and input schema, with the handler function provided next.
    mcpServer.registerTool('fpc.build', {
      description: 'Build with Free Pascal Compiler (fpc) for a Pascal program or project file',
      inputSchema: FpcBuildInput,
    }, async (req: any) => {
  • Core helper function that constructs FPC compiler arguments based on input parameters, validates the source file, and spawns the fpc process using runCommand.
    async function buildWithFpc({ source, output, defines, unitPaths, includePaths, cpu, os, fpcPath }: { source: string; output?: string; defines?: string[]; unitPaths?: string[]; includePaths?: string[]; cpu?: string; os?: string; fpcPath?: string; }) {
      const srcPath = resolve(source);
      if (!existsSync(srcPath)) {
        throw new Error(`Source not found: ${srcPath}`);
      }
      if (!isFpcSource(srcPath)) {
        throw new Error('Unsupported source type. Provide a .lpr/.pas/.pp');
      }
      const args: string[] = [];
      if (cpu) args.push(`-P${cpu}`);
      if (os) args.push(`-T${os}`);
      if (output) args.push(`-o${resolve(output)}`);
      (defines || []).forEach(d => args.push(`-d${d}`));
      (unitPaths || []).forEach(p => args.push(`-Fu${resolve(p)}`));
      (includePaths || []).forEach(p => args.push(`-Fi${resolve(p)}`));
      args.push('"' + srcPath + '"');
      const compiler = fpcPath || 'fpc';
      // Use the source directory as CWD so relative includes work
      return await runCommand(compiler, args, { cwd: dirname(srcPath) });
    }
  • Helper function to check if a file is a valid Free Pascal source file based on extension.
    function isFpcSource(file: string) {
      const ext = extname(file).toLowerCase();
      return ext === '.pas' || ext === '.pp' || ext === '.p' || ext === '.lpr';
    }

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observed

TDQS

C2.9/5.0
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 states the action ('Build') but lacks behavioral details such as whether this is a read-only or destructive operation, error handling, output format, or runtime implications. For a compilation tool with zero annotation coverage, this is a significant gap in transparency.

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, efficient sentence with zero waste, front-loading the core action ('Build with Free Pascal Compiler') and specifying the target. It is appropriately sized for the tool's complexity.

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 (8 parameters, no annotations, no output schema), the description is inadequate. It lacks behavioral context, usage guidelines, and details on return values or errors, leaving significant gaps for an AI agent to understand how to invoke it correctly beyond basic parameter input.

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 100%, so the schema fully documents all 8 parameters. The description adds no parameter-specific semantics beyond implying compilation of Pascal files, which is already covered by the schema. Baseline 3 is appropriate as the schema does the heavy lifting, but no extra value is added.

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 verb ('Build') and resource ('with Free Pascal Compiler for a Pascal program or project file'), making the purpose evident. It distinguishes from siblings like 'delphi.build' and 'lazarus.build' by specifying FPC, but doesn't explicitly contrast with them or mention non-compilation alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'delphi.build' or 'lazarus.build' is provided. The description implies usage for FPC compilation but lacks explicit context, prerequisites, or exclusions, leaving the agent to infer based on tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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