table of contents
| MCP::Prompt(3) | User Contributed Perl Documentation | MCP::Prompt(3) |
NAME¶
MCP::Prompt - Prompt container
SYNOPSIS¶
use MCP::Prompt; my $prompt = MCP::Prompt->new;
DESCRIPTION¶
MCP::Prompt is a container for prompts.
ATTRIBUTES¶
MCP::Prompt implements the following attributes.
arguments¶
my $args = $prompt->arguments;
$prompt = $prompt->arguments([{name => 'foo', description => 'Whatever', required => 1}]);
Arguments for the prompt.
code¶
my $code = $prompt->code;
$prompt = $prompt->code(sub { ... });
Prompt code.
description¶
my $description = $prompt->description;
$prompt = $prompt->description('A brief description of the prompt');
Description of the prompt.
name¶
my $name = $prompt->name;
$prompt = $prompt->name('my_prompt');
Name of the Prompt.
METHODS¶
MCP::Prompt inherits all methods from Mojo::Base and implements the following new ones.
call¶
my $result = $prompt->call($args, $context);
Calls the prompt with the given arguments and context, returning a result. The result can be a promise or a direct value.
context¶
my $context = $prompt->context;
Returns the context in which the prompt is executed.
# Get controller for requests using the HTTP transport
my $c = $prompt->context->{controller};
text_prompt¶
my $result = $prompt->text_prompt('Some text');
my $result = $prompt->text_prompt('Some text', $role);
my $result = $prompt->text_prompt('Some text', $role, $description);
Returns a text prompt in the expected format.
validate_input¶
my $bool = $prompt->validate_input($args);
Validates the input arguments. Returns true if validation failed.
SEE ALSO¶
MCP, <https://mojolicious.org>, <https://modelcontextprotocol.io>.
| 2025-10-06 | perl v5.42.0 |