Skip to main content

MCP Tools

AI Agent Plane runs a small MCP server inside the Lazarus IDE. This page summarizes the available tools. Full technical details are in docs/MCP.md.

Server​

ItemValue
Server namefastplaz
URLhttp://127.0.0.1:<port>/mcp
Default port17826; when it is taken, the next port up to 17835
TransportMCP Streamable HTTP (simplest form): POST /mcp with one JSON-RPC message, JSON response, no SSE
Protocol versions2025-11-25, 2025-06-18 (default), 2025-03-26, 2024-11-05
Methodsinitialize, ping, tools/list, tools/call, resources/list, resources/read, resources/templates/list
AuthenticationAuthorization: Bearer <token>, a new random token each time the server starts
LimitsRequest body 4 MB; text results are cut at 32 KB

Tools run in the IDE main thread. A long call, such as a compile, keeps the HTTP request open until it finishes.

Tools​

There are 19 tools in three groups. Paths can be absolute or relative to the project directory.

Every tool carries MCP annotations: readOnlyHint, destructiveHint (only clean_and_compile_project), idempotentHint, and openWorldHint: false.

IDE​

ToolPurposePermission
open_fileOpens a file in the Source Editor, optionally at a given line and columnauto
get_active_editorFile, cursor position, selected text, and modified state of the active editorauto
list_open_filesOpen files and whether they have unsaved changesauto
read_editorFile content as in the editor (including unsaved changes) with line numbers. Project files and search paths onlyauto
project_infoActive project info: .lpi file, main unit, build mode, target OS/CPU, search paths, compiler options, output fileauto
list_project_unitsFiles that are part of the projectauto
compile_projectCompiles the project (or builds everything with rebuild). Saves changed editor files firstask once per session
build_projectBuilds all units, like Run → Buildask once per session
clean_and_compile_projectLike Run → Clean up and Build: deletes compiled files, then builds everything. Source files are never deletedalways ask
get_messagesThe last compiler messages from the Messages window, with file, line, and columnauto

Shared arguments: build_mode (build mode to activate first) and min_urgency (hint, note, warning, error; default warning).

Example build result:

{"success": true, "duration_ms": 1234,
"messages": [{"file": "...", "line": 10, "column": 5, "urgency": "error", "text": "..."}]}

Editor, Search, and Units​

ToolPurposePermission
edit_textReplaces old_string with new_string in the editor buffer as a single undo step (Ctrl+Z undoes it). Fails if old_string is not found, or occurs more than once without replace_all. Written to disk only with saveask once per session
save_fileSaves a file's editor buffer (a form unit also saves its .lfm)ask once per session
revert_fileDiscards unsaved changes and reloads the file from diskalways ask
search_projectText search in project files (including unsaved buffers), or in directory with mask. Returns file, line, and line textauto
find_unitFor "Can't find unit X" errors: the file the compiler would use, whether it is part of the project, the package that provides it, and hints for a fixauto

FastPlaz Generators and Reference​

Generators write a new unit from a FastPlaz template, add it to the project, and open it in the editor. In FastPlaz a module is a controller, so a "create a module" request is handled with a controller generator.

ToolPurposePermission
create_simple_controllerWeb page controller (TMyCustomController with Get/Post, rendered through the theme). Saves <permalink>_controller.pasask once per session
create_api_controllerREST controller that answers JSON (Get/Post/Options). Saves <permalink>_controller.pasask once per session
create_modelTSimpleModel unit for a database table. Saves <name>_model.pasask once per session
get_fastplaz_referenceFastPlaz reference (same as the resource fastplaz://reference). With section, only one part (routes, model, theme, ...)auto

Generator arguments:

  • name: module or model name in words. "user group" becomes TUserGroupController / TUserGroupModel.
  • permalink: controller route, for example user-group. Default: from name.
  • table: database table name. If name is empty, the model name is taken from the table (users becomes TUserModel).
  • directory: where the unit goes; must be inside the project directory. Default: the project directory.

Generator rules:

  • Nothing is overwritten. If the file already exists, the call fails and nothing changes.
  • A generated controller registers its route in the initialization section. If the project has a routes.pas, move that line there. See Routing.

Resources​

URIContent
fastplaz://referenceFastPlaz reference for agents (text/markdown): project layout, controllers, routes, request and session, themes and template tags, TSimpleModel, TJSONUtil, config.json, helpers, workflow in the IDE, and common pitfalls

Example Request​

POST /mcp HTTP/1.1
Host: 127.0.0.1:17826
Authorization: Bearer <token>
Mcp-Session-Id: <session id from initialize>
Content-Type: application/json

{"jsonrpc":"2.0","id":1,"method":"tools/call",
"params":{"name":"open_file","arguments":{"path":"main.pas","line":42}}}

In normal use you do not need to call this server by hand: Agent Plane registers it with the agent automatically.

Adding a Tool​

For contributors who want to add a new tool, the steps are in the Adding a tool section of docs/MCP.md. The MCP server source is in tools/src/ai_plane/.