bin/mcp-multibroker

filter: Statementstmt 89.8% 284 / 316 Branchbran 67.1% 141 / 210 Conditioncond 62.2% 79 / 127 MC/DCmcdc 40.3% 27 / 67 Subroutinesub 86.7% 46 / 53 Podpod n/a totaltotal 74.6% 577 / 773 CC 135 SCAR 24.1
CC
135
Cov
77%
__ANON__
30.0
on_child_notification
30.0
__ANON__
27.5
CRAP 11.1
« blib/lib/AnyEvent/MCP/File.pm ↑ Summary blib/lib/AnyEvent/MCP/Workdirs.pm »
1 #!/opt/bin/perl
2  
3 =head1 NAME
4  
5 mcp-multibroker - combine MCP servers under tool name prefixes
6  
7 =head1 SYNOPSIS
8  
9 mcp-multibroker files 'stdio:mcp-fs /home/alice/src/project' \
10 search https://example.org/mcp/ --bearer TOKEN
11 mcp-multibroker vim --- mcp-vim --bind :: --- --required
12  
13 =head1 DESCRIPTION
14  
15 C<mcp-multibroker> combines several MCP servers behind one connection to
16 your MCP client. You can give an assistant access to filesystem tools,
17 Vim editors and other services by configuring them here, then connecting
18 the client to this broker.
19  
20 For each server, give a name prefix and an HTTP URL, a C<stdio:COMMAND>,
21 or C<--- PROGRAM ARG... ---> to start it as a subprocess. These are the downstream
22 servers. The multibroker starts or connects to them, obtains their tool
23 definitions and forwards tool calls and replies between them and your
24 client.
25  
26 The prefix identifies which server a tool belongs to. For example, a
27 filesystem server configured as C<files> has a tool named
28 C<files.read-lines>. Your client can ask the multibroker which servers and
29 tools are available, then call a tool by its prefixed name.
30  
31 The connection from your MCP client to the multibroker is the upstream
32 connection. It can use HTTP or stdin/stdout, independently of how the
33 downstream servers connect. See L<AnyEvent::MCP::Intro> for a complete
34 setup example.
35  
36 =head1 FIRST USE
37  
38 Configure a local MCP client to start a multibroker with two servers:
39  
40 mcp-multibroker --stdio \
41 files --- mcp-fs --name project /home/alice/src/project --- \
42 questions --- mcp-ask-user ---
43  
44 The client launches only the broker; it starts children as needed. Ask:
45  
46 Call discover-brokers and list-tools, then use files.workdirs
47 to show which project directories are configured.
48  
49 C<files> and C<questions> are routing prefixes, not child instance names
50 or permission profiles. Each child still applies its own permissions.
51 The broker selects stdio automatically for bundled AnyEvent::MCP children.
52 Third-party servers must support MCP over stdio in their own startup mode.
53 You can replace a child with any stdio-speaking MCP server by putting
54 its executable and arguments between the C<---> delimiters, or connect
55 an existing HTTP server by URL; see L</DOWNSTREAM SERVERS>.
56  
57 For HTTP clients, omit C<--stdio>, leave the broker running, and obtain
58 its upstream URL with C<--print-url> using the same listener settings.
59 For missing tools, try C<discover-brokers> for connection errors and
60 C<list-tools> to refresh discovery; your MCP client may also need to
61 refresh its cached list. C<--tool-help> only shows the broker's own
62 tools, not those of its children. Ordinary children start lazily. Use C<--eager>
63 after the child specification for services that accept independent
64 connections, such as Vim or browser brokers.
65  
66 =head1 TOOLS
67  
68 The broker exposes three tools of its own:
69  
70 =over
71  
72 =item discover-brokers
73  
74 Lists the configured downstream servers and their instructions by prefix.
75 An entry is a string of instructions, C<null> for a reachable server with
76 no instructions, or C<{error: MESSAGE}> for an unreachable server.
77 Hidden servers are listed, with instructions on how to discover their tools.
78  
79 =item list-tools
80  
81 Queries downstream servers for their tool definitions and refreshes the
82 combined list. An optional C<broker> argument selects one exact downstream
83 prefix, including hidden servers and excluding the multibroker's own tools.
84 Without C<broker>, hidden servers are omitted. Unknown broker names or
85 arguments are errors. Unreachable servers are omitted from tool listings
86 but reported by C<discover-brokers>.
87  
88 =item call-tool
89  
90 Calls a downstream tool by its C<PREFIX.TOOL> name with the supplied
91 arguments, including hidden servers. Calls to an unavailable server fail
92 as tool errors; calls are
93 not replayed after transport failures.
94  
95 =back
96  
97 A refreshed list is a snapshot of what is reachable at that point. It
98 includes configured servers and currently registered reverse connections.
99 A listed server might become unavailable before a later call.
100  
101 =head1 DOWNSTREAM SERVERS
102  
103 Each prefix identifies one downstream server. HTTP URLs may include a URL-path token,
104 or be followed by C<--bearer TOKEN>. C<bearer> and C<timeout> defaults
105 are read from C<[client PREFIX]> in the global configuration; the URL in
106 the command line overrides any configured C<url>. Stdio children receive
107 C<PERL_ANYEVENT_MCP_MULTIBROKER_PROTOCOL=stdio> and
108 C<PERL_ANYEVENT_MCP_MULTIBROKER_ALIAS=PREFIX> in their environment.
109 The alias may be displayed in downstream permission prompts, without changing
110 the server's instance name or permission rules.
111  
112 For direct execution, use C<PREFIX --- PROGRAM ARG... --->:
113  
114 mcp-multibroker vim --- mcp-vim --bind :: --- --eager \
115 files --- mcp-fs '/home/alice/project with spaces' ---
116  
117 The next exact C<---> argument closes the list. Everything inside, including
118 C<-->, C<--eager> and C<--bearer>, is passed unchanged to the child. There is
119 no shell interpretation. Empty arguments are preserved; the program must be
120 nonempty. An empty list or missing closing delimiter is an error.
121  
122 A subprocess can also connect to an MCP server on another machine via SSH:
123  
124 mcp-multibroker remote-fs --- ssh remotehost mcp-fs --stdio --ask mcp /workdir ---
125  
126 C<--stdio> tells the remote C<mcp-fs> to use stdin/stdout for MCP. It must be
127 specified explicitly because the multibroker's environment variables are
128 not passed through SSH. C<--ask mcp> forwards permission prompts over MCP to
129 the local multibroker, instead of trying to display dialogs on the remote
130 host. The local broker then presents them according to its own C<--ask> mode
131 (normally using a local helper); see L</PERMISSION PROMPTS>.
132  
133 C<stdio:COMMAND> retains shell interpretation. Use it for shell syntax or
134 when a child needs a literal C<---> argument. Quoting C<'---'> in the
135 delimited form cannot escape the delimiter: shell quoting is already gone.
136  
137 Broker-wide options precede the first server entry. Downstream options
138 follow that server's URL or closing C<--->; Getopt::Long stops at the next
139 prefix. Options inside an argv list belong exclusively to the child.
140  
141 C<--hidden> after a server keeps its tools out of normal MCP C<tools/list>
142 and unfiltered C<list-tools> results. This reduces the initial tool list
143 for large or rarely used servers. C<discover-brokers> still lists it;
144 C<list-tools broker=PREFIX>
145 returns its definitions, and C<call-tool> still works. Hiding reduces the
146 advertised tool set, not the permissions or availability of the server.
147  
148 C<--eager> after either stdio form starts that child at
149 multibroker startup rather than waiting for its first MCP use. This is useful
150 for children that also provide their own TCP service, such as C<mcp-vim>.
151 Other stdio children remain lazy. Eager startup attempts one connection and
152 logs failures; it does not continually restart failed children.
153 C<--required> implies C<--eager> and makes the multibroker exit with failure
154 if that child cannot initialize or later disconnects unexpectedly. A supervisor
155 can then restart the broker. An explicitly accepted managed idle shutdown is
156 not a failure; the child can be started again on the next use. Both options
157 apply only to spawned stdio children, never remote HTTP peers.
158  
159 =head2 Reverse connections
160  
161 The HTTP listener also accepts authenticated reverse MCP connections. It
162 can run with no configured downstream servers. With upstream stdio, add
163 C<--listen> to keep this listener active:
164  
165 mcp-multibroker --stdio --listen --bind 127.0.0.1:31740
166 mcp-multibroker --bind 127.0.0.1:31740 --print-url
167 mcp-fs --connect http://127.0.0.1:31740/TOKEN/files /home/alice/project
168  
169 Use the token returned by C<--print-url>. The connecting server extracts
170 the host, port, token and alias from this URL, sends
171 C<["mcp-connect", token, alias]> followed by a newline, then ordinary MCP
172 JSONL. The connection uses the HTTP listener but is not an HTTP request.
173 With C<--tls-cert> or C<--tls-key>, the same port also accepts TLS, and
174 C<--print-url> prints HTTPS first and HTTP second. Reverse connections using
175 C<https://> verify the listener certificate and hostname; C<http://> uses
176 plaintext.
177 It uses the same accepted tokens as HTTP. Authentication grants registration
178 under any free alias; configured or connected aliases cannot be replaced.
179  
180 The connecting program remains the MCP server. The multibroker attaches an
181 MCP client and discovers its tools immediately. Forms and cancellation follow
182 the same routes as other downstream connections. An unexpected disconnect
183 fails pending calls, removes the registration and starts a new connection
184 period. Refused TCP connections are retried every second, up to sixty times.
185 Other TCP setup failures and TLS verification failures log an error and stop;
186 there is no automatic downgrade to plaintext. No interrupted operation is
187 replayed. Plain HTTP endpoint URLs do not provide transport encryption;
188 use a trusted connection or tunnel as needed.
189  
190 =head2 Process lifetime
191  
192 Each downstream connection advertises C<anyevent-mcp/multibroker> version 1
193 in its client capabilities. A spawned stdio child can request managed idle
194 shutdown with C<anyevent-mcp/idle-exit>. When no calls are outstanding, the
195 broker may send C<anyevent-mcp/shutdown>; the child acknowledges before
196 exiting. This is optional and never makes HTTP children exit. Unexpected
197 disconnects are logged, not proactively restarted. A later use reconnects.
198  
199 =head1 PERMISSION PROMPTS
200  
201 C<--ask helper> (the default) answers downstream form challenges locally.
202 Ordinary forms use C<anyevent-mcp-form-elicitation>; permission requests keep their
203 specialised permission dialogs. C<--ask mcp> forwards modern challenges to
204 the upstream client. C<--ask auto> uses upstream form support when advertised,
205 otherwise the local helper. Both modes deliberately trust the upstream
206 client's user assertion when permission authority has been delegated to it.
207 The multibroker forwards the original authenticated user with every tool call,
208 even when a downstream saved permission rule resolves that request without
209 another prompt. A decline or cancel is never retried through another
210 interface. If a client advertises forms but silently declines them,
211 select C<helper> explicitly.
212  
213 C<--ask tty> and C<--ask yad> select only the built-in terminal or YAD
214 interface for both ordinary forms and permission dialogs. These modes
215 ignore custom helper variables and do not fall back to another interface.
216  
217 The broker advertises its local form support to downstream calls when it
218 will handle their forms itself. In C<mcp> mode it forwards the upstream
219 caller's capabilities instead. Local forms work for HTTP and stdio children,
220 including when the upstream caller cannot handle native input challenges.
221 Continuation tokens remain opaque; the broker sends the human response back
222 to the same downstream operation and returns its eventual result.
223  
224 Spawned stdio children default to C<--ask mcp>, delegating permissions to
225 the multibroker, which handles them according to its own C<--ask> mode.
226 An explicit child C<--ask> overrides this default. Independently running
227 servers keep their own configuration.
228 Spawned C<mcp-ask-user> instances normally delegate presentation to this broker.
229 Use C<--ask mcp> on a separately started C<mcp-ask-user> to delegate to its
230 connecting client, including a multibroker.
231  
232 Local permission and question dialogs share one queue. Set
233 C<PERL_ANYEVENT_MCP_ELICITATION_HELPER> to replace the form helper and
234 C<PERL_ANYEVENT_MCP_PERMISSION_HELPER> to replace the permission helper.
235 Cancelling a tool call cancels its downstream operation and pending local
236 prompt.
237  
238 =head1 CLIENT CONNECTION
239  
240 The upstream listener uses L<AnyEvent::MCP::Server::Simple/mcp_start>: HTTP
241 without stdout output by default, or stdio when run by another broker.
242 The service instance name defaults to C<default>. Repeated
243 C<--token TOKEN> options before the broker pairs configure credentials
244 accepted by the upstream HTTP listener. They are separate from C<--bearer>
245 after a downstream broker URL, which authenticates the client connection.
246 C<--name NAME>
247 selects C<[instance NAME]> in the global configuration, including its
248 credentials and optional C<bind> address. C<--bind ADDRESS[:PORT]> overrides
249 that address. The default is IPv4 loopback with a stable name-derived port
250 in 16384..32767. Port zero requests an ephemeral port.
251 C<--print-url> prints the credential-bearing URL without opening a listener
252 or starting children; it requires a nonzero port. Upstream stdio startup
253 skips HTTP listener configuration unless C<--listen> is specified; named HTTP
254 children still load their client defaults. Browser origins are unrestricted by default; HTTP requests
255 still require an accepted token. See L<AnyEvent::MCP::Intro> for examples.
256  
257 =head1 OPTIONS
258  
259 Shared upstream switches are documented in
260 L<AnyEvent::MCP::Server::Simple/COMMON COMMAND-LINE OPTIONS>.
261 Put broker-wide options before the first PREFIX/URL pair. Downstream
262 options must immediately follow the server they configure.
263  
264 =head2 Broker options
265  
266 =over
267  
268 =item --listen
269  
270 Keep the upstream HTTP/extension listener active alongside C<--stdio>
271 or C<--connect>. Without those, HTTP is already the default.
272 Applies to the broker, not its downstream servers.
273  
274 =item --ask MODE
275  
276 Select how downstream permission prompts are presented:
277 C<helper> (default), C<tty>, C<yad>, C<mcp>, or C<auto>.
278 This also supplies the default asking mode to spawned stdio children.
279 See L</PERMISSION PROMPTS>.
280  
281 =back
282  
283 =head2 Downstream options
284  
285 =over
286  
287 =item --bearer TOKEN
288  
289 Authenticate the preceding HTTP(S) child with a bearer token, not
290 the broker's upstream listener. Supply after the child URL;
291 invalid for stdio children.
292  
293 =item --hidden
294  
295 Omit the preceding child's tools from ordinary tool discovery,
296 including unfiltered C<list-tools>. Discover its definitions with
297 C<list-tools> specifying its C<broker> prefix. Its tools remain
298 callable by name. Applies to HTTP and stdio children.
299  
300 =item --eager
301  
302 Start the preceding stdio child at broker startup instead of on
303 first use. Not available for HTTP children.
304  
305 =item --required
306  
307 Require the preceding stdio child to initialize and remain connected.
308 Implies C<--eager>; an unexpected disconnect causes the broker to exit.
309 Managed idle shutdown is permitted. Not available for HTTP children.
310  
311 =back
312  
313 =head2 Shared-option behavior
314  
315 =over
316  
317 =item --name NAME
318  
319 Select the upstream broker's instance (default C<default>).
320 Does not affect downstream prefixes or their instance names.
321  
322 =item --token TOKEN
323  
324 Authenticate clients of the upstream broker. To authenticate an
325 HTTP(S) child, use C<--bearer> after its URL instead.
326  
327 =item --tool-help
328  
329 Lists only the broker's own tools. Use its C<list-tools> tool to
330 discover individual downstream registries.
331  
332 =item --auto-allow TOOL[,ACTION[,CAPABILITY]]
333  
334 Matches the broker-visible tool names, not a downstream server's
335 independent permission checks.
336  
337 =back
338  
339 =cut
340  
341 46 ▶use common::sense;
Subroutine BEGIN: called CC=1 SCAR=0.0
342 46 ▶use Getopt::Long ();
Subroutine BEGIN: called CC=1 SCAR=0.0
343  
344 46 ▶use AnyEvent ();
Subroutine BEGIN: called CC=1 SCAR=0.0
345 46 ▶use AnyEvent::MCP::Client::HTTP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
346 46 ▶use AnyEvent::MCP::Client::JSONL ();
Subroutine BEGIN: called CC=1 SCAR=0.0
347 46 ▶use AnyEvent::MCP::Permissions::Ask ();
Subroutine BEGIN: called CC=1 SCAR=0.0
348 46 ▶use AnyEvent::MCP::Helper ();
Subroutine BEGIN: called CC=1 SCAR=0.0
349 46 ▶use AnyEvent::MCP::Config ();
Subroutine BEGIN: called CC=1 SCAR=0.0
350 46 ▶use AnyEvent::MCP::Server::Toolset ();
Subroutine BEGIN: called CC=1 SCAR=0.0
351  
352 46 ▶use AnyEvent::MCP::Server::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
353  
354 46 AnyEvent::detect; # Initialise child watchers before starting subprocesses.
355 46 $| = 1;
356  
357 46 my $usage = "Usage: $0 [OPTION]... PREFIX (URL | --- PROGRAM ARG... ---) [CHILD-OPTION] ...\n";
358 46 Getopt::Long::Configure ("require_order");
359 46 my $server_options = mcp_getoptions ({
360 usage => $usage,
361 path => "/",
362 description => "Combine MCP servers behind one endpoint, with tools named PREFIX.TOOL.\n"
363 . "Each server is HTTP(S), stdio:COMMAND, or --- PROGRAM ARG... ---; downstream options follow its entry.",
364 options => [
365 "Broker-wide options:",
366 ["--ask MODE", "Before server entries: prompt locally (helper, default; tty; yad), upstream (mcp), or by capability (auto)"],
367 ["--listen", "Keep the upstream HTTP listener active alongside stdio or --connect"],
368 "Downstream options (after the URL or closing ---):",
369 ["--eager", "Start the preceding stdio child at broker startup"],
370 ["--required", "Require stdio child; implies --eager, exit on failure"],
371 ["--bearer TOKEN", "Authenticate to the preceding HTTP child"],
372 ["--hidden", "Hide child's tools from default discovery; explicit list-tools and calls still work"],
373 ],
374 examples => " $0 --ask auto files 'stdio:mcp-fs /home/alice/src/project'\n"
375 . " $0 files --- mcp-fs /home/alice/src/project --- --eager\n"
376 . " $0 vim --- mcp-vim --bind :: --- --required\n"
377 . " $0 remote https://example.org/mcp/ --bearer TOKEN\n"
378 . " $0 --name tools --print-url",
379 },
380 "ask=s" => \my $ask_mode,
381 "listen" => \my $listen,
382 );
383 $AnyEvent::Log::FILTER->level ("debug")
384 unless defined $ENV{PERL_ANYEVENT_VERBOSE}
385 40 ▶ || ($ENV{PERL_ANYEVENT_LOG} // "") =~ /(?:\A|\s)filter=/;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ENV{"PERL_ANYEVENT_VERBOSE"} or ($ENV{"PERL_ANYEVENT_LOG"} // "") =~ /(?:\A|\s)filter=/u 1 39 40
Condition60%3/5
defined $ENV{"PERL_ANYEVENT_VERBOSE"} or ($ENV{"PERL_ANYEVENT_LOG"} // "") =~ /(?:\A|\s)filter=/u
l!l&&r!l&&!r
0391
$ENV{"PERL_ANYEVENT_LOG"} // ""
l!l
400
MC/DC0%0/2
defined $ENV{"PERL_ANYEVENT_VERBOSE"} or ($ENV{"PERL_ANYEVENT_LOG"} // "") =~ /(?:\A|\s)filter=/u
defined $ENV{"PERL_ANYEVENT_VERBOSE"} $ENV{"PERL_ANYEVENT_LOG"}
Truth table33%1/3
A or B
A= defined $ENV{"PERL_ANYEVENT_VERBOSE"}B= $ENV{"PERL_ANYEVENT_LOG"}
ABresult
1X1
011
000
386 40 ▶$ask_mode //= $ENV{PERL_ANYEVENT_MCP_PERMISSION_ASK} || "helper";
Condition100%4/4
$ask_mode //= $ENV{"PERL_ANYEVENT_MCP_PERMISSION_ASK"} || "helper"
l!l
2020
$ENV{'PERL_ANYEVENT_MCP_PERMISSION_ASK'} || 'helper'
l!l
119
MC/DC100%1/1
$ask_mode //= $ENV{"PERL_ANYEVENT_MCP_PERMISSION_ASK"} || "helper"
$ask_mode
Truth table100%2/2
A
A= $ask_mode
Aresult
11
00
387 40 ▶die "--ask must be helper, tty, yad, auto, or mcp\n"
Branch: 1 branch
BranchTrueFalseTotal
if defined $ask_mode and not $ask_mode =~ /\A(?:helper|tty|yad|auto|mcp)\z/u 0 40 40
Condition33%1/3
defined $ask_mode and not $ask_mode =~ /\A(?:helper|tty|yad|auto|mcp)\z/u
!ll&&!rl&&r
0400
MC/DC0%0/2
defined $ask_mode and not $ask_mode =~ /\A(?:helper|tty|yad|auto|mcp)\z/u
defined $ask_mode not $ask_mode =~ /\A(?:helper|tty|yad|auto|mcp)\z/u
Truth table33%1/3
A and not(B)
A= defined $ask_modeB= not $ask_mode =~ /\A(?:helper|tty|yad|auto|mcp)\z/u
ABresult
0X0
100
111
388 if defined $ask_mode && $ask_mode !~ /\A(?:helper|tty|yad|auto|mcp)\z/;
389  
390 40 my (%broker, %stdio, %eager, %required, %hidden);
391 40 my $shutting_down;
392 40 my @prompts;
393 40 my $prompt;
394  
395 # keep local dialogs serial, including dialogs from different brokers.
396 sub next_prompt;
397 12 ▶sub ask_prompt {
Subroutine ask_prompt: called CC=1 SCAR=2.4
398 12 my ($req, $prepared, $done, $form) = @_;
399  
400 12 my $entry = { request => $req, prepared => $prepared, done => $done, form => $form };
401 12 push @prompts, $entry;
402  
403 12 my $old_cancel = $req->{on_cancel};
404 0 ▶ $req->{on_cancel} = sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
405 AE::log trace => "local prompt cancelled "
406 0 ▶ . (defined $entry->{started} ? sprintf ("after %.2fs", AE::now - $entry->{started}) : "while queued")
Branch: 2 branches
BranchTrueFalseTotal
defined $entry->{'started'} ? : 0 0 0
defined $_[1] ? : 0 0 0
407 . (defined $_[1] ? ": $_[1]" : "");
408 0 ▶ $entry->{job}->cancel if $entry->{job};
Branch: 1 branch
BranchTrueFalseTotal
if $entry->{"job"} 0 0 0
409 0 ▶ $old_cancel->(@_) if $old_cancel;
Branch: 1 branch
BranchTrueFalseTotal
if $old_cancel 0 0 0
410 12 };
411 12 next_prompt;
412 }
413  
414 24 ▶sub next_prompt {
Subroutine next_prompt: called CC=11 SCAR=24.5
415 24 ▶ return if $prompt;
Branch: 1 branch
BranchTrueFalseTotal
if $prompt 0 24 24
416 24 ▶ while (@prompts) {
Branch: 1 branch
BranchTrueFalseTotal
if (@prompts) 12 12 24
417 12 my $entry = shift @prompts;
418 12 ▶ next if $entry->{request}{finished};
Branch: 1 branch
BranchTrueFalseTotal
if $entry->{"request"}{"finished"} 0 12 12
419 12 $prompt = $entry;
420 $entry->{job} = $entry->{form}
421 ? AnyEvent::MCP::Helper->new (
422 helper => $ask_mode eq "tty" || $ask_mode eq "yad"
423 ? ["anyevent-mcp-form-elicitation", "--$ask_mode"]
424 12 ▶ : $ENV{PERL_ANYEVENT_MCP_ELICITATION_HELPER} || "anyevent-mcp-form-elicitation",
Branch: 3 branches
BranchTrueFalseTotal
$entry->{'form'} ? : 7 5 12
$ask_mode eq 'tty' || $ask_mode eq 'yad' ? : 2 5 7
$ask_mode eq 'tty' || $ask_mode eq 'yad' ? : 2 3 5
Condition87%7/8
$ask_mode eq "tty" or $ask_mode eq "yad"
l!l&&r!l&&!r
115
$ENV{"PERL_ANYEVENT_MCP_ELICITATION_HELPER"} or "anyevent-mcp-form-elicitation"
l!l
50
$ask_mode eq "tty" or $ask_mode eq "yad"
l!l&&r!l&&!r
113
MC/DC100%2/2
$ask_mode eq "tty" or $ask_mode eq "yad"
$ask_mode eq "tty" $ask_mode eq "yad"
MC/DC0%0/1
$ENV{"PERL_ANYEVENT_MCP_ELICITATION_HELPER"} or "anyevent-mcp-form-elicitation"
$ENV{"PERL_ANYEVENT_MCP_ELICITATION_HELPER"}
MC/DC100%2/2
$ask_mode eq "tty" or $ask_mode eq "yad"
$ask_mode eq "tty" $ask_mode eq "yad"
Truth table100%3/3
A or B
A= $ask_mode eq "tty"B= $ask_mode eq "yad"
ABresult
1X1
011
000
Truth table50%1/2
A
A= $ENV{"PERL_ANYEVENT_MCP_ELICITATION_HELPER"}
Aresult
11
00
Truth table100%3/3
A or B
A= $ask_mode eq "tty"B= $ask_mode eq "yad"
ABresult
1X1
011
000
425 timeout => 1800,
426 )
427 : AnyEvent::MCP::Permissions::Ask->new (
428 ($ask_mode eq "tty" || $ask_mode eq "yad"
429 ? (helper => ["anyevent-mcp-askpermission", "--$ask_mode"]) : ()),
430 );
431 12 $entry->{started} = AE::now;
432 12 ▶ AE::log trace => "local prompt started (" . ($entry->{form} ? "form" : "permission") . ")";
Branch: 1 branch
BranchTrueFalseTotal
$entry->{'form'} ? : 7 5 12
433 12 ▶ $entry->{job}->ask ($entry->{prepared}, sub {
Subroutine __ANON__: called CC=7 SCAR=21.0
434 12 my ($success, $result) = @_;
435  
436 12 ▶ unless ($entry->{request}{finished}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($entry->{"request"}{"finished"}) 12 0 12
437 my $outcome = $success
438 12 ▶ ? (ref $result eq "HASH" ? $result->{decision} || $result->{action} || "answered" : "answered")
Branch: 2 branches
BranchTrueFalseTotal
$success ? : 12 0 12
ref $result eq 'HASH' ? : 12 0 12
Condition60%3/5
$result->{"decision"} or $result->{"action"} or "answered"
l!l
120
$result->{"decision"} or $result->{"action"}
l!l&&r!l&&!r
570
MC/DC0%0/2
$result->{"decision"} or $result->{"action"} or "answered"
$result->{"decision"} $result->{"action"}
Truth table66%2/3
A or B
A= $result->{"decision"}B= $result->{"action"}
ABresult
1X1
011
000
439 : "failed: $result";
440 12 AE::log trace => sprintf "local prompt %s after %.2fs", $outcome, AE::now - $entry->{started};
441 }
442 12 undef $prompt;
443 12 delete $entry->{job};
444 12 ▶ $entry->{done}->($success, $result) unless $entry->{request}{finished};
Branch: 1 branch
BranchTrueFalseTotal
unless $entry->{"request"}{"finished"} 12 0 12
445 12 next_prompt;
446 12 });
447 return
448 12 }
449 }
450  
451 12 ▶sub on_input {
Subroutine on_input: called CC=11 SCAR=30.4
452 12 my ($client, $req) = @_;
453  
454 return $req->error (-32601, "Only form elicitation is supported locally")
455 12 ▶ unless $req->{method} eq "elicitation/create";
Branch: 1 branch
BranchTrueFalseTotal
unless $req->{"method"} eq "elicitation/create" 0 12 12
456 12 my $meta = $req->{params}{_meta}{"anyevent-mcp/permission"};
457 12 ▶ unless (defined $meta) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $meta) 7 5 12
458 return $req->error (-32602, "Only form elicitation is supported locally")
459 7 ▶ if defined $req->{params}{mode} && $req->{params}{mode} ne "form";
Branch: 1 branch
BranchTrueFalseTotal
if defined $req->{"params"}{"mode"} and $req->{"params"}{"mode"} ne "form" 0 7 7
Condition33%1/3
defined $req->{"params"}{"mode"} and $req->{"params"}{"mode"} ne "form"
!ll&&!rl&&r
070
MC/DC0%0/2
defined $req->{"params"}{"mode"} and $req->{"params"}{"mode"} ne "form"
defined $req->{"params"}{"mode"} $req->{"params"}{"mode"} ne "form"
Truth table33%1/3
A and B
A= defined $req->{"params"}{"mode"}B= $req->{"params"}{"mode"} ne "form"
ABresult
0X0
100
111
460 defined $req->{params}{message} && !ref $req->{params}{message}
461 7 ▶ or return $req->error (-32602, "Form needs a message");
Branch: 1 branch
BranchTrueFalseTotal
defined $req->{"params"}{"message"} and not ref $req->{"params"}{"message"} or return $req->error(-32602, "Form needs a message") 7 0 7
Condition33%1/3
defined $req->{"params"}{"message"} and not ref $req->{"params"}{"message"}
!ll&&!rl&&r
007
MC/DC0%0/2
defined $req->{"params"}{"message"} and not ref $req->{"params"}{"message"}
defined $req->{"params"}{"message"} not ref $req->{"params"}{"message"}
Truth table33%1/3
A and not(B)
A= defined $req->{"params"}{"message"}B= not ref $req->{"params"}{"message"}
ABresult
0X0
100
111
462 ask_prompt $req, {
463 7 %{$req->{params}},
464 message => "Server: $client->{name}\n\n$req->{params}{message}",
465 7 ▶ }, sub {
Subroutine __ANON__: called CC=9 SCAR=28.9
466 7 my ($success, $response) = @_;
467  
468 7 ▶ return $req->error (-32603, $response) unless $success;
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 7 7
469 7 ▶ my $action = ref $response eq "HASH" ? $response->{action} : undef;
Branch: 1 branch
BranchTrueFalseTotal
ref $response eq 'HASH' ? : 7 0 7
470 defined $action && !ref $action && $action =~ /\A(?:accept|decline|cancel)\z/
471 7 ▶ && ($action ne "accept" || ref $response->{content} eq "HASH")
Branch: 1 branch
BranchTrueFalseTotal
defined $action and not ref $action and $action =~ /\A(?:accept|decline|cancel)\z/u and $action ne "accept" || ref $response->{"content"} eq "HASH" or return $req->error(-32603, "Invalid form helper response") 7 0 7
Condition33%4/12
defined $action and not ref $action and $action =~ /\A(?:accept|decline|cancel)\z/u and $action ne "accept" || ref $response->{"content"} eq "HASH"
!ll&&!rl&&r
007
defined $action and not ref $action and $action =~ /\A(?:accept|decline|cancel)\z/u
!ll&&!rl&&r
007
defined $action and not ref $action
!ll&&!rl&&r
007
$action ne "accept" or ref $response->{"content"} eq "HASH"
l!l&&r!l&&!r
070
MC/DC0%0/5
defined $action and not ref $action and $action =~ /\A(?:accept|decline|cancel)\z/u and $action ne "accept" || ref $response->{"content"} eq "HASH"
defined $action not ref $action $action =~ /\A(?:accept|decline|cancel)\z/u $action ne "accept" ref $response->{"content"} eq "HASH"
Truth table16%1/6
A and not(B) and C and D or E
A= defined $actionB= not ref $actionC= $action =~ /\A(?:accept|decline|cancel)\z/uD= $action ne "accept"E= ref $response->{"content"} eq "HASH"
ABCDEresult
0XXXX0
10XXX0
110XX0
111000
1111X1
111011
472 or return $req->error (-32603, "Invalid form helper response");
473 $req->reply ({
474 action => $action,
475 7 ▶ ($action eq "accept" ? (content => $response->{content}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
$action eq 'accept' ? : 7 0 7
476 });
477 7 }, 1;
478 7 return;
479 }
480 return $req->error (-32601, "Invalid permission elicitation")
481 5 ▶ unless ref $meta eq "HASH" && $meta->{version} == 1 && ref $meta->{request} eq "HASH";
Branch: 1 branch
BranchTrueFalseTotal
unless ref $meta eq "HASH" and $meta->{"version"} == 1 and ref $meta->{"request"} eq "HASH" 0 5 5
Condition33%2/6
ref $meta eq "HASH" and $meta->{"version"} == 1 and ref $meta->{"request"} eq "HASH"
!ll&&!rl&&r
005
ref $meta eq "HASH" and $meta->{"version"} == 1
!ll&&!rl&&r
005
MC/DC0%0/3
ref $meta eq "HASH" and $meta->{"version"} == 1 and ref $meta->{"request"} eq "HASH"
ref $meta eq "HASH" $meta->{"version"} == 1 ref $meta->{"request"} eq "HASH"
Truth table25%1/4
A and B and C
A= ref $meta eq "HASH"B= $meta->{"version"} == 1C= ref $meta->{"request"} eq "HASH"
ABCresult
0XX0
10X0
1100
1111
482  
483 5 my $stage = $meta->{stage};
484  
485 ask_prompt $req, {
486 5 ▶ %{$meta->{request}},
Condition100%2/2
$meta->{'selection'} || {}
l!l
23
MC/DC100%1/1
$meta->{'selection'} || {}
$meta->{'selection'}
Truth table100%2/2
A
A= $meta->{'selection'}
Aresult
11
00
487 _permission_stage => $stage,
488 _permission_selection => $meta->{selection} || {},
489 5 ▶ }, sub {
Subroutine __ANON__: called CC=11 SCAR=33.1
490 5 my ($success, $decision) = @_;
491  
492 5 ▶ return $req->error (-32603, $decision) unless $success;
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 5 5
493 5 my $valid = eval {
494 AnyEvent::MCP::Permissions::Ask::build ($meta->{request}, {
495 %$decision,
496 (ref $decision->{rule} eq "HASH"
497 0 ▶ ? (map { $_ => $decision->{rule}{$_} } qw(path)) : ()),
Branch: 1 branch
BranchTrueFalseTotal
ref $decision->{'rule'} eq 'HASH' ? : 0 5 5
498 (ref $decision->{rule} eq "HASH"
499 0 ? (map { (my $key = $_) =~ s/^match\./dim_/; $key => $decision->{rule}{$_} }
500 0 grep /^match\./, keys %{$decision->{rule}}) : ()),
501 }, $stage, $meta->{selection})
502 5 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
ref $decision->{'rule'} eq 'HASH' ? : 0 5 5
503 5 ▶ return $req->error (-32603, "Invalid permission helper decision: $@") if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 5 5
504 $req->reply ({
505 action => "accept",
506 content => {
507 decision => $valid->{decision},
508 (exists $valid->{sandbox_grants}
509 5 ▶ ? (sandbox_grants => join ",", @{$valid->{sandbox_grants}}) : ()),
Branch: 4 branches
BranchTrueFalseTotal
defined $valid->{'message'} ? : 0 5 5
exists $valid->{'lifetime'} ? : 0 5 5
ref $valid->{'rule'} eq 'HASH' && defined $valid->{'rule'}{'path'} ? : 0 5 5
ref $valid->{'rule'} eq 'HASH' ? : 0 5 5
Condition33%1/3
ref $valid->{"rule"} eq "HASH" and defined $valid->{"rule"}{"path"}
!ll&&!rl&&r
500
MC/DC0%0/2
ref $valid->{"rule"} eq "HASH" and defined $valid->{"rule"}{"path"}
ref $valid->{"rule"} eq "HASH" defined $valid->{"rule"}{"path"}
Truth table33%1/3
A and B
A= ref $valid->{"rule"} eq "HASH"B= defined $valid->{"rule"}{"path"}
ABresult
0X0
100
111
510 (defined $valid->{message} ? (message => $valid->{message}) : ()),
511 (exists $valid->{lifetime} ? (lifetime => $valid->{lifetime}) : ()),
512 (ref $valid->{rule} eq "HASH" && defined $valid->{rule}{path}
513 ? (path => $valid->{rule}{path}) : ()),
514 (ref $valid->{rule} eq "HASH"
515 0 ? (map { (my $key = $_) =~ s/^match\./dim_/; $key => $valid->{rule}{$_} }
516 0 ▶ grep /^match\./, keys %{$valid->{rule}}) : ()),
Branch: 1 branch
BranchTrueFalseTotal
exists $valid->{'sandbox_grants'} ? : 5 0 5
517 },
518 });
519 5 };
520 }
521  
522 0 ▶sub on_child_notification {
Subroutine on_child_notification: not called CC=5 SCAR=34.0
523 0 my ($prefix, $client, $method) = @_;
524  
525 0 ▶ return unless $stdio{$prefix} && $method eq "anyevent-mcp/idle-exit";
Branch: 1 branch
BranchTrueFalseTotal
unless $stdio{$prefix} and $method eq "anyevent-mcp/idle-exit" 0 0 0
Condition0%0/3
$stdio{$prefix} and $method eq "anyevent-mcp/idle-exit"
!ll&&!rl&&r
000
MC/DC0%0/2
$stdio{$prefix} and $method eq "anyevent-mcp/idle-exit"
$stdio{$prefix} $method eq "anyevent-mcp/idle-exit"
Truth table0%0/3
A and B
A= $stdio{$prefix}B= $method eq "anyevent-mcp/idle-exit"
ABresult
0X0
100
111
526 0 ▶ return if $client->{idle_shutdown_pending};
Branch: 1 branch
BranchTrueFalseTotal
if $client->{"idle_shutdown_pending"} 0 0 0
527 # the child offered to exit; only act while no broker calls need it.
528 0 ▶ return if keys %{$client->{operations}};
Branch: 1 branch
BranchTrueFalseTotal
if keys %{$$client{"operations"};} 0 0 0
529  
530 0 $client->{idle_shutdown_pending} = 1;
531 0 ▶ $client->rpc ("anyevent-mcp/shutdown", {}, sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
532 0 my ($success, $result) = @_;
533  
534 0 ▶ if ($success && $result->{accepted}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($success and $result->{'accepted'}) { } 0 0 0
Condition0%0/3
$success and $result->{"accepted"}
!ll&&!rl&&r
000
MC/DC0%0/2
$success and $result->{"accepted"}
$success $result->{"accepted"}
Truth table0%0/3
A and B
A= $successB= $result->{"accepted"}
ABresult
0X0
100
111
535 0 $client->{idle_shutdown_expected} = 1;
536 } else {
537 AE::log debug => "$prefix: idle shutdown declined: "
538 0 ▶ . ($result->{message} || "child is busy");
Condition0%0/2
$result->{'message'} || 'child is busy'
l!l
00
MC/DC0%0/1
$result->{'message'} || 'child is busy'
$result->{'message'}
Truth table0%0/2
A
A= $result->{'message'}
Aresult
11
00
539 }
540 0 delete $client->{idle_shutdown_pending};
541 0 });
542 }
543  
544 # required children must not leave spawned peers running after broker failure.
545 2 ▶sub required_failure {
Subroutine required_failure: called CC=2 SCAR=6.9
546 2 my ($prefix, $message) = @_;
547 2 AE::log error => "$prefix: required child $message";
548 2 $shutting_down = 1;
549 2 $_->close for values %broker;
550 2 exit 1;
551 }
552  
553 5 ▶sub on_child_close {
Subroutine on_child_close: called CC=9 SCAR=23.6
554 5 my ($prefix, $client, $error) = @_;
555  
556 5 ▶ return if $shutting_down;
Branch: 1 branch
BranchTrueFalseTotal
if $shutting_down 0 5 5
557 5 ▶ if (delete $client->{idle_shutdown_expected}) {
Branch: 3 branches
BranchTrueFalseTotal
if (delete $client->{'idle_shutdown_expected'}) { } 0 5 5
elsif ($required{$prefix}) { } 1 4 5
elsif ($stdio{$prefix} or $error->{'pending'}) { } 1 3 4
558 0 mcp_log "$prefix: managed idle shutdown";
559 } elsif ($required{$prefix}) {
560 required_failure $prefix, "disconnected: $error->{message}"
561 1 ▶ . ($error->{pending} ? " ($error->{pending} outstanding requests)" : "");
Branch: 1 branch
BranchTrueFalseTotal
$error->{'pending'} ? : 0 1 1
562 ▶ } elsif ($stdio{$prefix} || $error->{pending}) {
Condition66%2/3
$stdio{$prefix} or $error->{"pending"}
l!l&&r!l&&!r
013
MC/DC50%1/2
$stdio{$prefix} or $error->{"pending"}
$stdio{$prefix} $error->{"pending"}
Truth table66%2/3
A or B
A= $stdio{$prefix}B= $error->{"pending"}
ABresult
1X1
011
000
563 my $message = "$prefix: unexpected disconnect: $error->{message}"
564 1 ▶ . ($error->{pending} ? " ($error->{pending} outstanding requests)" : "");
Branch: 1 branch
BranchTrueFalseTotal
$error->{'pending'} ? : 1 0 1
565 1 ▶ AE::log warn => $message or mcp_log $message;
Branch: 1 branch
BranchTrueFalseTotal
&AE::log("warn", $message) or mcp_log($message) 0 1 1
566 } else {
567 3 mcp_log "$prefix: disconnected: $error->{message}";
568 }
569 4 delete $client->{idle_shutdown_pending};
570 }
571  
572 57 ▶sub broker_config {
Subroutine broker_config: called CC=1 SCAR=0.1
573 57 my ($prefix) = @_;
574  
575 (
576 name => $prefix,
577 client_info => { name => "mcp-multibroker", version => "$AnyEvent::MCP::VERSION" },
578 client_capabilities => {
579 elicitation => { form => {} },
580 extensions => { "anyevent-mcp/multibroker" => { version => 1 } },
581 },
582 on_request => \&on_input,
583 45 ▶ on_ready => sub { mcp_log "$prefix: connected" },
Subroutine __ANON__: called CC=1 SCAR=0.0
584 0 ▶ on_notification => sub { on_child_notification ($prefix, @_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
585 1 ▶ on_close => sub { on_child_close ($prefix, @_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
586 )
587 57 }
588  
589 7 ▶sub accept_extension {
Subroutine accept_extension: called CC=7 SCAR=20.8
590 7 my ($server, $handle, $hello) = @_;
591  
592 7 ▶ @$hello == 3 && $hello->[0] eq "mcp-connect"
Branch: 1 branch
BranchTrueFalseTotal
@$hello == 3 and $hello->[0] eq "mcp-connect" and defined $hello->[2] and not ref $hello->[2] and $hello->[2] =~ /\A[A-Za-z0-9_-]+\z/u or die "Invalid reverse MCP hello\n" 5 2 7
Condition75%9/12
@$hello == 3 and $hello->[0] eq "mcp-connect" and defined $hello->[2] and not ref $hello->[2] and $hello->[2] =~ /\A[A-Za-z0-9_-]+\z/u
!ll&&!rl&&r
205
@$hello == 3 and $hello->[0] eq "mcp-connect" and defined $hello->[2] and not ref $hello->[2]
!ll&&!rl&&r
115
@$hello == 3 and $hello->[0] eq "mcp-connect" and defined $hello->[2]
!ll&&!rl&&r
106
@$hello == 3 and $hello->[0] eq "mcp-connect"
!ll&&!rl&&r
016
MC/DC40%2/5
@$hello == 3 and $hello->[0] eq "mcp-connect" and defined $hello->[2] and not ref $hello->[2] and $hello->[2] =~ /\A[A-Za-z0-9_-]+\z/u
@$hello == 3 $hello->[0] eq "mcp-connect" defined $hello->[2] not ref $hello->[2] $hello->[2] =~ /\A[A-Za-z0-9_-]+\z/u
Truth table50%3/6
A and B and C and not(D) and E
A= @$hello == 3B= $hello->[0] eq "mcp-connect"C= defined $hello->[2]D= not ref $hello->[2]E= $hello->[2] =~ /\A[A-Za-z0-9_-]+\z/u
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
593 && defined $hello->[2] && !ref $hello->[2] && $hello->[2] =~ /\A[A-Za-z0-9_-]+\z/
594 or die "Invalid reverse MCP hello\n";
595 5 my $prefix = $hello->[2];
596 5 ▶ !exists $broker{$prefix} or die "Broker alias '$prefix' is occupied\n";
Branch: 1 branch
BranchTrueFalseTotal
exists $broker{$prefix} and die "Broker alias '${prefix}' is occupied\n" 1 4 5
597  
598 my $client = AnyEvent::MCP::Client::JSONL->new (
599 broker_config ($prefix),
600 4 ▶ on_close => sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
601 4 on_child_close ($prefix, @_);
602 4 ▶ delete $broker{$prefix} if $broker{$prefix} == $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if $broker{$prefix} == $_[0] 4 0 4
603 },
604 4 );
605 4 $broker{$prefix} = $client;
606 4 $client->attach ($handle);
607 4 ▶ $client->connect (sub {
Subroutine __ANON__: called CC=3 SCAR=17.3
608 4 my ($success, $error) = @_;
609  
610 4 ▶ unless ($success) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($success) 0 4 4
611 0 AE::log warn => "$prefix: reverse MCP initialization failed: $error->{message}";
612 0 ▶ delete $broker{$prefix} if $broker{$prefix} == $client;
Branch: 1 branch
BranchTrueFalseTotal
if $broker{$prefix} == $client 0 0 0
613 0 $client->close;
614 }
615 4 });
616 }
617  
618 40 ▶while (@ARGV) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ARGV) 56 33 89
619 56 ▶ @ARGV >= 2 or die $usage;
Branch: 1 branch
BranchTrueFalseTotal
@ARGV >= 2 or die $usage 56 0 56
620 56 my ($prefix, $url) = splice @ARGV, 0, 2;
621 56 ▶ $prefix =~ /\A[A-Za-z0-9_-]+\z/ or die "Invalid broker prefix '$prefix'\n";
Branch: 1 branch
BranchTrueFalseTotal
$prefix =~ /\A[A-Za-z0-9_-]+\z/u or die "Invalid broker prefix '${prefix}'\n" 56 0 56
622 56 ▶ exists $broker{$prefix} and die "Duplicate broker prefix '$prefix'\n";
Branch: 1 branch
BranchTrueFalseTotal
exists $broker{$prefix} and die "Duplicate broker prefix '${prefix}'\n" 0 56 56
623  
624 56 my $command;
625  
626 56 ▶ if ($url eq "---") {
Branch: 2 branches
BranchTrueFalseTotal
if ($url eq '---') { } 11 45 56
elsif ($url =~ s/\Astdio://u) { } 28 17 45
627 11 my ($end) = grep $ARGV[$_] eq "---", 0 .. $#ARGV;
628 11 ▶ defined $end or die "Missing closing --- for '$prefix'\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $end or die "Missing closing --- for '${prefix}'\n" 10 1 11
629 10 $command = [splice @ARGV, 0, $end];
630 10 shift @ARGV;
631 10 ▶ @$command && length $command->[0] or die "Empty stdio argv for '$prefix'\n";
Branch: 1 branch
BranchTrueFalseTotal
@$command and length $command->[0] or die "Empty stdio argv for '${prefix}'\n" 8 2 10
Condition100%3/3
@$command and length $command->[0]
!ll&&!rl&&r
118
MC/DC100%2/2
@$command and length $command->[0]
@$command length $command->[0]
Truth table100%3/3
A and B
A= @$commandB= length $command->[0]
ABresult
0X0
100
111
632 } elsif ($url =~ s/\Astdio://) {
633 28 ▶ length $url or die "Empty stdio command for '$prefix'\n";
Branch: 1 branch
BranchTrueFalseTotal
length $url or die "Empty stdio command for '${prefix}'\n" 28 0 28
634 # preserve shell commands, but let ordinary programs receive TERM directly.
635 28 ▶ $command = $url =~ / ^\s*(?: exec\b | source\b | \.\s ) | = | ; | \( | \{ | \|\| | && /x
Branch: 1 branch
BranchTrueFalseTotal
$url =~ / ^\s*(?: exec\b | source\b | \.\s ) | = | ; | \( | \{ | \|\| | && /ux ? : 0 28 28
636 ? $url : "exec $url";
637 }
638  
639 53 my %config = broker_config $prefix;
640 Getopt::Long::GetOptionsFromArray (\@ARGV,
641 2 ▶ "eager" => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
642 2 ▶ defined $command or die "--eager requires a stdio broker ('$prefix')\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $command or die "--eager requires a stdio broker ('${prefix}')\n" 1 1 2
643 1 $eager{$prefix} = 1;
644 },
645 2 ▶ "hidden" => sub { $hidden{$prefix} = 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
646 4 ▶ "required" => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
647 4 ▶ defined $command or die "--required requires a stdio broker ('$prefix')\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $command or die "--required requires a stdio broker ('${prefix}')\n" 3 1 4
648 3 $eager{$prefix} = $required{$prefix} = 1;
649 },
650 13 ▶ "bearer=s" => sub {
Subroutine __ANON__: called CC=4 SCAR=14.2
651 13 ▶ !defined $command && $url =~ m{\Ahttps?://} or die "Authentication options require an HTTP broker\n";
Branch: 1 branch
BranchTrueFalseTotal
not defined $command and $url =~ m[\Ahttps?://]u or die "Authentication options require an HTTP broker\n" 12 1 13
Condition66%2/3
not defined $command and $url =~ m[\Ahttps?://]u
!ll&&!rl&&r
1012
MC/DC50%1/2
not defined $command and $url =~ m[\Ahttps?://]u
not defined $command $url =~ m[\Ahttps?://]u
Truth table66%2/3
not(A) and B
A= not defined $commandB= $url =~ m[\Ahttps?://]u
ABresult
0X0
100
111
652 12 ▶ length $_[1] or die "Missing bearer token for '$prefix'\n";
Branch: 1 branch
BranchTrueFalseTotal
length $_[1] or die "Missing bearer token for '${prefix}'\n" 12 0 12
653 12 $config{bearer} = $_[1];
654 },
655 53 ▶ ) or die $usage;
Branch: 1 branch
BranchTrueFalseTotal
&Getopt::Long::GetOptionsFromArray(\@ARGV, "eager", sub { defined $command or die "--eager requires a stdio broker ('${prefix}')\n"; $eager{$prefix} = 1; } , "hidden", sub { $hidden{$prefix} = 1; } , "required", sub { defined $command or die "--required requires a stdio broker ('${prefix}')\n"; $eager{$prefix} = $required{$prefix} = 1; } , "bearer=s", sub { not defined $command and $url =~ m[\Ahttps?://]u or die "Authentication options require an HTTP broker\n"; length $_[1] or die "Missing bearer token for '${prefix}'\n"; $config{"bearer"} = $_[1]; } ) or die $usage 49 4 53
656  
657 49 ▶ if (!defined $command && $url =~ m{\Ahttps?://}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $command and $url =~ m[\Ahttps?://]u) { } 15 34 49
elsif (defined $command) { } 34 0 34
Condition66%2/3
not defined $command and $url =~ m[\Ahttps?://]u
!ll&&!rl&&r
34015
MC/DC50%1/2
not defined $command and $url =~ m[\Ahttps?://]u
not defined $command $url =~ m[\Ahttps?://]u
Truth table66%2/3
not(A) and B
A= not defined $commandB= $url =~ m[\Ahttps?://]u
ABresult
0X0
100
111
658 15 $broker{$prefix} = AnyEvent::MCP::Client::HTTP->new (%config, url => $url);
659 } elsif (defined $command) {
660 34 $broker{$prefix} = AnyEvent::MCP::Client::JSONL->new (
661 %config, command => $command,
662 env => {
663 PERL_ANYEVENT_MCP_MULTIBROKER_PROTOCOL => "stdio",
664 PERL_ANYEVENT_MCP_MULTIBROKER_ALIAS => $prefix,
665 PERL_ANYEVENT_MCP_PERMISSION_ASK => "mcp",
666 },
667 );
668 34 $stdio{$prefix} = 1;
669 } else {
670 0 die "Invalid broker URL '$url'\n";
671 }
672 }
673  
674 33 my $toolset = AnyEvent::MCP::Server::Toolset->new;
675  
676 194 ▶sub broker_alias {
Subroutine broker_alias: called CC=2 SCAR=6.9
677 194 my ($name) = @_;
678 194 ▶ return $name if exists $broker{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $broker{$name} 78 116 194
679 116 $name =~ tr/_/-/;
680 116 $name
681 }
682  
683 26 ▶sub all_tools {
Subroutine all_tools: called CC=5 SCAR=16.1
684 26 my ($req, $done, $name) = @_;
685  
686 26 ▶ my @tools = defined $name ? () : map @{$_->list}, @{$req->{server}{toolsets}};
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 9 17 26
687 26 ▶ my @prefix = defined $name ? ($name) : grep !$hidden{$_}, sort keys %broker;
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 9 17 26
688 26 my @results;
689 26 my %pending = map { $_ => 1 } @prefix;
690 26 my $remaining = @prefix;
691 26 my $finished;
692 my $timer;
693 26 ▶ my $finish = sub {
Subroutine __ANON__: called CC=5 SCAR=16.4
694 26 ▶ return if $finished++;
Branch: 1 branch
BranchTrueFalseTotal
if $finished++ 0 26 26
695 26 undef $timer;
696 26 ▶ push @tools, @{$_ || []} for @results;
Condition100%2/2
$_ || []
l!l
351
MC/DC100%1/1
$_ || []
$_
Truth table100%2/2
A
A= $_
Aresult
11
00
697 26 ▶ $done->(\@tools) unless $req->{finished};
Branch: 1 branch
BranchTrueFalseTotal
unless $req->{"finished"} 26 0 26
698 26 };
699 26 ▶ return $finish->() unless $remaining;
Branch: 1 branch
BranchTrueFalseTotal
unless $remaining 2 24 26
700  
701 0 ▶ $timer = AnyEvent->timer (after => 15, cb => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
702 0 AE::log warn => "Tool discovery timed out: " . join ", ", sort keys %pending;
703 0 $finish->();
704 24 });
705 24 for my $i (0 .. $#prefix) {
706 36 my $prefix = $prefix[$i];
707 36 my $client = $broker{$prefix};
708 36 ▶ $client->tools (sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
709 36 ▶ return if $finished;
Branch: 1 branch
BranchTrueFalseTotal
if $finished 0 36 36
710 36 my ($success, $result) = @_;
711 36 ▶ if ($success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($success) { } 35 1 36
712 35 $results[$i] = [map { +{ %$_, name => "$prefix.$_->{name}" } } @$result];
713 } else {
714 1 AE::log warn => "$prefix: $result->{message}";
715 }
716 36 delete $pending{$prefix};
717 36 ▶ $finish->() unless --$remaining;
Branch: 1 branch
BranchTrueFalseTotal
unless --$remaining 24 12 36
718 36 });
719 }
720 }
721  
722 220 ▶sub call_tool {
Subroutine call_tool: called CC=19 SCAR=29.8
723 220 my ($req, $name, $args) = @_;
724  
725 220 ▶ return $req->error ("Invalid tool call") unless defined $name && !ref $name && ref $args eq "HASH";
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name and not ref $name and ref $args eq "HASH" 0 220 220
Condition33%2/6
defined $name and not ref $name and ref $args eq "HASH"
!ll&&!rl&&r
00220
defined $name and not ref $name
!ll&&!rl&&r
00220
MC/DC0%0/3
defined $name and not ref $name and ref $args eq "HASH"
defined $name not ref $name ref $args eq "HASH"
Truth table25%1/4
A and not(B) and C
A= defined $nameB= not ref $nameC= ref $args eq "HASH"
ABCresult
0XX0
10X0
1100
1111
726 220 ▶ if (my ($local) = grep exists $_->{tool}{$name}, @{$req->{server}{toolsets}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($local) = grep(exists $_->{"tool"}{$name}, @{$$req{"server"}{"toolsets"};})) 147 73 220
727 147 local $req->{tool} = $name;
728 147 local $req->{args} = $args;
729 147 return $local->call ($req)
730 }
731  
732 73 my ($prefix, $tool) = $name =~ /\A([^.]+)\.(.+)\z/;
733 73 ▶ $prefix = broker_alias $prefix if defined $prefix;
Branch: 1 branch
BranchTrueFalseTotal
if defined $prefix 73 0 73
734 73 my $client = $broker{$prefix};
735 73 ▶ return $req->error ("Unknown tool '$name'") unless $client;
Branch: 1 branch
BranchTrueFalseTotal
unless $client 1 72 73
736  
737 72 AE::log trace => "multibroker $name";
738 72 my %params = (%{$req->{params}}, name => $tool, arguments => $args);
739 72 ▶ $params{_meta} = { %{$params{_meta} || {}} };
Condition100%2/2
$params{'_meta'} || {}
l!l
693
MC/DC100%1/1
$params{'_meta'} || {}
$params{'_meta'}
Truth table100%2/2
A
A= $params{'_meta'}
Aresult
11
00
740 72 $params{_meta}{"anyevent-mcp/user"} = $req->{user};
741 72 my $caps = $params{_meta}{"io.modelcontextprotocol/clientCapabilities"};
742 72 ▶ $caps = ref $caps eq "HASH" ? { %$caps } : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $caps eq 'HASH' ? : 69 3 72
743 my $native_forms = $req->{protocol_version} ge "2026"
744 && ref $caps->{elicitation} eq "HASH"
745 72 ▶ && (!keys %{$caps->{elicitation}} || ref $caps->{elicitation}{form} eq "HASH");
Condition77%7/9
$req->{'protocol_version'} ge '2026' && ref $caps->{'elicitation'} eq 'HASH' && (!keys(%{$$caps{'elicitation'};}) || ref $caps->{'elicitation'}{'form'} eq 'HASH')
!ll&&!rl&&r
46026
$req->{"protocol_version"} ge 2026 and ref $caps->{"elicitation"} eq "HASH"
!ll&&!rl&&r
34326
not keys %{$$caps{"elicitation"};} or ref $caps->{"elicitation"}{"form"} eq "HASH"
l!l&&r!l&&!r
6200
MC/DC50%2/4
$req->{'protocol_version'} ge '2026' && ref $caps->{'elicitation'} eq 'HASH' && (!keys(%{$$caps{'elicitation'};}) || ref $caps->{'elicitation'}{'form'} eq 'HASH')
$req->{"protocol_version"} ge 2026 ref $caps->{"elicitation"} eq "HASH" not keys %{$$caps{"elicitation"};} ref $caps->{"elicitation"}{"form"} eq "HASH"
Truth table80%4/5
A and B && not(C) or D
A= $req->{"protocol_version"} ge 2026B= ref $caps->{"elicitation"} eq "HASH"C= not keys %{$$caps{"elicitation"};}D= ref $caps->{"elicitation"}{"form"} eq "HASH"
ABCDresult
0XXX0
10XX0
11000
111X1
11011
746 72 ▶ my $local_forms = $ask_mode =~ /\A(?:helper|tty|yad)\z/ || $ask_mode eq "auto" && !$native_forms;
Condition83%5/6
$ask_mode =~ /\A(?:helper|tty|yad)\z/u || $ask_mode eq 'auto' && !$native_forms
l!l&&r!l&&!r
24345
$ask_mode eq "auto" and not $native_forms
!ll&&!rl&&r
4503
MC/DC66%2/3
$ask_mode =~ /\A(?:helper|tty|yad)\z/u || $ask_mode eq 'auto' && !$native_forms
$ask_mode =~ /\A(?:helper|tty|yad)\z/u $ask_mode eq "auto" not $native_forms
Truth table75%3/4
A || B and not(C)
A= $ask_mode =~ /\A(?:helper|tty|yad)\z/uB= $ask_mode eq "auto"C= not $native_forms
ABCresult
1XX1
0111
00X0
0100
747 72 ▶ if ($local_forms) {
Branch: 2 branches
BranchTrueFalseTotal
if ($local_forms) { } 27 45 72
elsif ($req->{'protocol_version'} lt '2026') { } 2 43 45
748 27 $caps->{elicitation} = { form => {} };
749 } elsif ($req->{protocol_version} lt "2026") {
750 2 delete $caps->{elicitation};
751 }
752 $caps->{extensions} = {
753 72 ▶ %{ref $caps->{extensions} eq "HASH" ? $caps->{extensions} : {}},
Branch: 1 branch
BranchTrueFalseTotal
ref $caps->{'extensions'} eq 'HASH' ? : 0 72 72
754 "anyevent-mcp/multibroker" => { version => 1 },
755 };
756 72 $params{_meta}{"io.modelcontextprotocol/clientCapabilities"} = $caps;
757 72 my $id;
758 72 my $old_cancel = $req->{on_cancel};
759 2 ▶ $req->{on_cancel} = sub {
Subroutine __ANON__: called CC=3 SCAR=12.0
760 2 ▶ $client->cancel ($id, $_[1]) if defined $id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $id 2 0 2
761 2 ▶ $old_cancel->(@_) if $old_cancel;
Branch: 1 branch
BranchTrueFalseTotal
if $old_cancel 0 2 2
762 72 };
763 72 ▶ my $done = sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
764 72 my ($success, $result) = @_;
765  
766 72 ▶ return if $req->{finished};
Branch: 1 branch
BranchTrueFalseTotal
if $req->{"finished"} 2 70 72
767 70 ▶ return $req->error ($result->{message}) unless $success;
Branch: 1 branch
BranchTrueFalseTotal
unless $success 1 69 70
768 69 $req->reply ($result);
769 72 };
770 72 ▶ if ($local_forms || $req->{protocol_version} lt "2026") {
Branch: 1 branch
BranchTrueFalseTotal
if ($local_forms or $req->{'protocol_version'} lt '2026') { } 29 43 72
Condition100%3/3
$local_forms or $req->{"protocol_version"} lt 2026
l!l&&r!l&&!r
27243
MC/DC100%2/2
$local_forms or $req->{"protocol_version"} lt 2026
$local_forms $req->{"protocol_version"} lt 2026
Truth table100%3/3
A or B
A= $local_formsB= $req->{"protocol_version"} lt 2026
ABresult
1X1
011
000
771 29 $id = $client->call ($tool, $args, $done, %params);
772 } else {
773 43 $id = $client->rpc ("tools/call", \%params, $done);
774 }
775 }
776  
777 $toolset->tool (discover_brokers =>
778 "Get instructions from all brokers by name: string; null if reachable but none; {error: MESSAGE} if unreachable.",
779 { type => "object", properties => {} },
780 8 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.1
781 8 my ($req) = @_;
782  
783 8 my @prefix = sort keys %broker;
784 8 my %instructions;
785 8 my %pending = map { $_ => 1 } @prefix;
786 8 my $remaining = @prefix;
787 8 my $finished;
788 my $timer;
789 8 ▶ my $finish = sub {
Subroutine __ANON__: called CC=4 SCAR=14.5
790 8 ▶ return if $finished++;
Branch: 1 branch
BranchTrueFalseTotal
if $finished++ 0 8 8
791 8 undef $timer;
792 8 $instructions{$_} = { error => "Discovery timed out" } for keys %pending;
793 8 ▶ $req->result (\%instructions) unless $req->{finished};
Branch: 1 branch
BranchTrueFalseTotal
unless $req->{"finished"} 8 0 8
794 8 };
795 8 ▶ return $finish->() unless $remaining;
Branch: 1 branch
BranchTrueFalseTotal
unless $remaining 0 8 8
796  
797 0 ▶ $timer = AnyEvent->timer (after => 15, cb => sub { $finish->() });
Subroutine __ANON__: not called CC=1 SCAR=1.2
798 8 for my $prefix (@prefix) {
799 18 my $client = $broker{$prefix};
800 18 ▶ $client->connect (sub {
Subroutine __ANON__: called CC=6 SCAR=18.0
801 18 ▶ return if $finished;
Branch: 1 branch
BranchTrueFalseTotal
if $finished 0 18 18
802 18 my ($success, $result) = @_;
803 18 ▶ if ($success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($success) { } 17 1 18
804 $instructions{$prefix} = $hidden{$prefix}
805 ? "Hidden tools; use list-tools broker=$prefix.\n" . ($client->{instructions} // "")
806 17 ▶ : $client->{instructions};
Branch: 1 branch
BranchTrueFalseTotal
$hidden{$prefix} ? : 2 15 17
Condition50%1/2
$client->{"instructions"} // ""
l!l
20
MC/DC0%0/1
$client->{"instructions"} // ""
$client->{"instructions"}
Truth table50%1/2
A
A= $client->{"instructions"}
Aresult
11
00
807 } else {
808 1 AE::log warn => "$prefix: $result->{message}";
809 1 $instructions{$prefix} = { error => $result->{message} };
810 }
811 18 delete $pending{$prefix};
812 18 ▶ $finish->() unless --$remaining;
Branch: 1 branch
BranchTrueFalseTotal
unless --$remaining 8 10 18
813 18 });
814 }
815 },
816 33 );
817 $toolset->tool (list_tools =>
818 "Refresh tools; broker selects one downstream, including hidden ones. Omit for local + visible brokers.",
819 {
820 type => "object",
821 properties => {
822 broker => { type => "string", description => "Downstream broker, including hidden; underscores may replace hyphens. Omit for visible brokers + local tools." },
823 },
824 additionalProperties => JSON::XS::false,
825 },
826 129 ▶ sub {
Subroutine __ANON__: called CC=6 SCAR=17.9
827 129 my ($req, $args) = @_;
828  
829 129 for (keys %$args) {
830 123 ▶ $_ eq "broker" or return $req->error ("Unknown list-tools argument '$_'");
Branch: 1 branch
BranchTrueFalseTotal
$_ eq "broker" or return $req->error("Unknown list-tools argument '${_}'") 122 1 123
831 }
832 128 my $name = $args->{broker};
833 128 ▶ $name = broker_alias $name if defined $name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name 121 7 128
834 128 ▶ return $req->error ("Unknown broker '$name'") if defined $name && !exists $broker{$name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and not exists $broker{$name} 112 16 128
Condition100%3/3
defined $name and not exists $broker{$name}
!ll&&!rl&&r
79112
MC/DC100%2/2
defined $name and not exists $broker{$name}
defined $name not exists $broker{$name}
Truth table100%3/3
A and not(B)
A= defined $nameB= not exists $broker{$name}
ABresult
0X0
100
111
835  
836 16 ▶ all_tools $req, sub { $req->result ({ tools => $_[0] }) }, $name;
Subroutine __ANON__: called CC=1 SCAR=0.0
837 },
838 33 );
839 $toolset->tool (call_tool =>
840 "Call tool by prefixed name from list-tools. Use when not directly exposed; call loaded tools directly.",
841 {
842 type => "object",
843 required => ["name"],
844 properties => {
845 name => { type => "string" },
846 arguments => { type => "object" },
847 },
848 },
849 8 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
850 8 my ($req, $args) = @_;
851  
852 8 ▶ return $req->error ("call-tool cannot call itself") if $args->{name} eq "call-tool";
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"name"} eq "call-tool" 1 7 8
853 7 ▶ call_tool $req, $args->{name}, $args->{arguments} || {};
Condition100%2/2
$args->{'arguments'} || {}
l!l
34
MC/DC100%1/1
$args->{'arguments'} || {}
$args->{'arguments'}
Truth table100%2/2
A
A= $args->{'arguments'}
Aresult
11
00
854 },
855 33 );
856  
857 257 ▶sub log_request {
Subroutine log_request: called CC=3 SCAR=11.0
858 257 my ($server, $req) = @_;
859  
860 # keep proxied calls at trace to avoid duplicating downstream activity logs.
861 257 ▶ return if $req->{method} eq "tools/call" && $req->{tool} =~ /\A[^.]+\./;
Branch: 1 branch
BranchTrueFalseTotal
if $req->{"method"} eq "tools/call" and $req->{"tool"} =~ /\A[^.]+\./u 66 191 257
Condition100%3/3
$req->{"method"} eq "tools/call" and $req->{"tool"} =~ /\A[^.]+\./u
!ll&&!rl&&r
4414766
MC/DC100%2/2
$req->{"method"} eq "tools/call" and $req->{"tool"} =~ /\A[^.]+\./u
$req->{"method"} eq "tools/call" $req->{"tool"} =~ /\A[^.]+\./u
Truth table100%3/3
A and B
A= $req->{"method"} eq "tools/call"B= $req->{"tool"} =~ /\A[^.]+\./u
ABresult
0X0
100
111
862  
863 191 mcp_log_request $server, $req;
864 }
865  
866 mcp_config
867 server_name => "mcp-multibroker",
868 server_version => $AnyEvent::MCP::VERSION,
869 on_request => \&log_request,
870 0 ▶ on_error => sub { AE::log error => "MCP dispatch $_[1]{method}: $_[2]" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
871 33 short_instructions => "MCP tool router. discover-brokers lists servers including hidden ones; list-tools broker=NAME finds their tools.",
872 instructions => <<'EOF';
873 Proxy MCP servers as PREFIX.TOOL. discover-brokers lists servers, including hidden ones; list-tools broker=NAME retrieves a server's tools. list-tools without a broker returns visible tools; call-tool invokes by prefixed name, even when hidden. Tools may change.
874 EOF
875  
876 # start selected stdio children now, before the upstream event loop starts.
877 # their asynchronous initialization completes once that loop is running.
878 # optional children can still be reconnected by a later MCP request.
879 33 mcp_tool_help ($server_options->{tool_help}, $toolset);
880 32 delete $server_options->{tool_help};
881 32 for my $prefix (sort keys %eager) {
882 4 ▶ $broker{$prefix}->connect (sub {
Subroutine __ANON__: called CC=4 SCAR=14.1
883 4 my ($success, $error) = @_;
884  
885 4 ▶ if (!$success && $required{$prefix}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $success and $required{$prefix}) 1 3 4
Condition66%2/3
not $success and $required{$prefix}
!ll&&!rl&&r
301
MC/DC50%1/2
not $success and $required{$prefix}
not $success $required{$prefix}
Truth table66%2/3
not(A) and B
A= not $successB= $required{$prefix}
ABresult
0X0
100
111
886 1 required_failure $prefix, "initialization failed: $error->{message}";
887 }
888 3 ▶ AE::log warn => "$prefix: eager startup failed: $error->{message}"
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 3 3
889 unless $success;
890 4 });
891 }
892  
893 mcp_start
894 %$server_options,
895 ($listen ? (listen => 1) : ()),
896 toolsets => [$toolset],
897 on_extension => \&accept_extension,
898 10 ▶ on_tools_list => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
899 10 my ($server, $req) = @_;
900  
901 10 AE::log debug => "multibroker list-tools";
902 10 ▶ all_tools $req, sub { $req->reply ({ tools => $_[0] }) };
Subroutine __ANON__: called CC=1 SCAR=0.0
903 },
904 213 ▶ on_tools_call => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
905 213 my ($server, $req, $args) = @_;
906  
907 213 call_tool $req, $req->{tool}, $args;
908 32 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$listen ? : 1 31 32
909  
910 30 $shutting_down = 1;
911 30 $_->close for values %broker;
912  
« blib/lib/AnyEvent/MCP/File.pm ↑ Summary blib/lib/AnyEvent/MCP/Workdirs.pm »