Skip to content

v2.0 Phase 1: MCP server skeleton (list_open_files)#9

Open
nonatofabio wants to merge 2 commits intomainfrom
feat/mcp-server
Open

v2.0 Phase 1: MCP server skeleton (list_open_files)#9
nonatofabio wants to merge 2 commits intomainfrom
feat/mcp-server

Conversation

@nonatofabio
Copy link
Copy Markdown
Owner

Summary

First slice of the v2.0 milestone — the MCP plumbing that lets Claude (or any other harness) ask Mindle questions over a real protocol. Phase 1 only, intentionally narrow: prove the round-trip with one tool, then layer on the annotation surface in Phase 2.

Architecture decision: Mindle's MCP is read-only and Mindle-unique

read_file and write_file belong in the agent's own filesystem tools. Mindle's MCP only exposes what no other tool can — what's currently open, what the user has annotated, and (in Phase 2) the ability to mark an annotation as addressed. The whole MCP becomes "the human's side of an agent collaboration loop, full stop."

What's in this PR

  • MCPServer actor in Sources/mindle/MCPServer.swift. Binds a Unix socket at ~/Library/Caches/local.fnp.mindle/mcp.sock on launch, unlinks it on terminate. Speaks length-prefixed JSON internally — not MCP; the helper handles MCP framing.
  • AppDelegate wiring. New registeredStores list (weak refs) so list_open_files aggregates paths across every window. applicationDidFinishLaunching starts the server; applicationWillTerminate stops it.
  • mindle-mcp Swift CLI in Sources/MindleMCP/main.swift. Synchronous POSIX-read stdin loop, newline-delimited JSON-RPC out, full MCP handshake (initialize / tools/list / tools/call). On tools/call list_open_files, opens the Unix socket, sends the internal op, formats the response as text content. Clean error if Mindle isn't running ("Open Mindle and try again").
  • Build wiring. build.sh compiles the helper alongside the main app and embeds it at Mindle.app/Contents/MacOS/mindle-mcp.

Smoke test (passes locally)

{
  printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}'
  printf '%s\n' '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
  printf '%s\n' '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"list_open_files","arguments":{}}}'
} | /Applications/Mindle.app/Contents/MacOS/mindle-mcp

Returns proper serverInfo, the list_open_files schema, and the open file paths as text content.

Coming in subsequent phases

  • Phase 2get_annotations(path) and clear_annotation(id, summary). Summary attaches to the diff chip's hover.
  • Phase 3 — bundled mindle-collaboration skill at docs/skills/mindle-collaboration.md teaching the agent the loop and listing tools as deferred (zero context cost until first call).
  • Phase 4 — "Set Up MCP for Claude Code…" menu item that runs the install command for the user.
  • Phase 5 — theme polish, landing-page rewrite, demo video.

Part of v2.0 roadmap.

Phase 1 of v2.0 plumbing. The Mindle app now binds a Unix socket at
~/Library/Caches/local.fnp.mindle/mcp.sock on launch and unlinks it
on terminate. The internal protocol over the socket is a tiny
length-prefixed JSON dialect (not MCP — the helper handles MCP
framing on stdio).

Phase 1 ships one op: list_open_files. Aggregated across every
window's tabs via a new registeredStores list (weak refs) on
AppDelegate, populated whenever a RootView registers its store.

Read-only by design: filesystem reads belong in the agent's own
Read tool. Mindle's MCP only ever exposes what's unique to Mindle —
open-files state and (in the next phase) the annotation feedback
channel.
Bundled CLI at Mindle.app/Contents/MacOS/mindle-mcp. Reads
newline-delimited JSON-RPC from stdin, handles the standard MCP
handshake (initialize / tools/list / tools/call), and translates
each tools/call into a length-prefixed request over Mindle's Unix
socket. Phase 1 supports one tool: list_open_files.

If Mindle isn't running, the helper returns a tool error with a
clear 'Open Mindle and try again' message instead of hanging or
silently failing.

End-to-end smoke test passes — full handshake produces:
  initialize → serverInfo
  tools/list → list_open_files schema
  tools/call list_open_files → text content with absolute paths

Build script picks up Sources/MindleMCP/*.swift and embeds the
binary in the app bundle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant