# lazarus-mcp-assistant [Health: Active]

**Category:** 🤖 Coding Agents  
**Repository:** https://github.com/tnt4brain/lazarus-mcp-assistant  
**GitHub Stars:** 19  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/lazarus-mcp-assistant

## Description
Bring Anthropic's MCP to Lazarus IDE. Let AI assistants natively code, refactor, debug, and design forms in Object Pascal.

## Tools
Capabilities this server exposes over MCP:

- **editor_get_active** — Active editor file path and current buffer content
- **editor_list_open** — All open editor tabs
- **editor_read_file** — Read any file by absolute path; prefers the live editor buffer (unsaved changes) over disk
- **editor_open** — Open a file in the editor without moving the cursor; returns `already_open
- **editor_create_file** — Create a new text file on the IDE's machine and open it; only inside the project, a loaded package's folder or the temp folder, never in `.git`, no overwrite unless `overwrite:true` (and not while open)
- **editor_get_cursor** — Read / move the cursor (opens the file if needed)
- **editor_get_selection** — Selected text and its range
- **editor_edit_text** — Preferred edit.** Replace `old_string` with `new_string`; fails if missing or ambiguous; `replace_all` for every match. Undoable with Ctrl+Z
- **editor_replace_range** — Replace a range given by start and end, or start and `delete_len` (no end inserts, empty text deletes) — for coordinates from `code_*` tools
- **editor_save** — Save a buffer (a form unit saves its `.lfm` too)
- **editor_revert** — Discard unsaved changes and reload from disk
- **editor_close** — Close a tab, discarding unsaved changes
- **code_get_outline** — Uses, types, class members and routines with line numbers (no bodies)
- **code_get_unit_interface** — The interface section of a unit
- **code_get_procedure_ast** — Locals (with type) and the statements of one routine as a tree (if/for/while/repeat/try/case/with, calls, assignments) with lines and columns; `depth` sets how many levels ([ADR-008](docs/adr/0008-structural-source-editing.md))
- **code_find_declaration** — Where an identifier is declared, with a context snippet; follows the uses clauses (RTL, sibling units) and works in a program; optional `line`/`col` pick a use
- **code_goto_declaration** — Jump the editor cursor to a declaration
- **code_get_identifier_info** — Type, declaration and hint text for the identifier at file/line/col
- **code_find_references** — Every reference to an identifier across the project (and the file asked about, even outside the project). `also` (`same_folder`, `lcl`, `components`, `rtl`, `fcl`, `packages`) and `search_dir` add other sources, e.g. to see how an API is used; only files that mention the name are parsed, at most `m…
- **code_rename_identifier** — Rename across all project files from the declaration or any reference, as the IDE's Rename Identifier does; `dry_run` lists the references first. Unit names are refused
- **code_find_descendants** — The classes (and interface implementers) below a class or interface, the whole tree unless `direct_only`; scope as `code_find_references` ([ADR-027](docs/adr/0027-navigation-and-refactoring-tools.md))
- **code_find_overrides** — The methods of the same name in the classes below the one that declares a method: override, reintroduce or plain
- **code_unit_dependencies** — Uses graph: of one unit (uses, used by, unneeded units) or of the whole project with its cycles
- **code_find_unused** — Symbols of a unit nothing refers to (a hint: widen the search before deleting public API)
- **code_extract_method** — Extract statements into a procedure or method, as the IDE's Extract Procedure; `dry_run` reports what is possible
- **package_move_unit** — Move a unit between two packages and add the requirement that makes necessary; refuses a cycle; `dry_run` shows the plan
- **code_add_uses** — Add a unit to the interface or implementation uses clause
- **code_insert_in_procedure** — Insert text right after a routine's `begin`; an overloaded name is refused with the candidates, `line` picks one
- **code_edit_statement** — Replace, delete, insert next to or wrap (begin, try, if, while, for, with) ONE statement of a body, found by the `line`/`col` of `code_get_procedure_ast`; the text around it stays ([ADR-008](docs/adr/0008-structural-source-editing.md))
- **code_replace_procedure_body** — Replace everything between a routine's `begin` and `end`; an overloaded name is refused with the candidates, `line` picks one
- **code_add_to_class** — Append a declaration to a class section (private/protected/public/published)
- **code_complete** — Code completion as Ctrl+Shift+C does it: method bodies, property fields and setters, forward procedures, local variables, event handlers. Returns the changed lines
- **code_format** — Format a file or a range of lines with JEDI Code Format, using the IDE's JCF settings; one undo step. Returns the changed lines
- **form_create** — New form, data module or frame (`kind`): `.pas` + `.lfm`, added to the project (or, with `package_name`/`lpk_path`, to that package) and opened
- **form_list_components** — Every component with class, parent, bounds, Align, Anchors, Visible, Caption/Text, TabOrder; form and client size
- **form_get_lfm** — LFM text of the live designer state (incl. unsaved changes) — whole form or one component
- **form_get_properties** — Properties of a component, nested ones as dotted paths; with `names`, also the allowed values
- **form_set_properties** — Set several properties at once; one result per property. `Parent` moves a control into another container
- **form_add_component** — Add a palette component, optionally inside a container, with `name` and initial `properties`; adds the unit to `uses
- **form_delete_component** — Delete a component and its child controls, or a menu item and its submenu (fields removed from the source)
- **form_list_collection_items** — Items of a collection property (ListView `Columns`, StatusBar `Panels`, grid `Columns`, `Sections`, `Bands`) with their properties
- **form_add_collection_item** — Add (at an index, with properties), delete or reorder collection items
- **form_get_menu** — Item tree of a `TMainMenu`/`TPopupMenu`: captions, shortcuts, checked/enabled, OnClick; `menu_name` is optional when the form has one menu, and errors list the form's menus
- **form_add_menu_item** — Add an item or separator (`-`) to a menu or submenu; move an item to another position or parent
- **form_arrange** — Same size as the first control, distribute with a fixed gap or evenly, align edges/centres to the first control or the parent
- **form_create_event_handler** — Create (or show) the handler for a component event
- **form_search_palette** — Find palette classes by name: class, unit, palette page
- **form_undo** — One step of the designer's undo list, as Edit > Undo / Redo (Ctrl+Z) in the designer; returns `can_undo` / `can_redo
- **debug_set_breakpoint** — Source (file + line), address (`$401000`, or `Proc+12` for a procedure with debug info, resolved while paused) and data breakpoints (`data` + `watch` write/read/readwrite); each with `condition` and `pass_count`. Setting one again at its location changes it. No session needed, except to resolve a s…
- **debug_run** — Start, or continue from a pause (F9). Refused up front when the project has no DWARF info (the IDE would ask in a dialog); a program that ends reports `reason: "exited"` and `exit_code`; a stop on a breakpoint says `reason: "breakpoint"`; if no session starts (a failed build) the answer is an error…
- **debug_run_to_line** — Run to a file/line via a temporary breakpoint
- **debug_step_over** — F8 / F7 / Shift+F8
- **debug_attach** — Attach the debugger to a running process by id (e.g. the program `project_run` started); it stops with its stack readable. `debug_stop` with `detach: true` lets it go on
- **debug_pause** — Pause / stop the session (ends an attached program unless `detach`); a pause makes the program's main thread current (not the debugger's break-in thread)
- **debug_get_state** — State and source location, in any state
- **debug_get_call_stack** — Frames with file, line, function and address (`max_frames`)
- **debug_get_locals** — Locals and parameters of a frame (`thread`, `frame`)
- **debug_evaluate** — Evaluate a Pascal expression in the selected frame, or in `thread`/`frame` for this call only. Raw memory too: `^Byte($1000A0)[0..15]`, with a type the program uses (there is no separate memory dump tool; see [ADR-009](ADR-009.md#v09-registers-and-disassembly))
- **debug_select_frame** — Select a thread and stack frame, as the Threads and Call Stack windows do
- **debug_set_variable** — Modify a variable or expression
- **debug_get_exception** — The exception the program is paused at
- **debug_add_watch** — Watches window; values for the selected (or given) thread and frame
- **debug_list_threads** — Threads with state and top frame
- **debug_get_registers** — CPU registers of a thread and frame, as the Registers window shows them, plus `hex`; `changed` since the previous pause; `names` or `general` keep only some (the full list is ~20 KB)
- **debug_disassemble** — Machine code around an address, a symbol, or a frame: bytes, instruction, function+offset, source lines, call/jump targets
- **debug_get_output** — What the program wrote to its console, and debugger output
- **project_get_directory** — Root directory of the active project (contains the `.lpi`)
- **project_list_files** — Source files of the active project
- **project_list_directory** — Files and folders of any directory on disk (depth up to 5, size per file, capped)
- **project_get_settings** — Target OS/CPU, output directory, custom options, debug info (`debug_info`: none, dwarf3, ...; the debugger needs DWARF), compiler and FPC version, LCL widgetset of the active build mode (set in the build-mode matrix, as Project Options does), and the debug-run switches `heaptrc`, `trash_variables`,…
- **project_add_file** — Project file list (files stay on disk). Adding a file already in the project reports `already_in_project`. Removing a file open in the editor is refused until it is closed
- **project_create_unit** — New unit on disk, added to the project and opened
- **project_list_packages** — Required packages as in Project Inspector: version limits, resolved `.lpk`, status (`ok`, `not_found`, ...); `recursive` adds the whole graph in compile order
- **project_add_package** — Package dependencies in the `.lpi
- **project_search** — Case-insensitive text search across project files
- **project_list_todos** — TODO` / `FIXME` / `DONE` comments, as the IDE's ToDo List shows them
- **project_build** — Incremental build; returns success and errors
- **project_get_compiler_errors** — Errors and warnings of the last build
- **project_run** — Build if needed and run without the debugger; optional `args` (stored in the run parameters). Answers with the program's stdout, stderr and exit code (waits up to `wait_seconds`, default 10; a program still running comes back with `running: true`); a heaptrc report in stderr also comes back parsed…
- **project_run_output** — The output of that program since the last read, its exit code once it ended; can wait for more, or stop it

## Claude Desktop Quick Installation
No confirmed install details yet, so no config is published. Follow the setup steps in the repository above.

## Documentation

## What lazarus-mcp-assistant does

lazarus-mcp-assistant connects an MCP-capable AI assistant to a running Lazarus IDE instance. Its 124 tools cover editor operations, Object Pascal code analysis and refactoring, project and package work, form editing, building, debugging, and IDE inspection. The assistant can work with the live editor state, so reads prefer unsaved content in an open buffer over the copy on disk.

The design is intended for development inside Lazarus rather than for launching a separate command-line MCP process. Multiple AI sessions can connect to the same IDE, and the in-process server remains available between sessions.

## How it works

The plugin runs an HTTP MCP server inside the Lazarus process. Lazarus starts the server, while the AI client connects to it; the client does not spawn the server as a subprocess. This arrangement allows an assistant to edit plugin source, rebuild the IDE, and reconnect after a restart.

Tools use names in the form `<category>_<action>`, and `tools/list` returns them with human-readable titles and annotations. The annotations identify read-only operations, potentially destructive operations, and calls that are idempotent. In Claude Code, the tools appear with the `mcp__lazarus-ide__` prefix.

## Setup and configuration

Install lazarus-mcp-assistant as a standard Lazarus package, then run Lazarus with the package enabled. Configure an MCP-capable client to connect to the HTTP server exposed by the IDE. The integration is tested on Windows and Debian 12 with Lazarus 4.6, FPC 3.2.2, and GTK2.

Source-file operations use absolute paths. The server recognizes both slash styles on Windows, and older parameter names such as `file_path`, `path`, and `filename` remain accepted for compatibility.

## Tools and capabilities

The tool groups support work such as:

- Reading, opening, creating, editing, saving, reverting, and closing editor files and tabs.
- Moving the cursor, reading selections, and working with active editor buffers.
- Inspecting unit interfaces, outlines, procedure syntax trees, declarations, references, descendants, overrides, dependencies, and unused symbols.
- Renaming identifiers, extracting methods, changing uses clauses, editing statements, replacing procedure bodies, and adding class declarations.
- Creating or moving project and package units, with package dependency updates where required.
- Building and inspecting projects, working with forms, and using debugger-related IDE tools.

Edits made through the relevant editor, code, form, and project operations are constrained to approved project, package, repository, or temporary locations. The server also protects against ambiguous text replacements and reports errors instead of opening the IDE's file-not-found dialog.

## Limitations and notes

The platform scope is Windows and Linux. macOS has not been tested or claimed, even though the code uses LCL and IDE interfaces and includes code for launching Claude Code in Terminal.app.

Some operations are intentionally destructive, including closing or reverting unsaved editors, Git checkout and reset, rebuilds, and installs. File-changing tools generally support undo or dry-run behavior where applicable, but actions such as package installation and project or package creation have separate access considerations. Creating or opening a project or package can make its directory the active writable location, so consent controls matter when that behavior needs to be restricted.

Changes made outside the IDE by another assistant or shell process are visible to the tools. Editor saves, reverts, and closes are not subject to the same path restriction as operations that write existing source content.

_Full upstream README: https://allmcps.com/mcp/lazarus-mcp-assistant/readme_

