gleamunison/mcp_session
MCP session layer: selected-branch CAS plus explicit source overlays. The pure session owns values; the supervised web session owns mutations.
Types
pub type SearchHit =
mcp_search.SearchHit
pub opaque type SessionState
Values
pub fn boot() -> SessionState
Fresh scratch-only session: bootstrap definitions, no ambient store.
pub fn boot_configured() -> Result(SessionState, String)
Server startup reads the configured branch and the node’s one active store.
pub fn callers_of(
state: SessionState,
name: String,
) -> Result(List(String), String)
Callers of a name: every visible definition with a dependency edge to it.
pub fn define_source(
state: SessionState,
name: String,
source: String,
) -> Result(#(String, SessionState), String)
Bind one definition by name, so a later eval sees it.
pub fn defined_names(state: SessionState) -> List(String)
Every visible name in the durable view plus its explicit scratch overlay.
pub fn definitions_json(state: SessionState) -> String
pub fn defs_by_kind(
state: SessionState,
kind: String,
) -> Result(List(String), String)
Definitions filtered by kind (term, type, ability, type-alias).
pub fn deps_of(
state: SessionState,
name: String,
) -> Result(List(String), String)
Dependencies of a definition: in-corpus names its body references.
pub fn eval_source(
state: SessionState,
source: String,
) -> Result(#(String, SessionState), String)
Evaluate source against the session and return the last value plus the
advanced state. This is the live-session contract the REPL and the HTTP
routes share: a define binds a name for later evaluation, anything else
is an expression. The HTTP surface used to call a stateless evaluator with
no baseline, so /eval?expr=(+ 1 2) answered “undefined variable +” and
/define stored the source text in a notebook without binding anything —
the route said “defined” and nothing was.
pub fn from_parts(
cache: types.TypeCache,
defs: List(#(String, elab_types.SurfaceDef)),
) -> SessionState
Explicit scratch view for the REPL and isolated tests.
pub fn from_store(
adapter: storage.StorageAdapter,
branch: String,
) -> Result(SessionState, String)
pub fn handle_rpc(
state: SessionState,
body: String,
) -> mcp.Response
Route one JSON-RPC body through the protocol layer with the session’s real tools attached.
pub fn load_file(
state: SessionState,
path: String,
) -> Result(SessionState, String)
Extend a session by loading a lisp source file through the same
pipeline verify uses: defines are defined, other forms evaluated.
pub fn overlay_scratch(
fresh: SessionState,
previous: SessionState,
) -> SessionState
Rebuild a durable snapshot, then reapply only the previous scratch overlay. A successful write must not turn the session into a second scratch owner or silently discard unrelated exploratory definitions.
pub fn search(
state: SessionState,
query: String,
) -> List(mcp_search.SearchHit)