Skip to content

MCP Server

Federico Conticello edited this page May 9, 2026 · 3 revisions

MCP Server

FerrisPad includes a built-in MCP (Model Context Protocol) server that allows external AI tools to interact with the editor.

How It Works

When FerrisPad starts, it launches a local TCP server on 127.0.0.1 with an OS-assigned port. The port number is written to ~/.config/ferrispad/mcp-port so that MCP clients can discover it. The server is cleaned up automatically when FerrisPad exits.

Communication uses the JSON-RPC 2.0 protocol, newline-delimited (one request/response per line).

Bridge Mode

For stdio-based MCP clients (like Claude Code CLI), FerrisPad provides a bridge mode:

FerrisPad --mcp-server

This starts a headless process (no GUI) that translates between stdin/stdout and the TCP server running in the main FerrisPad instance. The bridge reads the port from ~/.config/ferrispad/mcp-port and forwards messages.

Available Tools

The MCP server exposes these tools:

Tool Description
get_active_file Returns path, name, language, line count, cursor position, and modified status
get_buffer_content Full text of the active buffer
get_selection Currently selected text with position info
list_open_files All open tabs with names and modified status
open_file Open a file in the editor (checks if already open)
goto_line Move cursor to a specific line number
refresh_tree Refresh the file explorer panel
show_diff Open a side-by-side diff between an open buffer and the file on disk so the user can review external edits before accepting them. The diff view auto-scrolls to the first changed line and shows colored markers in the scrollbar gutter.
preview_edit Preview a proposed edit and block until the user accepts or rejects it. Lets an external agent (e.g. Claude Code) propose changes interactively.
reload_file Reload a file from disk into its editor buffer (used after an external write).

Plugin Integration

Plugins can discover the MCP server port and configure projects for MCP clients automatically. See the Plugin Editor API for the available methods.

Security

  • The server listens only on 127.0.0.1 (localhost) — no remote access
  • Bridge mode requires an existing FerrisPad instance with a valid port file
  • .mcp.json creation is sandboxed to the project root directory

Clone this wiki locally