Skip to main content
Lexera exposes its legal verification pipeline through the Model Context Protocol (MCP), an open standard that lets AI agents and enterprise systems call tools over a persistent, event-driven transport. Because human attorney review takes time, Lexera’s implementation is fully asynchronous and stateful: you open a single long-lived connection, dispatch a request, and receive the result later as a server event.

Why JSON-RPC 2.0 over SSE

Traditional REST APIs expect an immediate response, which does not fit a workflow where a law firm may spend hours reviewing a contract. Lexera solves this with Server-Sent Events (SSE): a persistent HTTP connection that the server uses to push status updates, results, and errors back to your system. JSON-RPC 2.0 provides a lightweight, structured message format for invoking tools and correlating responses.

JSON-RPC 2.0 message format

Every tool call is a JSON-RPC 2.0 request. The envelope is predictable and easy to generate from any language.

Server-Sent Events transport

Lexera streams three kinds of information over SSE:
  1. Session initialization — After you open the stream, the server sends an event: endpoint containing your unique session URL. You must extract this URL to dispatch any RPC.
  2. Execution results — Once you POST a tool call, the eventual result (for example, DISPATCH_SUCCESS or a completed order payload) arrives as a later SSE message on the same connection.
  3. Errors — Validation failures, wallet issues, and authentication problems are also streamed as JSON-RPC error payloads over SSE.

The event: endpoint handshake

Immediately after opening the SSE stream, the server pushes a session assignment. The event looks like this:
Your code must parse the data line, prepend https://lexera.dev, and use the resulting URL for every subsequent JSON-RPC POST. Without this step, the server cannot correlate your tool calls with your open stream.
All SSE traffic, including the initial session assignment, requires a valid Bearer token. See Authentication for how to obtain and pass your API key.

Next steps