Scroll to navigation

MCP::Server::Subscription(3) User Contributed Perl Documentation MCP::Server::Subscription(3)

NAME

MCP::Server::Subscription - Subscription container

SYNOPSIS

  use MCP::Server::Subscription;
  my $subscription = MCP::Server::Subscription->new(id => 1, notifications => {toolsListChanged => 1});
  my $bool         = $subscription->wants('notifications/tools/list_changed');

DESCRIPTION

MCP::Server::Subscription is a container for a "subscriptions/listen" notification stream.

ATTRIBUTES

MCP::Server::Subscription implements the following attributes.

id

  my $id        = $subscription->id;
  $subscription = $subscription->id(1);

The JSON-RPC id of the "subscriptions/listen" request that opened this subscription, sent to the client as "_meta.io.modelcontextprotocol/subscriptionId" with every message on the stream.

notifications

  my $filter    = $subscription->notifications;
  $subscription = $subscription->notifications({toolsListChanged => 1});

The notification filter the client requested, as a hash reference. Notification types that were not requested are never delivered.

stream

  my $stream    = $subscription->stream;
  $subscription = $subscription->stream(Mojolicious::Controller->new);

The Mojolicious::Controller serving the SSE stream for this subscription, when the HTTP transport is in use.

METHODS

MCP::Server::Subscription inherits all methods from Mojo::Base and implements the following new ones.

acknowledgement

  my $notification = $subscription->acknowledgement;

The "notifications/subscriptions/acknowledged" notification a server has to send as the very first message on a subscription stream, listing the notification types it will actually deliver.

honoured

  my $filter = $subscription->honoured;

The subset of "notifications" the server actually supports.

notification

  my $notification = $subscription->notification($method);
  my $notification = $subscription->notification($method, {foo => 'bar'});

Build a JSON-RPC notification for this subscription, tagged with "id" in "_meta.io.modelcontextprotocol/subscriptionId".

wants

  my $bool = $subscription->wants('notifications/tools/list_changed');

Returns true if the given notification method was requested in "notifications".

SEE ALSO

MCP, <https://mojolicious.org>, <https://modelcontextprotocol.io>.

2026-07-31 perl v5.44.0