object

mcp_server_2025_06_18_spec

MCP 2025-06-18 protocol handler. Transport-agnostic message handling; returns abstract outcomes for stdio or Streamable HTTP transports to render. Synchronous elicitation requires stdio_input/1 and stdio_output/1 options.

Availability:
logtalk_load(mcp_server(loader))
Author: Paulo Moura
Version: 1:0:0
Date: 2026-09-02
Compilation flags:
static, context_switching_calls
Implements:
Imports:
Uses:
Remarks:
(none)

Public predicates

supported_specs/1

Specs this handler can negotiate, preferred first.

Compilation flags:
static
Template:
supported_specs(Versions)
Mode and number of proofs:
supported_specs(-list) - one

current_options/1

Merged options established by prepare/2.

Compilation flags:
static
Template:
current_options(Options)
Mode and number of proofs:
current_options(-list) - zero_or_one

elicit_request/5

Sends an elicitation/create request to the client and reads the response (2025-06-18 synchronous model).

Compilation flags:
static
Template:
elicit_request(Input,Output,Message,RequestedSchema,Answer)
Mode and number of proofs:
elicit_request(+stream,+stream,+atom,+compound,--compound) - one

Protected predicates

handle_initialize/4

Handles the initialize request and returns a reply/1 outcome. Overridable by later 2025 family specs (e.g. 2025-11-25).

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

handle_ping/2

Handles the ping request and returns a reply/1 outcome.

Compilation flags:
static
Template:
handle_ping(Id,Outcome)
Mode and number of proofs:
handle_ping(+nonvar,-nonvar) - one

handle_tools_list/3

Handles the tools/list request. Overridable so later specs can enrich tool descriptors (e.g. icons).

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

handle_tools_call/4

Handles the tools/call request and returns a reply/1 outcome.

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

handle_prompts_list/3

Handles the prompts/list request. Overridable so later specs can enrich prompt descriptors (e.g. icons).

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

handle_prompts_get/4

Handles the prompts/get request and returns a reply/1 outcome.

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

handle_completion_complete/4

Handles the completion/complete request and returns a reply/1 outcome.

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

handle_resources_list/3

Handles the resources/list request. Overridable so later specs can enrich resource descriptors (e.g. icons).

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

handle_resources_templates_list/3

Handles the resources/templates/list request. Overridable so later specs can enrich resource template descriptors (e.g. icons).

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

handle_resources_read/4

Handles the resources/read request and returns a reply/1 outcome.

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

generate_elicit_id/1

Generates a new elicitation id.

Compilation flags:
dynamic
Template:
generate_elicit_id(ElicitId)
Mode and number of proofs:
generate_elicit_id(-non_negative_integer) - one

build_capabilities/2

Builds the server capabilities object from application capability atoms (tools is always present; prompts, resources, completions, and the MCP Apps UI extension are optional).

Compilation flags:
static
Template:
build_capabilities(ApplicationCapabilities,Capabilities)
Mode and number of proofs:
build_capabilities(+list,-compound) - one

best_supported_spec/3

Selects the highest supported spec that is less than or equal to the client-requested spec. Fails when no such spec exists.

Compilation flags:
static
Template:
best_supported_spec(Supported,ClientVersion,Best)
Mode and number of proofs:
best_supported_spec(+list,+atom,-atom) - zero_or_one

Private predicates

client_capabilities_/1

Client capabilities.

Compilation flags:
dynamic
Template:
client_capabilities_(Capabilities)
Mode and number of proofs:
client_capabilities_(-nonvar) - one

elicit_counter_/1

Elicitation current counter.

Compilation flags:
dynamic
Template:
elicit_counter_(Counter)
Mode and number of proofs:
elicit_counter_(-non_negative_integer) - one

initialized_/0

Initialization completed flag.

Compilation flags:
dynamic
Mode and number of proofs:
initialized_ - zero_or_one

server_options_/1

Server options.

Compilation flags:
dynamic
Template:
server_options_(Options)
Mode and number of proofs:
server_options_(-list(compound)) - one

Operators

(none)