NAME
AnyEvent::MCP::Helper - asynchronous JSON exchange with an external helper
SYNOPSIS
use AnyEvent::MCP::Helper;
my $job = AnyEvent::MCP::Helper->new (
helper => ["my-helper", "--option"], timeout => 300,
);
$job->ask ($input, sub {
my ($success, $result) = @_;
...
});
DESCRIPTION
Runs an executable (or an argument array, never a shell command), writes one UTF-8 JSON value to its stdin and closes that input. A successful helper writes one JSON value to stdout and exits zero. Diagnostics use stderr.
ask ($input, $done) calls $done->($success, $result) once. On failure, $result is an error string. One exchange may be active per object. timeout defaults to 300 seconds and max_size to 1 MiB of output. cancel ($reason) terminates the helper and completes with failure. The independent child watcher reaps the helper after cancellation too.
This module handles processes and bytes, not the meaning of the JSON. It is the transport for local form and permission helpers: an MCP server or multibroker can ask a human without blocking its AnyEvent loop. Ordinary server authors should normally use AnyEvent::MCP::Server::Permissions or the form facilities in AnyEvent::MCP::Permissions::Ask, not launch helpers directly. AnyEvent::MCP::Permissions::Ask provides the permission interface; anyevent-mcp-form-elicitation implements the standard form request/response contract.