| 1 | package MCP::Primitive; | ||||||||||
| 2 | 4 | ▶ | use Mojo::Base -base, -signatures; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 4 | ▶ | use MCP::Server::Context; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 24 | ▶ | has scopes => sub { [] }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 7 | ▶ | sub context ($self) { $self->{context} || MCP::Server::Context->new } | ||||||||
|
Subroutine
context: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||
| 9 | |||||||||||
| 10 | 4 | 1; | |||||||||
| 11 | |||||||||||
| 12 | =encoding utf8 | ||||||||||
| 13 | |||||||||||
| 14 | =head1 NAME | ||||||||||
| 15 | |||||||||||
| 16 | MCP::Primitive - Primitive base class | ||||||||||
| 17 | |||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||
| 19 | |||||||||||
| 20 | package MyMCPPrimitive; | ||||||||||
| 21 | use Mojo::Base 'MCP::Primitive'; | ||||||||||
| 22 | |||||||||||
| 23 | 1; | ||||||||||
| 24 | |||||||||||
| 25 | =head1 DESCRIPTION | ||||||||||
| 26 | |||||||||||
| 27 | L<MCP::Primitive> is a base class for MCP (Model Context Protocol) primitives such as L<MCP::Tool>, L<MCP::Prompt>, | ||||||||||
| 28 | and L<MCP::Resource>. | ||||||||||
| 29 | |||||||||||
| 30 | =head1 ATTRIBUTES | ||||||||||
| 31 | |||||||||||
| 32 | L<MCP::Primitive> implements the following attributes. | ||||||||||
| 33 | |||||||||||
| 34 | =head2 scopes | ||||||||||
| 35 | |||||||||||
| 36 | my $scopes = $primitive->scopes; | ||||||||||
| 37 | $primitive = $primitive->scopes(['mcp:read', 'mcp:write']); | ||||||||||
| 38 | |||||||||||
| 39 | OAuth scopes required to list or call this primitive, as an array reference. Defaults to no required scopes. | ||||||||||
| 40 | |||||||||||
| 41 | =head1 METHODS | ||||||||||
| 42 | |||||||||||
| 43 | L<MCP::Primitive> inherits all methods from L<Mojo::Base> and implements the following new ones. | ||||||||||
| 44 | |||||||||||
| 45 | =head2 context | ||||||||||
| 46 | |||||||||||
| 47 | my $context = $primitive->context; | ||||||||||
| 48 | |||||||||||
| 49 | Returns the L<MCP::Server::Context> for the current request. Capture this before an async boundary to keep using | ||||||||||
| 50 | its notification methods from later callbacks. | ||||||||||
| 51 | |||||||||||
| 52 | # Get controller for requests using the HTTP transport | ||||||||||
| 53 | my $c = $primitive->context->controller; | ||||||||||
| 54 | |||||||||||
| 55 | =head1 SEE ALSO | ||||||||||
| 56 | |||||||||||
| 57 | L<MCP>, L<https://mojolicious.org>, L<https://modelcontextprotocol.io>. | ||||||||||
| 58 | |||||||||||
| 59 | =cut | ||||||||||