gleamunison/mcp_session
MCP session layer: a live gleamunison session behind the JSON-RPC tools.
The session is immutable after boot: eval is read-only (define forms are
rejected), so handlers never thread state. Tools answer from the session’s
own definition table — names, kinds, content-addressed refs.
Types
One search hit: the triple a CLI or an agent actually needs.
pub type SearchHit {
SearchHit(
name: String,
kind: String,
ref_hex: String,
score: Float,
)
}
Constructors
-
SearchHit( name: String, kind: String, ref_hex: String, score: Float, )
pub opaque type SessionState
Values
pub fn callers_of(
state: SessionState,
name: String,
) -> Result(List(String), String)
Callers of a name: every definition with a def/dep edge pointing at it. Answered by the native datalog engine over the session index.
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 from_parts(
cache: types.TypeCache,
defs: List(#(String, elab_types.SurfaceDef)),
) -> SessionState
Build a session from parts — the REPL carries its own cache/defs, and the graph tools should answer over exactly what the user has defined.
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 search(
state: SessionState,
query: String,
) -> List(SearchHit)
BM25-ranked search over definition names and bodies. Name tokens count double (a name match is stronger intent evidence than a body mention). Ties break alphabetically for stable output.
pub fn session_defs(
state: SessionState,
) -> List(#(String, elab_types.SurfaceDef))
The session’s definition set (name + surface def). Read-only view for index tooling and diagnostics.