protocol
mcp_resource_protocol
Protocol for Logtalk objects that provide resources to be exposed via an MCP (Model Context Protocol) server. Implements the MCP 2025-06-18 specification. Implementing objects must define the set of resources available and handle resource read requests. Resources expose data and content from the application that MCP clients can access.
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/listandresources/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 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.
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_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)