protocol
mcp_resource_protocol
Protocol for Logtalk objects that provide resources to be exposed via an MCP (Model Context Protocol) server. Implementing objects must define the set of resources available and handle resource read requests. Applications may also expose parameterized resources using URI templates. Resources expose data and content from the application that MCP clients can access. Used by both the 2025-06-18 and 2026-07-28 adapters.
logtalk_load(mcp_server(loader))static
Capabilities: Objects providing resources must declare
resourcesin theircapabilities/1predicate (from themcp_tool_protocolprotocol). The server will then advertise theresourcescapability and handleresources/list,resources/templates/list, andresources/readrequests.Resource descriptors: Each resource is described by a
resource(URI, Name, Description, MimeType)orresource(URI, Name, Title, Description, MimeType)term whereURIis the resource identifier (an atom),Nameis a human-readable name (an atom),Titleis an optional human-friendly display name (an atom),Descriptionis a human-readable description (an atom), andMimeTypeis the MIME type of the resource content (an atom, e.g.'text/plain').Resource template descriptors: Parameterized resources are optionally described by
resource_template(URITemplate, Name, Description, MimeType)orresource_template(URITemplate, Name, Title, Description, MimeType)terms.URITemplateis an RFC 6570 URI template atom. Template listing is validated as a whole: an invalid template raises adomain_error(uri_template, URITemplate)error and no partial list is advertised. The server advertises valid templates without expanding them; applications validate, authorize, and read concrete expanded URIs usingresource_read/3.Resource contents: The
resource_read/3predicate must return a result term. The result must becontents(ContentList)where each item istext_content(URI, MimeType, Text)for text resources orblob_content(URI, MimeType, Base64Data)for binary resources encoded as base64.Multi-round (2026-07-28): For the 2026-07-28 adapter, applications that need additional input during a resource read implement
resource_read_round/4from themcp_multiround_protocol. Existingresource_read/3remains valid and is wrapped as acompleteresult when the round hook is absent.Caching (2026-07-28): Complete
resources/readresults may include cache fields (ttlMs,cacheScope) derived frommcp_cache_protocolor server options. Cache fields are never attached toinput_requiredresults.
Public predicates
resources/1
Returns a list of resource descriptors available from this object. Each descriptor is a compound term resource(URI, Name, Description, MimeType) or resource(URI, Name, Title, Description, MimeType) where URI is the resource identifier (an atom, typically a URI like logtalk://my-app/data), Name is a human-readable name (an atom), Title is an optional human-friendly display name (an atom), Description is a human-readable description (an atom), and MimeType is the MIME type (an atom, e.g. 'text/plain', 'application/json').
staticresources(Resources)resources(-list(compound)) - oneresource_templates/1
Optional. Returns a list of parameterized resource descriptors. Each descriptor is a resource_template(URITemplate, Name, Description, MimeType) or resource_template(URITemplate, Name, Title, Description, MimeType) term. URITemplate is an RFC 6570 URI template atom. Concrete expanded URIs are handled by resource_read/3.
staticresource_templates(ResourceTemplates)resource_templates(-list(compound)) - zero_or_oneresource_read/3
Handles a resource read request. URI is the resource identifier (as declared in resources/1), Arguments is a list of ArgumentName-Value pairs (currently unused but reserved for future use), and Result is unified with the resource result. The result must be contents(ContentList) where each content item is either text_content(URI, MimeType, Text) for text resources or blob_content(URI, MimeType, Base64Data) for binary resources encoded as base64. Text and Base64Data must be atoms.
staticresource_read(URI,Arguments,Result)resource_read(+atom,+list(pair),--compound) - oneProtected predicates
(none)
Private predicates
(none)
Operators
(none)