object
mcp_server_streamable_http_transport
Implements the Streamable HTTP transport for MCP servers. Uses Logtalk http_server::serve_until_shutdown/5 and a dedicated http_handler_protocol handler object. Supports specs 2025-06-18, 2025-11-25, and 2026-07-28 selected via the spec/1 option and delegated to the matching mcp_server_*_spec object. Supports optional OAuth protection and protected-resource metadata publication using the oauth/4 option. Long-lived subscriptions/listen streams emit periodic SSE comment keep-alives (http_sse_keepalive/1). Requires a multi-threaded backend for subscriptions/listen.
logtalk_load(mcp_server(loader))static, context_switching_calls, threadedPublic predicates
prepare/2
Initializes adapter state for Application with Options without opening a listener. Used by unit tests and by embeddings by pairing with handle_mcp_request/4 and cleanup/0.
staticprepare(Application,Options)prepare(+object_identifier,+list) - one_or_errorOptions is a variable:instantiation_errorOptions is neither a variable nor a list:type_error(list,Options)Option of the list Options is a variable:instantiation_errorOption of the list Options is neither a variable nor a compound term:type_error(compound,Option)Option of the list Options is a compound term but not a valid option:domain_error(option,Option)attach_sse_stream/1
Registers a live output stream for incremental SSE writes. Headers must already have been written. Each emit_progress/5 call writes and flushes immediately.
staticattach_sse_stream(Stream)attach_sse_stream(+stream) - onedetach_sse_stream/0
Clears any live SSE output stream registration.
staticdetach_sse_stream - onesse_headers/1
HTTP headers for an SSE response body.
staticsse_headers(Headers)sse_headers(-list) - onecurrent_options/1
Unified with the options list established by prepare/2 or start/4.
staticcurrent_options(Options)current_options(-list) - zero_or_onehandle_mcp_request/4
Handles one MCP HTTP request. Method is an uppercase HTTP method atom. Headers is a list of Name-Value pairs. Body is the raw request body atom. HTTPResponse is http_response(Status, Headers, BodyAtom) or http_response(already_sent, Headers, BodyAtom).
statichandle_mcp_request(Method,Headers,Body,HTTPResponse)handle_mcp_request(+atom,+list,+atom,-compound) - oneemit_progress/5
Emits a notifications/progress event. In live mode the SSE record is written and flushed immediately on the attached stream. In buffered mode the event is queued until finalize_response/4.
staticemit_progress(Token,RequestId,ProgressValue,Total,Message)emit_progress(+term,+term,+number,+number,+atom) - oneProtected predicates
(no local declarations; see entity ancestors if any)
Private predicates
running_/0
True while the adapter has been prepared or is serving requests.
dynamicrunning_ - zero_or_oneserver_options_/1
Merged server options for the active prepare/start session.
dynamicserver_options_(Options)server_options_(-list) - zero_or_oneshutdown_control_/1
Token passed to http_server::request_shutdown/1 when stopping the listener.
dynamicshutdown_control_(Control)shutdown_control_(-nonvar) - zero_or_onesubscription_/4
Active subscriptions/listen registration. Synchronization uses threaded_wait/1 and threaded_notify/1 tagged by SubscriptionId.
dynamicsubscription_(SubscriptionId,RequestId,Filters,Stream)subscription_(-atom,-nonvar,-list,-nonvar) - zero_or_moreprogress_events_/1
Buffered notifications/progress events when SSE mode is not live.
dynamicprogress_events_(Events)progress_events_(-list) - zero_or_oneprogress_token_/1
progressToken from the current request, or none.
dynamicprogress_token_(Token)progress_token_(-nonvar) - zero_or_onesse_output_/1
Live response stream for incremental SSE writes.
dynamicsse_output_(Stream)sse_output_(-stream) - zero_or_onesse_mode_/1
Current SSE delivery mode: live, buffered, or none.
dynamicsse_mode_(Mode)sse_mode_(-atom) - zero_or_oneOperators
(none)