Local only MCP Server#575
Conversation
Adds @modelcontextprotocol/sdk and zod to support the upcoming MCP server that lets external AI agents drive the editor over Streamable HTTP.
types.ts holds the lifecycle types (McpServerInfo, McpServerStatus, McpInvokeRequest/Response) the main process and renderer exchange. toolCatalog.ts defines the surface area of the MCP server as data: each tool's name, description, category, and zod input schema. Both the SDK registration on the main side and the dialog's tool listing in the renderer import this single source so they cannot drift.
- server.ts hosts a Streamable HTTP MCP server on 127.0.0.1 with a random port. Enforces two layers of loopback validation: the peer socket address and the Host header (DNS rebinding defense). - Stubs the OAuth 2.1 + Dynamic Client Registration endpoints the MCP HTTP transport spec requires; the responses are well-formed but enforce nothing, so any local MCP client can complete the handshake. - /authorize renders a small branded HTML page that JS-redirects to the client's callback URL with a fixed code. - rendererBridge.ts forwards tool invocations to the editor window using correlation IDs and timeouts; replies route back via the matching IPC channel. - index.ts exposes lazy singletons for both.
- handlers.ts registers mcp:start / mcp:stop / mcp:status and pushes
state changes to the editor window over mcp:status-changed.
Also exposes clipboard:write-text as a reliable way for the renderer
to copy the connection URL.
- preload.ts adds window.electronAPI.mcp.{start,stop,status,
onStatusChanged,onInvoke,reply,onOpenDialog} and writeClipboard.
- main.ts adds a Tools menu with an MCP Server entry that opens (or
creates) the editor window and tells it to show the dialog.
- electron-env.d.ts typings track the new surface.
- toolHandlers.ts wires each MCP tool name to a handler reading and writing EditorState via the small McpEditorControls interface. Region ids come from the existing deriveNextId helper; the normalize/clamp rules in normalizeProjectEditor still apply since every edit goes through pushState. - McpToolHost.tsx listens for mcp:invoke from main, dispatches via the handler map, and replies with mcp:reply. Stable controls reference so the map is built once. - useMcpStatus.ts wraps start/stop/status IPC plus the mcp:status-changed subscription for the dialog UI.
Radix Dialog with: - Status pill (Stopped / Starting / Running / Error) reflecting the live server state from useMcpStatus. - Enable / Disable toggle that flips the server lifecycle. - Copyable connection URL routed through the Electron clipboard module (navigator.clipboard fallback if the IPC path is unavailable). - Scrollable tool catalog grouped by category, sourced from TOOL_DISPLAY so it stays in lockstep with what's actually registered.
Builds an McpEditorControls bag that reads editor state via refs so handlers see live values without rebuilding the handler map, and writes through the existing pushState so every agent edit lands in the undo stack as its own checkpoint. Implements captureSourceFrame (offscreen canvas + <video>) and captureRenderedFrame (seek + waitForFrame + Pixi canvas snapshot). exportProject returns a placeholder error pending refactor of handleExport to accept an explicit output path. Listens on mcp:open-dialog so the Tools menu opens the MCP dialog inside the editor window.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@AbhinRustagi sorry but wanted to stop and inform before you spend more time on this - mcp, agentic capabilities will not be accepted currently. |
Pull Request Template
Description
Motivation
Type of Change
Related Issue(s)
#574
Screenshots / Video
export-1778494804267-compressed.mp4
Testing
Checklist
Thank you for contributing!