Skip to main content

Module mcp

Module mcp 

Source
Expand description

A Model Context Protocol server on localhost, so AI assistants on the same Mac can use the library falcon has open.

It speaks Streamable HTTP on POST /mcp, and answers every request with a single JSON object (no SSE stream, no sessions). [rpc] holds the JSON-RPC layer and [tools] the tools.

Falcon’s own choices:

  • it listens on 127.0.0.1 only and never binds Eagle’s port or 8000;
  • a request is served only when its Host is the server’s own address and its Origin, if it has one, is on the loopback address. There are no CORS headers, so a web page can’t read an answer even from another local port;
  • Options::token can also ask for Authorization: Bearer <token>;
  • it serves whatever library Handle::set_library was last given and has no way to open another one;
  • write tools exist only while Options::allow_writes is on.

Structs§

Handle
A server running on its own threads; dropping it stops the server.
Options
What the app can change on a running server.
UndoStep
A write a tool made, for the app’s undo history.

Enums§

WriteKind
Which write tool made an UndoStep.

Constants§

DEFAULT_PORT
The first port tried. The HTTP API tries the five from crate::DEFAULT_PORT, so this stays clear of them.
PATH
The MCP endpoint.
RESERVED_PORT
A port the MCP server never binds, besides Eagle’s: other MCP servers on this Mac commonly sit there.

Functions§

client_config
The JSON an MCP client is configured with to reach this server.
start
Starts serving on the first free port of ports, calling on_request after each handled request (for example to repaint a UI). Port 0 asks the system for a free port.