NAME
Net::Async::MCP::Transport::Stdio - Stdio MCP transport via subprocess JSON-RPC
VERSION
version 0.001
SYNOPSIS
# Usually created automatically by Net::Async::MCP
use IO::Async::Loop;
use Net::Async::MCP;
my $loop = IO::Async::Loop->new;
my $mcp = Net::Async::MCP->new(
command => ['npx', '@anthropic/mcp-server-web-search'],
);
$loop->add($mcp);
DESCRIPTION
Net::Async::MCP::Transport::Stdio communicates with an external MCP server process via stdin/stdout using newline-delimited JSON-RPC 2.0. The subprocess is managed as an IO::Async::Process child notifier.
This transport works with any MCP server that supports the stdio transport, regardless of implementation language (Perl, Node.js, Python, Go, etc.).
Requests are matched to responses by their JSON-RPC id field. Each pending request is represented by a Future that resolves when the matching response arrives. If the subprocess exits unexpectedly, all pending futures are failed with an error message including the exit code.
This transport is selected automatically by Net::Async::MCP when constructed with a command argument.
send_request
my $future = $transport->send_request($method, \%params);
Encodes a JSON-RPC request and writes it as a newline-terminated JSON line to the subprocess stdin. Returns a Future that resolves to the result value when the matching response is read from stdout, or fails with an error if the server returns a JSON-RPC error or the process exits.
Fails immediately if the subprocess has already exited.
send_notification
my $future = $transport->send_notification($method, \%params);
Encodes a JSON-RPC notification (no id field, no response expected) and writes it to the subprocess stdin. Returns an immediately resolved Future.
Fails immediately if the subprocess has already exited.
close
my $future = $transport->close;
Sends SIGTERM to the subprocess and returns a Future that resolves when the process exits. If the process has already exited, returns an immediately resolved Future.
SEE ALSO
Net::Async::MCP - Main client module that uses this transport
Net::Async::MCP::Transport::InProcess - Alternative transport for in-process Perl servers
IO::Async::Process - Subprocess management used internally
IO::Async::Notifier - Base class
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-net-async-mcp/issues.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de> https://raudss.us/
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.