NAME
MCP::Resource - Resource container
SYNOPSIS
use MCP::Resource;
my $resource = MCP::Resource->new;
DESCRIPTION
MCP::Resource is a container for resources.
ATTRIBUTES
MCP::Resource implements the following attributes.
code
my $code = $resource->code;
$resource = $resource->code(sub { ... });
Resource code.
description
my $description = $resource->description;
$resource = $resource->description('A brief description of the resource');
Description of the resource.
mime_type
my $mime_type = $resource->mime_type;
$resource = $resource->mime_type('text/plain');
MIME type of the resource.
name
my $name = $resource->name;
$resource = $resource->name('my_resource');
Name of the resource.
uri
my $uri = $resource->uri;
$resource = $resource->uri('file:///path/to/resource.txt');
URI of the resource.
METHODS
MCP::Resource inherits all methods from Mojo::Base and implements the following new ones.
binary_resource
my $result = $resource->binary_resource($data);
Returns a binary resource in the expected format.
call
my $result = $resource->call($context);
Calls the resource with context, returning a result. The result can be a promise or a direct value.
context
my $context = $resource->context;
Returns the context in which the resouce is executed.
# Get controller for requests using the HTTP transport
my $c = $resource->context->{controller};
text_resource
my $result = $resource->text_resource('Some text');
Returns a text resource in the expected format.
SEE ALSO
MCP, https://mojolicious.org, https://modelcontextprotocol.io.