Subject: Announcing FPC/Lazarus MCP Server – Bring AI to your Pascal Workflow
Hi everyone,
I’m excited to share a new project designed to bridge the gap between Modern AI and the Free Pascal ecosystem:
FPC-Lazarus-MCP-Server (
https://github.com/xyzeugene/FPC-Lazarus-MCP-Server).
What is this?
This is a Model Context Protocol (MCP) server that allows AI models (like Gemini, Claude, and OpenCode) to interact
directly with your local Free Pascal and Lazarus environment. Instead of copying and pasting code, you can simply ask
the AI to compile your units, build your projects, or format your source code using natural language.
Quick Start (Setup in 3 Steps)
1. Prerequisites: Ensure fpc, lazbuild, and ptop are in your system PATH.
2. Install FastMCP: pip install fastmcp
3. Register the Server: Add the following to your MCP host configuration (e.g., claude_desktop_config.json):
1 {
2 "mcpServers": {
3 "fpc-lazarus": {
4 "command": "python",
5 "args": ["/path/to/fpc_mcp_server.py"]
6 }
7 }
8 }
How to Use (Prompting AI)
Once registered, you can use natural language to control your Pascal environment. Here are some examples of what you
can ask the AI:
* Check Environment: "What versions of FPC and Lazarus are installed?"
* Compile Code: "Compile the Pascal file at src/main.pas and output it to bin/main.exe."
* Build Project: "Find the .lpi project in the current directory and build it in 'Release' mode."
* Debug Build Modes: "Show me all the available build modes for my Lazarus project."
* Clean Workspace: "Clean my project and remove all the temporary lib and backup folders."
* Run Binary: "Run the compiled binary at ./bin/main.exe and tell me what it prints."
* Format Source: "Format all the .pas files in the src/ directory to follow standard Pascal conventions."
Key Features:
* 🚀 Smart Compilation: Ask the AI to compile .pas or .lpr files using fpc directly.
* 🏗️ Lazarus Integration: Full support for lazbuild to build .lpi projects and inspect build modes.
* 🧹 Safe Cleanup: Tools to safely remove lib and backup artifacts across your workspace.
* ⏱️ Secure Execution: Run your compiled binaries within a secure, timed environment and capture the output for the
AI to analyze.
* ✨ Automated Formatting: Use ptop through the AI to keep your codebases consistent and clean.
Professional Test Suite Included
The project also features a comprehensive, object-oriented test suite written in Python. It’s heavily commented and
serves as an educational example for those interested in:
* Pathlib: Dynamic, portable path discovery.
* Dataclasses: Structured data management.
* Functional Dispatch: Clean, extensible test runners.
* Memory Diagnostics: Stability tracking for long-running processes.
GitHub Repository:
https://github.com/xyzeugene/FPC-Lazarus-MCP-Server (
https://github.com/xyzeugene/FPC-Lazarus-MCP-Server)
I'd love to hear your feedback or see your contributions!
Happy coding!