Announcing FPC/Lazarus MCP Server – Bring AI to your Pascal Workflow lazarus / 83-Pascal and AI ---------------------------------------------------------------------- xyzeugene · 2026-03-21 11:54 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! ---------------------------------------------------------------------- ginoo · 2026-03-22 14:18 interesting, I'll try it later ---------------------------------------------------------------------- VisualLab · 2026-03-23 08:30 This could be interesting if it were written in Object Pascal and ran as a Lazarus extension (package). Unfortunately it is "done" in Python. Such "gluing" the work environment from different pieces ("each from a different parish") causes mess and various problems ("tearing" one's nerves with different versions of Python). What a lousy time it is with this idiotic fashion for "making scripts" instead of creating real programs. ---------------------------------------------------------------------- Joanna · 2026-03-23 09:40 Why no Code tags?  Is this post just to occupy maximum space? ---------------------------------------------------------------------- jamie · 2026-03-23 10:28 Quote from: VisualLab on March 23, 2026, 09:30:22 amThis could be interesting if it were written in Object Pascal and ran as a Lazarus extension (package). Unfortunately it is "done" in Python. Such "gluing" the work environment from different pieces ("each from a different parish") causes mess and various problems ("tearing" one's nerves with different versions of Python). What a lousy time it is with this idiotic fashion for "making scripts" instead of creating real programs. They call that script kiddies, once they figure out how to configure one, they call themselves a PROGRAMMER, a serious one at that! And you are correct; it's a mess just to load all those required libs that have been written by real professionals/Programmers that allows for this atrocity, maybe they are partially to blame for this. Jamie ---------------------------------------------------------------------- valdir.marcos · 2026-03-25 21:25 Quote from: jamie on March 23, 2026, 11:28:08 amQuote from: VisualLab on March 23, 2026, 09:30:22 amThis could be interesting if it were written in Object Pascal and ran as a Lazarus extension (package). Unfortunately it is "done" in Python. Such "gluing" the work environment from different pieces ("each from a different parish") causes mess and various problems ("tearing" one's nerves with different versions of Python). What a lousy time it is with this idiotic fashion for "making scripts" instead of creating real programs. They call that script kiddies, once they figure out how to configure one, they call themselves a PROGRAMMER, a serious one at that! And you are correct; it's a mess just to load all those required libs that have been written by real professionals/Programmers that allows for this atrocity, maybe they are partially to blame for this. Jamie Real programmers are expensive, however vibe coding, no code, low code, script kids, AI kids, etc are not. Real programmers are forged with money, time, effort, and professional career built over the years. ---------------------------------------------------------------------- C0m3b4ck · 2026-03-26 16:48 Quote from: VisualLab on March 23, 2026, 09:30:22 amThis could be interesting if it were written in Object Pascal and ran as a Lazarus extension (package). Unfortunately it is "done" in Python. Such "gluing" the work environment from different pieces ("each from a different parish") causes mess and various problems ("tearing" one's nerves with different versions of Python). What a lousy time it is with this idiotic fashion for "making scripts" instead of creating real programs. Python is used because it has short syntax, a lot of pre-made functions and is quite portable. That is why "AI developers" and "developers of AI tools" tend to use Python - making that in a language like C++ would be quite time consuming, especially for a single-person project. For me, as long as the dev behind it understands their code enough to modify and improve it, all goes. ---------------------------------------------------------------------- Thausand · 2026-03-26 18:11 Critical Python supply chain compromise: how library used by millions of AI developers got infected with malware Not write that not happen for write in pascal/c/c++ but all python depend other python and any one write python. So when make use automata system then have make sure all is ok. ---------------------------------------------------------------------- marcov · 2026-03-26 18:27 Quote from: C0m3b4ck on March 26, 2026, 05:48:35 pmPython is used because it has short syntax, a lot of pre-made functions and is quite portable. While that might be, any project that requires multiple language skills only gets a fraction of the available user base. Even when people prototype using Python, they might not want to add it as a dependency to the final product. ---------------------------------------------------------------------- C0m3b4ck · 2026-03-27 04:54 Quote from: marcov on March 26, 2026, 07:27:19 pmEven when people prototype using Python, they might not want to add it as a dependency to the final product. That is, mostly, true. However, there are some business apps made mostly in Python and our *beloved* megacorporations such as Meta and Microslop even use A LOT of it in their backends. I tried distributing a Python program with a lot of dependencies that I compiled with Pyinstaller. Turns out the dependencies needed to be distributed along with the binary - turns out there were more than 20 library files needed. So Python does indeed stay mostly as a scripting language rather than one for finished apps. ---------------------------------------------------------------------- marcov · 2026-03-27 09:10 Quote from: C0m3b4ck on March 27, 2026, 05:54:26 amThat is, mostly, true. However, there are some business apps made mostly in Python and our *beloved* megacorporations such as Meta and Microslop even use A LOT of it in their backends. I don't have billions in the bank and don't employ hundreds of thousands of developers. So that analogy might not fly. ---------------------------------------------------------------------- mercurhyo · 2026-03-27 10:05 As usually... Marcov +100 This is a pascalish forum: a place meant to be a safe pascal programmers place. Furthermore, I can't imagine me opening a thread on a py forum to expose my pascal api on a pascalscript to their tools (with or without Eval(billions) ) I ain't un-pool-lite I guess ---------------------------------------------------------------------- jc99 · 2026-09-11 22:56 I was looking for an MCP-Server for lazarus, and I came across this thread. I first thought, if there is nothing else, it's at least a start, despite written in python, instead of complainig, do it ! Write a MCP- Server in Lazarus. But then I found that Michael Van Canneyt just did that ! ( Shoutout  @Michael    ) Here: https://gitlab.com/freepascal.org/mcp Why did anybody point to that incredible project ? So I startet playing with this, and did some fixing and improving: Here: https://github.com/joecare99/gl-fpc-mcp Quote from: jc99 on September 12, 2026, 12:41:23 amSee also here ... ---------------------------------------------------------------------- ALLIGATOR · 2026-09-12 05:16 Quote from: jc99 on September 12, 2026, 12:56:20 am...and did some fixing and improving... Personally, I think that if the changes are just improvements and fixes, it's better to incorporate them into the original project rather than create a fork ---------------------------------------------------------------------- jc99 · 2026-09-12 07:27 I tried, since I don't have a GitLab-Account, I was not able to post patches/issues/stuff. but nothing is lost, git makes it possible to cherry-pick, pull, push, merge, whatever you like, --> because I cloned the original repo. By the way there are other gitlab-github clones too like https://github.com/fpc/FPCSource and https://github.com/fpc/Lazarus ---------------------------------------------------------------------- DavidL · 2026-09-12 13:12 This entire thread should be moved to the "Pascal and AI" forum.  That forum was created especially for all things AI-slop and Pascal to avoid infecting the other forums. ---------------------------------------------------------------------- dsiders · 2026-09-12 16:11 Quote from: DavidL on September 12, 2026, 03:12:58 pmThis entire thread should be moved to the "Pascal and AI" forum.  That forum was created especially for all things AI-slop and Pascal to avoid infecting the other forums. +1 ---------------------------------------------------------------------- MarkMLl · 2026-09-13 08:07 Could I have a reality check please: does an MCP request in this context start off a fresh copy of the FPC compiler every time, i.e. like the execution of a CGI script on a web server or a plugin in InkScape etc.? ISTM that this could result in dozens or hundreds of compiler invocations during the course of a session, which goes against the grain of one of FPC's claimed strengths i.e. that a single invocation handles the main file of a program plus all static dependencies. Could anything be done to load the compiler into memory at initial MCP invocation, and then handle subsequent invocations via a backdoor entry point? Continuing the analogy of a web server and focusing explicitly on Apache, I mean something like mod_cgid or mod_perl rather than the simple mod_cgi. MarkMLl ---------------------------------------------------------------------- jc99 · 2026-09-13 13:47 @MarkMLI: You are talking about the Python-MCP, aren't you ? ---------------------------------------------------------------------- MarkMLl · 2026-09-14 07:36 Quote from: jc99 on September 13, 2026, 03:47:50 pm@MarkMLI: You are talking about the Python-MCP, aren't you ? I don't see why the language the MCP shim is written in is relevant. MarkMLl ---------------------------------------------------------------------- jc99 · 2026-09-14 18:12 Quote from: MarkMLl on September 14, 2026, 09:36:32 amQuote from: jc99 on September 13, 2026, 03:47:50 pm@MarkMLI: You are talking about the Python-MCP, aren't you ? I don't see why the language the MCP shim is written in is relevant. MarkMLl It is, because the Pascal-one can be integrated into Lazarus, while the other only calls the tools from extern. Please read the COMPLETE thread, if you want to know why it matters. If I would go to a Python-Forum and would tell them "Hey I got this hot new thing, written in pascal ..." Think what they woud say. For me it was to differnciate, whether you are talkin about the one or the other tool. So are you talking about the one or the other ?We take your observaion seriously, so we have to know exactly what you mean, and who is the best person to handle your request. ---------------------------------------------------------------------- MarkMLl · 2026-09-15 06:29 I have of course read it, and most of it is the usual level of language chauvinism: look, I don't like Python but on occasion one has to recognise that a certain area of endeavour has a widely-accepted lingua franca, and doing anything else is tantamount to saying "I refuse to engage with ATC because they all speak English". I've also read MVC's stuff on GitLab, and can now see that in part this is to drive Lazarus not FPC per se. However the same question still stands: if MCP or anything it invokes makes a single-character syntax change which it wants to check with a trial build it will invoke the compiler: and since it's really got limited (if any) actual intelligence it will be doing that repeatedly and iteratively. And that's a massive waste of resources. MarkMLl ---------------------------------------------------------------------- gidesa · 2026-09-16 15:23 When you use Lazarus, after every modify you rerun the compiler/build. The compiler does all normal check to search only for changed units included in project (directly or indirectly), and recompile them. The trick is to use compiler through Lazarus, that has knowledge of projects. If the MCP, or any other automation tool, doesn't have any idea of projects, it must recompile every units, or has to reimplement same functions of Lazarus. I don't know if this Python MCP call directly the compiler, and has the notion of project. If this isn't, then you are right, there should be much more compilations. EDIT: it say that the MCP can use Lazarus projects: "Lazarus Integration: Full support for lazbuild to build .lpi projects and inspect build modes." ---------------------------------------------------------------------- kveroneau · 2026-09-20 17:05 Quote from: jc99 on September 14, 2026, 08:12:45 pmIt is, because the Pascal-one can be integrated into Lazarus, while the other only calls the tools from extern. Please read the COMPLETE thread, if you want to know why it matters. If I would go to a Python-Forum and would tell them "Hey I got this hot new thing, written in pascal ..." Think what they woud say. That is completely understandable, and when first seeing this thread today, as it was recently bumped, I was actually surprised at first that it wasn't a Lazarus package with IDE integration, but instead was a Python script, requiring a bunch of Python dependencies to be installed in order to use. Because of the many supply chain issues, I am always very hesitant to install any interpreted languages and a swath of packages which aren't a part of my distros official repository.  I also don't use Linux distros that require me to use 3rd party repos for the same reason, I only install packages from my distro's officially supported repo, as then I know they are all vetted by the distro to work and shouldn't pose any potential security risks.  In our modern world, we need to always assume that our supply chains can be comprised.  These sort of issues seem to always target Python and specially Node.JS, the latter I completely refuse to even have a local Node.JS binary installed because of how much it's in the News... I also find it rather interesting that someone tried to compare writing a program in C++ and in Object Pascal...  Writing a full program in Object Pascal is almost as easy as writing a program in Python, there is no comparison to C++, which does require a lot more to get stuff done.  With Object Pascal, you reap similar benefits to that of Python, except your program is compiled.  Object Pascal, if used with just TComponents, and no raw pointers has the ability to almost manage all of your memory for you, and even when you create instances of TObjects, using try/finally to .Free is incredibly trivial and a non-issue in Object Pascal.  This is what makes Object Pascal rather incredible when compared to other compiled languages, as it actually does a lot of the heavy lifting you see from other languages like Python, but also fully supports manual memory management for those parts of your code that need that extra bit of performance.  Object Pascal puts both the choice and balance in the hands of the programmer, I can choose to manage memory, or just let Object Pascal handle it for me, it's nice.  Other languages don't usually give you that choice.  Pardon my rant, but I really do believe in the potential of Object Pascal, and hate seeing something so amazing just being overlooked because it isn't as popular as Insert popular language here.