[fpc-devel] LLM / MCP
Michael Van Canneyt
michael at freepascal.org
Sat Oct 4 15:36:56 CEST 2025
Hi,
For those that are busy with LLM and MCP:
I've created 2 repos:
https://gitlab.com/freepascal.org/llm
This contains client-side classes that allow you to use the APIs of the
major LLM vendors (OpenAI, Anthropic, Google Gemini and OLLama, JanAI).
There is an example for each API.
The intent is to use this to allow using any LLM in the lazarus IDE.
For people that want to go a step further:
The following repo contains an implementation of the MCP (Model
Context Protocol):
https://gitlab.com/freepascal.org/mcp
The MCP protocol allows you to write a tool that is usable by most AI agents
today. What you can do with the classes is to write an MCP server which is
then used by the agent (and allows the LLM to execute commands).
As an example, there is a MCP server that allows an Agent to execute SQL queries
on any FPC-supported database. It allows one to ask to retrieve information
from the database in natural language. The agent will then transform the
natural language to SQL and retrieve the result. I've had surpringly good
results using Google Gemini.
The tool by default does not allow to modify the data or structure of the database.
Since retrieved data is sent to a LLM, be careful not to send any
personal data over the line for privacy reasons.
Articles describing how to use this will follow.
Michael.
More information about the fpc-devel
mailing list