| Did you know ... | Search Documentation: |
| Pack logtalk -- logtalk-3.98.0/docs/apis/_sources/mcp_server_0.rst.txt |
.. index:: single: mcp_server .. _mcp_server/0:
.. rst-class:: right
object
mcp_server
MCP (Model Context Protocol) server for Logtalk applications. Exposes Logtalk objects implementing the mcp_tool_protocol and optionally mcp_prompt_protocol and mcp_resource_protocol protocols as MCP tool, prompt, and resource providers over stdio transport with Content-Length framing. Implements the MCP 2025-03-26 specification. Uses the json_rpc library for JSON-RPC 2.0 message handling.
| Availability:
| logtalk_load(mcp_server(loader))
| Author: Paulo Moura | Version: 0:5:0 | Date: 2026-02-24
| Compilation flags:
| static, context_switching_calls
| Imports:
| public :ref:`options <options/0>`
| Uses:
| :ref:`json_rpc <json_rpc/0>`
| :ref:`list <list/0>`
| :ref:`term_io <term_io/0>`
| :ref:`user <user/0>`
| Remarks:
initialize request. The server selects the highest version it supports that is compatible (i.e., less than or equal to the client version). If no compatible version exists, the server responds with error -32602 ("Unsupported protocol version") including a data field with the list of supported versions.tools/list and tools/call). Optionally supports the prompts capability (prompts/list and prompts/get) when the application declares it via capabilities/1 and implements mcp_prompt_protocol. Optionally supports the resources capability (resources/list and resources/read) when the application declares it via capabilities/1 and implements mcp_resource_protocol. Optionally supports the elicitation capability (elicitation/create) when the application declares it via capabilities/1.mcp_tool_protocol. Tool metadata (descriptions, parameter schemas) is derived from info/2 and mode/2 directives.mcp_prompt_protocol. Prompt metadata (names, descriptions, arguments) is declared via the prompts/1 predicate.mcp_resource_protocol. Resource metadata (URIs, names, descriptions, MIME types) is declared via the resources/1 predicate.elicitation in its capabilities/1, the server constructs an elicit closure and passes it to tool_call/4. The closure sends elicitation/create requests to the client and reads back the user response. This enables interactive tools that can ask the user questions during execution.isError set to true.| Inherited public predicates: | Â :ref:`options_protocol/0::check_option/1` Â :ref:`options_protocol/0::check_options/1` Â :ref:`options_protocol/0::default_option/1` Â :ref:`options_protocol/0::default_options/1` Â :ref:`options_protocol/0::option/2` Â :ref:`options_protocol/0::option/3` Â :ref:`options_protocol/0::valid_option/1` Â :ref:`options_protocol/0::valid_options/1` Â
.. contents:: :local: :backlinks: top
.. index:: start/2 .. _mcp_server/0::start/2:
start/2 ^^^^^^^^^^^
Starts the MCP server with the given server name and application object. The application object must implement the mcp_tool_protocol protocol. Reads JSON-RPC messages from standard input and writes responses to standard output using Content-Length framing. Blocks until the client disconnects or an exit signal is received.
| Compilation flags:
| static
| Template:
| start(Name,Application)
| Mode and number of proofs:
| start(+atom,+object_identifier) - one
.. index:: start/3 .. _mcp_server/0::start/3:
start/3 ^^^^^^^^^^^
Starts the MCP server with the given server name, application object, and options. Currently supported options: server_version(Version) to set the server version (default '1.0.0'), server_title(Title) to set the server display title (default '', omitted when empty).
| Compilation flags:
| static
| Template:
| start(Name,Application,Options)
| Mode and number of proofs:
| start(+atom,+object_identifier,+list) - one
.. index:: start/4 .. _mcp_server/0::start/4:
start/4 ^^^^^^^^^^^
Starts the MCP server with custom input and output streams. Useful for testing or non-stdio transports. Uses default options.
| Compilation flags:
| static
| Template:
| start(Name,Application,Input,Output)
| Mode and number of proofs:
| start(+atom,+object_identifier,+stream,+stream) - one
.. index:: start/5 .. _mcp_server/0::start/5:
start/5 ^^^^^^^^^^^
Starts the MCP server with custom input and output streams and options.
| Compilation flags:
| static
| Template:
| start(Name,Application,Input,Output,Options)
| Mode and number of proofs:
| start(+atom,+object_identifier,+stream,+stream,+list) - one
.. index:: elicit_request/5 .. _mcp_server/0::elicit_request/5:
elicit_request/5 ^^^^^^^^^^^^^^^^^^^^
Sends an elicitation/create request to the MCP client and reads the response. Input and Output are the I/O streams. Message is the prompt text (an atom). RequestedSchema is a curly-term JSON Schema describing the input to request from the user (e.g., {type-object, properties-{answer-{type-string, enum-[yes, no]}}, required-[answer]}). Answer is unified with accept(Content) (where Content is the user response as a curly-term), decline, or cancel. This predicate is typically not called directly but through the elicit closure passed to tool_call/4.
| Compilation flags:
| static
| Template:
| elicit_request(Input,Output,Message,RequestedSchema,Answer)
| Mode and number of proofs:
| elicit_request(+stream,+stream,+atom,+compound,--compound) - one
(no local declarations; see entity ancestors if any)
.. index:: initialized_/0 .. _mcp_server/0::initialized_/0:
initialized_/0
^^^^^^^^^^^^^^^^^^
| Compilation flags:
| dynamic
.. index:: application_/1 .. _mcp_server/0::application_/1:
application_/1
^^^^^^^^^^^^^^^^^^
| Compilation flags:
| dynamic
.. index:: server_name_/1 .. _mcp_server/0::server_name_/1:
server_name_/1
^^^^^^^^^^^^^^^^^^
| Compilation flags:
| dynamic
.. index:: server_version_/1 .. _mcp_server/0::server_version_/1:
server_version_/1
^^^^^^^^^^^^^^^^^^^^^
| Compilation flags:
| dynamic
.. index:: server_title_/1 .. _mcp_server/0::server_title_/1:
server_title_/1
^^^^^^^^^^^^^^^^^^^
| Compilation flags:
| dynamic
.. index:: elicit_counter_/1 .. _mcp_server/0::elicit_counter_/1:
elicit_counter_/1
^^^^^^^^^^^^^^^^^^^^^
| Compilation flags:
| dynamic
.. index:: application_capabilities_/1 .. _mcp_server/0::application_capabilities_/1:
application_capabilities_/1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Compilation flags:
| dynamic
(none)