.. index:: single: mcp_server
.. _mcp_server/0:

.. rst-class:: right

**object**

``mcp_server``
==============

MCP server facade. Selects spec and transport (stdio or Streamable HTTP).

| **Availability:** 
|    ``logtalk_load(mcp_server(loader))``

| **Author:** Paulo Moura
| **Version:** 2:0:0
| **Date:** 2026-09-02

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Imports:**
|    ``public`` :ref:`options <options/0>`
| **Uses:**
|    :ref:`http_server <http_server/0>`
|    :ref:`list <list/0>`
|    :ref:`type <type/0>`

| **Remarks:**

   - Specs: ``'2025-06-18'`` (default), ``'2025-11-25'``, and ``'2026-07-28'`` via ``spec/1``.
   - Transports: ``stdio`` (default) and ``streamable_http`` via ``transport/1``.
   - OAuth: Streamable HTTP servers can be protected using the ``oauth/4`` option.

| **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

Public predicates
-----------------

.. index:: start/2
.. _mcp_server/0::start/2:

``start/2``
^^^^^^^^^^^

Starts the MCP server with default options.

| **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 options (``spec/1``, ``transport/1``, HTTP options, ...).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``start(Name,Application,Options)``
| **Mode and number of proofs:**
|    ``start(+atom,+object_identifier,+list)`` - ``one_or_error``

| **Exceptions:**
|    The ``Options`` list specifies an invalid MCP server configuration:
|        ``domain_error(mcp_server_configuration,Version-Transport)``


------------

.. index:: start/4
.. _mcp_server/0::start/4:

``start/4``
^^^^^^^^^^^

Starts with custom streams and 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 with custom 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_or_error``

| **Exceptions:**
|    The ``Options`` list specifies a unsupported MCP server configuration:
|        ``domain_error(mcp_server_configuration,Version-Transport)``


------------

.. index:: notify/1
.. _mcp_server/0::notify/1:

``notify/1``
^^^^^^^^^^^^

Publishes an application event to the active adapter.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``notify(Event)``
| **Mode and number of proofs:**
|    ``notify(+compound)`` - ``zero_or_one``


------------

Protected predicates
--------------------

(no local declarations; see entity ancestors if any)

Private predicates
------------------

.. index:: active_transport_object_/1
.. _mcp_server/0::active_transport_object_/1:

``active_transport_object_/1``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Currently active transport object.

| **Compilation flags:**
|    ``dynamic``

| **Template:**
|    ``active_transport_object_(TransportObject)``
| **Mode and number of proofs:**
|    ``active_transport_object_(?object_identifier)`` - ``zero_or_one``


------------

Operators
---------

(none)

