Lazarus MCP Assistant
An in-process MCP server for the Lazarus IDE. Installs as a standard Lazarus package and exposes 156 IDE tools over HTTP so any MCP-capable AI assistant can read, edit, navigate, build, and inspect your project — without leaving the IDE.
The server runs inside the IDE, so it sees the open project, the editor buffers (also unsaved text), the compiler and the debugger. It listens on 127.0.0.1 by default and needs a bearer token. It changes files only inside the open project (docs/write-scope.md) and sends nothing on its own (docs/privacy.md).
Any MCP client that supports Streamable HTTP can connect. Reported to work, as of 2026-11-28: Claude Code, OpenCode (v2.4.2, #39) and ZCode (v0.17.3, #20).
Platform: Windows and Linux. The whole test suite, the debugger tests included, passes on the combinations below (FPC 3.2.2).
Lazarus Windows 11 Debian 12 4.6 (the reference version) passes GTK2: passes 4.8 (the lazarus_4_8tag, stable)passes GTK2: passes 5.0RC1 (the lazarus_5_0_RC1tag)passes GTK3: passes (GTK2 is not usable with 5.0RC1 here) Not supported: Lazarus trunk (4.99). It is known not to compile: the editor and project interfaces differ. Known differences on 5.0RC1: #29.
macOS is not tested and not claimed.
Why in-process HTTP?
Most MCP servers are stdio subprocesses: the AI client spawns them, reads their output on stdout, and they die when the session ends. That model does not work for an IDE plugin — a plugin lives inside the IDE process and cannot be spawned from the outside.
Running as an HTTP server inverts the ownership: the IDE starts the server; the AI client connects to it. This enables:
- Self-hosted development — you can use Claude Code to develop this plugin from inside the Lazarus IDE it is running in. Claude edits the source, rebuilds the IDE, and resumes the same session after restart. See Self-hosted development.
- Multiple simultaneous clients — any number of AI sessions can connect to the same running IDE instance. One session can work on the plugin while another works on a project built with it.
- Session persistence — the server stays running between AI sessions. No re-spawn, no re-configuration. Reconnect at any time.
Transport details: ADR-001.
Tool reference
156 tools, named <category>_<action> (in Claude Code: mcp__lazarus-ide__<tool_name>). Each has a title, a description
and annotations: readOnlyHint, destructiveHint (only for changes that neither Ctrl+Z nor form_history can take back),
idempotentHint. The full reference, with every tool, is in docs/tools.md.
| Category | What it does |
|---|---|
editor_* | Read, open, create, edit and save files; edits go through the editor buffer, so Ctrl+Z works |
code_* | CodeTools: outline, declarations, references, rename, extract method, completion, formatting, structural edits |
form_* | The form designer: components, properties, menus, collections, layout, undo |
debug_* | Breakpoints, run and step, locals, evaluate, call stack, registers, attach |
project_* | Build, run, create and open projects, settings, files, search, todos |
package_* | Create, open, compile, install and edit packages and their dependencies |
ide_* | Ping, rebuild the IDE, messages, dialogs, tests, reports; ide_show_markdown shows a Markdown report in an IDE tab (tables, code in the editor's colours, alerts, folding <details> blocks) |
git_* | Status, diff, blame, log, commit, branches, checkout, stash, tags, remotes (fetch, pull, push), merge, rebase, cherry-pick, squash, conflict resolution, archive, and git_serve (hands the repository to one test machine) |
Edits go through the editor buffer, so Ctrl+Z takes them back. Files created or changed outside the IDE are seen at once. Calls that take long (builds, test runs, program runs, git calls to a remote) report progress and can be cancelled (ADR-036); only Claude Code was observed to use this. Some tools were renamed in 1.7.0; the old names work through all of 1.x and are refused from 2.0 on: docs/renamed-tools.md.
What the tools may change
A tool changes a file only inside the open project's folder, the folder of a loaded package that is not part of
Lazarus, the git working tree holding either, and the temp folder; never inside a .git folder or the IDE's
settings folder. Limited mode (Tools > Options > MCP Assistant > Directories, off by default) narrows reads and
the opening of projects to folders you list. Details, and what the limits do not do:
docs/write-scope.md.
Safety
- One named token per client; Revoke cuts a client off at once (ADR-021).
- Limited mode narrows reads and the opening of projects to folders you list (docs/write-scope.md).
- Installing a package needs your consent; the setting is off by default (ADR-013).
- With several clients, the first one that drives the debugger owns the session; the others are refused until it ends or its lease expires (docs/tools.md).
- A native dialog that blocks the IDE is answered through
ide_answer_dialog; a consent dialog is never answered by a tool (docs/tools.md). - The tool-call log is off by default and holds no argument values (ADR-022).
Requirements
- Lazarus IDE 4.6, 4.8 or 5.0RC1 (see the table at the top; trunk is not supported); macOS is not tested
- Free Pascal Compiler 3.2.2 (bundled with Lazarus)
- An MCP client that supports Streamable HTTP (see the top of this page)
How to connect an assistant other than Claude Code: Another assistant, or none started by the IDE.
Package dependencies — all bundled with Lazarus: SynEdit, IDEIntf, FCL,
CodeTools, and jcfbase (JEDI Code Format, for code_format). JCF's IDE
plugin, jcfidelazarus, is optional; when it is installed, code_format uses
its settings.
Installation
- In Lazarus: Package → Open Package File (.lpk) → select
src/lazmcpassistant.lpk. - In the package dialog: Use → Install.
- Lazarus will ask to rebuild the IDE. Confirm. The IDE restarts with the plugin loaded.
Usage
-
In the IDE: Tools → MCP Assistant → Launch MCP Assistant.
- This starts the HTTP server on a random local port and opens Claude Code in a terminal window.
- Windows opens a new console. Linux opens the first terminal it finds:
x-terminal-emulator,gnome-terminal,konsole,xfce4-terminalorxterm. macOS opens Terminal.app. - The MCP config file is written to a stable path in your system temp directory and reused on subsequent launches.
-
The launcher hands Claude Code the server URL and bearer token through
--mcp-config; the config path is persisted inmcpassistantoptions.xml. -
Tools are available as
mcp__lazarus-ide__<tool_name>in Claude Code.
Another assistant, or none started by the IDE
The server does not need Claude Code. Tools → MCP Assistant → Start MCP Server (no assistant) starts it and
shows its address; it also starts with the IDE once it has been started once. If you would rather start it only
when you need it, untick Start the server when the IDE starts (Tools → Options → MCP Assistant → Server) and use
that menu item. An ide_rebuild restarts the IDE too: with the switch off it asks you first, because the server
stays down afterwards until you start it again. To connect an assistant, make a
token (Tools → MCP Assistant → Copy Server Config to Clipboard..., or Add token... in the options) and put
the server's url and the Authorization header into that assistant's MCP settings. The config the dialog copies
is in Claude Code's mcpServers format; other assistants name the same two things differently.
To have Launch MCP Assistant start another assistant, set its executable, and the arguments that hand it the
MCP config, under Options below (Claude Code's --mcp-config {config} --strict-mcp-config is the default;
{config} is the config file; leave the field empty for an assistant that finds the server by itself).
Options
Tools → Options → MCP Assistant (also Tools → MCP Assistant → Options...):
| Setting | Empty means |
|---|---|
| Assistant executable (Launch MCP Assistant) | claude on PATH |
| Working directory | The open project's directory |
| Arguments that hand over the MCP config | Nothing is passed. Default: --mcp-config {config} --strict-mcp-config (Claude Code); {config} is replaced by the config file |
| Extra command-line options | None |
Terminal command (Linux/macOS), e.g. kitty -e | Detect a terminal |
| git executable | git on PATH |
| Listen address (IPv4) | 127.0.0.1: this machine only. 0.0.0.0 or a machine address lets other machines connect over plain HTTP with the token: see ADR-020 |
| Test the connection | A button under the listen address: asks the running server what a client asks (the token, tools/list, a wrong token, a call into the IDE) and shows one line per check with the reason when one fails (ADR-032). The server listens on a numeric address (127.0.0.1), never localhost, which can resolve to ::1 first |
| Client tokens | One named token per client on another machine: Add token... shows it once, masked, with an eye button and buttons to copy the token or the whole client config; only a hash is stored, so a lost token is revoked and replaced. Revoke cuts a client off at once and ends its sessions. The primary token (what the IDE writes for clients on this machine) is never shown; Regenerate primary token... replaces it. See ADR-021 |
| Allow assistants to install packages | Off; see ADR-013 |
| Logging: tool-call log | Off. One begin and one end line per tool call (tool, caller, time, outcome, argument names and a hash of them; no argument values or results) in mcp-tools.log, rotated at 4 MB. See ADR-022 |
| Logging: log file | Empty: mcp-tools.log in the Lazarus config folder. Any other path moves the file |
| Logging: Messages window | Off. One line per finished tool call (name, duration, and the cut error text of a failed call) in the MCP Server view |
Settings are stored in mcpassistantoptions.xml in the IDE's primary config
directory, together with the server's token and port.
Self-hosted development
This plugin was built using itself: Claude edits the source through the tools, calls ide_rebuild, and carries on
in the rebuilt IDE with the same token and port. The loop, why it survives a restart and the boot-loop escape hatch:
docs/self-hosted-development.md. Design: ADR-004.
Knowledge injection
Every MCP client gets docs/system-prompt.md as the server's instructions in the initialize reply, which clients may add to the model's context (observed: Claude Code puts it into the system prompt). This short text covers workflows, tool preferences and the rules Claude must follow (package-install consent, debugger exceptions, rebuild/reconnect). It leaves per-tool details to the tool descriptions.
The Lazarus/FPC reference covers LCL component packages, installation patterns and common gotchas, so Claude doesn't hallucinate package names or import paths. It is served on demand as the lazarus-ide://reference MCP resource, and the system prompt tells Claude to read it before answering such questions.
To update the reference: edit docs/lazarus-knowledge.md, then run tools/gen_knowledge_inc.exe from the project root to regenerate src/lazarus_knowledge.inc and src/system_prompt.inc (build it once with fpc -MObjFPC -Scghi -FEtools tools/gen_knowledge_inc.pas), then rebuild the IDE. The same applies to docs/system-prompt.md.
Testing
A standalone FPCUnit project lives in tests/: lazbuild tests/mcpserver_tests.lpi, then
tests/mcpserver_tests --all --format=plain, or the ide_run_tests tool. Units without IDE dependencies are tested
in-process; everything else over HTTP against the running IDE. Suites, requirements and options:
docs/testing.md.
Architecture
The design decisions are recorded as ADRs; docs/adr/ lists them with one line each.
Documentation
- docs/tools.md: every tool
- docs/write-scope.md: where the tools may write, limited mode
- docs/privacy.md: what the plugin connects to, writes and starts (nothing is sent on its own)
- docs/renamed-tools.md: tools renamed in 1.7.0
- docs/testing.md: the test suites
- docs/self-hosted-development.md: developing the plugin with itself
- docs/adr/: design decisions
- docs/system-prompt.md and docs/lazarus-knowledge.md: what every client is told
Help wanted
- macOS builds. The plugin uses only LCL/IDE interfaces and has code for Terminal.app, but it has never been compiled or run on macOS. Contributions are welcome.
Provenance
Designed and directed by Sergei Pechenko: the requirements, design decisions (recorded as ADRs in docs/adr/), reviews and acceptance. Most of the code, tests and docs were written by Claude (Anthropic) from his prompts and decisions, and checked by the test suite and by using the tools inside the IDE they extend. Because the code is largely AI-generated, no warranty of originality is given beyond the license's disclaimer.
License
BSD-3-Clause — see LICENSE.