Recent

Author Topic: Announcing FPC/Lazarus MCP Server – Bring AI to your Pascal Workflow  (Read 2554 times)

xyzeugene

  • Newbie
  • Posts: 6
  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

  • Full Member
  • ***
  • Posts: 166
interesting, I'll try it later

VisualLab

  • Hero Member
  • *****
  • Posts: 742
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

  • Hero Member
  • *****
  • Posts: 1461
Why no Code tags? ;D
 Is this post just to occupy maximum space?

jamie

  • Hero Member
  • *****
  • Posts: 7774
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.
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
The only true wisdom is knowing you know nothing

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1285
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.

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

  • New Member
  • *
  • Posts: 30
  • Open-source programs for Windows 95-11 and Linux
    • Github
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.

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.
Github profile - https://github.com/C0m3b4ck | YouTube Channel - https://youtube.com/@PrinterFixer
Current Pascal project - https://github.com/C0m3b4ck/BookwormPascal - library book management app

Still making sure I support Win95 for its users out there...

Thausand

  • Hero Member
  • *****
  • Posts: 560
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.
A docile goblin always follow HERMES.md

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12905
  • FPC developer.
Python 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

  • New Member
  • *
  • Posts: 30
  • Open-source programs for Windows 95-11 and Linux
    • Github
Even 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.
Github profile - https://github.com/C0m3b4ck | YouTube Channel - https://youtube.com/@PrinterFixer
Current Pascal project - https://github.com/C0m3b4ck/BookwormPascal - library book management app

Still making sure I support Win95 for its users out there...

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12905
  • FPC developer.
Re: Announcing FPC/Lazarus MCP Server – Bring AI to your Pascal Workflow
« Reply #10 on: March 27, 2026, 10:10:38 am »
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 don't have billions in the bank and don't employ hundreds of thousands of developers. So that analogy might not fly.


mercurhyo

  • Sr. Member
  • ****
  • Posts: 265
Re: Announcing FPC/Lazarus MCP Server – Bring AI to your Pascal Workflow
« Reply #11 on: March 27, 2026, 11:05:15 am »
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
 ;)
« Last Edit: March 27, 2026, 11:20:44 am by mercurhyo »
DEO MERCHVRIO - Fedora PlasmaKDE, Win11pro - Ryzen9XT+Geforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

 

TinyPortal © 2005-2018