protocol

mcp_server_spec_protocol

Protocol for MCP server spec (aka data layer) handlers independent of transport. A handler validates and dispatches JSON-RPC messages and returns abstract outcomes that a transport (stdio or Streamable HTTP) renders to the wire.

Availability:
logtalk_load(mcp_server(loader))
Author: Paulo Moura
Version: 1:0:0
Date: 2026-08-31
Compilation flags:
static
Dependencies:
(none)
Remarks:
(none)
Inherited public predicates:
(none)

Public predicates

spec/1

MCP server spec implemented by this handler (e.g. '2025-06-18' or '2026-07-28').

Compilation flags:
static
Template:
spec(Version)
Mode and number of proofs:
spec(-atom) - one

prepare/2

Initializes handler state for Application with merged Options. Does not open any transport.

Compilation flags:
static
Template:
prepare(Application,Options)
Mode and number of proofs:
prepare(+object_identifier,+list) - one_or_error
Exceptions:
Options is a variable:
instantiation_error
Options is neither a variable nor a list:
type_error(list,Options)
An element Option of the list Options is a variable:
instantiation_error
An element Option of the list Options is neither a variable nor a compound term:
type_error(compound,Option)
An element Option of the list Options is a compound term but not a valid option:
domain_error(option,Option)

handle_message/3

Handles one JSON-RPC Message under Options and returns an Outcome for the transport to render. Outcomes include reply(JsonRpcTerm), accepted, no_reply, and transport-agnostic error replies already encoded as JSON-RPC error objects inside reply/1.

Compilation flags:
static
Template:
handle_message(Message,Options,Outcome)
Mode and number of proofs:
handle_message(+nonvar,+list,-nonvar) - one

notify/1

Publishes an application event. Transports that support server-initiated notifications deliver it; others may ignore it.

Compilation flags:
static
Template:
notify(Event)
Mode and number of proofs:
notify(+compound) - zero_or_one

cleanup/0

Releases handler-owned dynamic state.

Compilation flags:
static
Mode and number of proofs:
cleanup - one

Protected predicates

(none)

Private predicates

(none)

Operators

(none)