NAME
MCP::Primitive - Primitive base class
SYNOPSIS
package MyMCPPrimitive;
use Mojo::Base 'MCP::Primitive';
1;
DESCRIPTION
MCP::Primitive is a base class for MCP (Model Context Protocol) primitives such as MCP::Tool, MCP::Prompt, and MCP::Resource.
ATTRIBUTES
MCP::Primitive implements the following attributes.
scopes
my $scopes = $primitive->scopes;
$primitive = $primitive->scopes(['mcp:read', 'mcp:write']);
OAuth scopes required to list or call this primitive, as an array reference; all of them must be granted. This is a local authorization policy layered on the HTTP transport's "auth" in MCP::Server::Transport::HTTP hook, not wire-level MCP metadata, and is only enforced for requests that supply scopes (so it has no effect over stdio). Defaults to no required scopes.
METHODS
MCP::Primitive inherits all methods from Mojo::Base and implements the following new ones.
context
my $context = $primitive->context;
Returns the MCP::Server::Context for the current request. Capture this before an async boundary to keep using its notification methods from later callbacks.
# Get controller for requests using the HTTP transport
my $c = $primitive->context->controller;
SEE ALSO
MCP, https://mojolicious.org, https://modelcontextprotocol.io.