table of contents
- Tumbleweed 0.150.0-1.1
- Leap-16.0
| MCP::Server::Transport::Stdio(3) | User Contributed Perl Documentation | MCP::Server::Transport::Stdio(3) |
NAME¶
MCP::Server::Transport::Stdio - Stdio transport for MCP servers
SYNOPSIS¶
use MCP::Server::Transport::Stdio; my $stdio = MCP::Server::Transport::Stdio->new;
DESCRIPTION¶
MCP::Server::Transport::Stdio is a transport for MCP (Model Context Protocol) server that reads requests from standard input (STDIN) and writes responses to standard output (STDOUT). It is designed for command-line tools and debugging tasks.
All messages share the one channel, so a "subscriptions/listen" request is answered with an acknowledgement notification and then left open, with its JSON-RPC response withheld until the client cancels it.
Requests are processed strictly in order, so a "notifications/cancelled" notification cannot be read while the request it refers to is still in flight; it can only cancel a subscription. Use MCP::Server::Transport::HTTP for workloads where cancelling a running tool matters.
ATTRIBUTES¶
MCP::Server::Transport::Stdio inherits all attributes from MCP::Server::Transport and implements the following new ones.
subscriptions¶
my $subscriptions = $stdio->subscriptions;
$stdio = $stdio->subscriptions({});
Registry of active MCP::Server::Subscription objects, keyed by the id of the request that opened them.
METHODS¶
MCP::Server::Transport::Stdio inherits all methods from MCP::Server::Transport and implements the following new ones.
handle_requests¶
$stdio->handle_requests;
Reads requests from standard input and prints responses to standard output.
notify_all¶
my $bool = $stdio->notify_all($method);
my $bool = $stdio->notify_all($method, {foo => 'bar'});
Send a JSON-RPC notification to standard output, once for every subscription in "subscriptions" that asked for it.
SEE ALSO¶
MCP, <https://mojolicious.org>, <https://modelcontextprotocol.io>.
| 2026-07-31 | perl v5.44.0 |