blib/lib/AnyEvent/MCP/Server.pm

filter: Statementstmt 98.3% 182 / 185 Branchbran 90.0% 108 / 120 Conditioncond 71.5% 98 / 137 MC/DCmcdc 52.2% 35 / 67 Subroutinesub 94.7% 18 / 19 Podpod 100% 4 / 4 totaltotal 83.6% 445 / 532 CC 108 SCAR 40.9
CC
108
Cov
88%
rpc
103.3
__ANON__
12.0
_dispatch
11.1
CRAP 59.9
« blib/lib/AnyEvent/MCP/Server/Permissions.pm ↑ Summary blib/lib/AnyEvent/MCP.pm »
1 =head1 NAME
2  
3 AnyEvent::MCP::Server - MCP request dispatch and JSON-RPC framing
4  
5 =head1 DESCRIPTION
6  
7 An MCP server needs to understand requests, but it does not necessarily need
8 to own a listening socket. This class handles the protocol: it accepts decoded
9 JSON-RPC objects (or UTF-8 JSON), dispatches requests and delivers responses
10 through callbacks. Its subclasses L<AnyEvent::MCP::Server::JSONL> and
11 L<AnyEvent::MCP::Server::HTTP> handle the actual connections. If you are
12 writing a standalone server, L<AnyEvent::MCP::Server::Simple> is usually
13 the easier starting point.
14  
15 The server implements discovery, initialization, ping and tool listing/calls.
16 The 2025 compatibility path supports ordinary requests and responses, but
17 not server-initiated requests. Permission asking supports modern input
18 challenges as well as local helpers. SSE, subscriptions and schema validation
19 are not implemented yet.
20  
21 The usual object-level assembly is a
22 L<AnyEvent::MCP::Server::Toolset> holding tool callbacks, a Server
23 handling protocol messages, and a transport accepting connections.
24 Use L<AnyEvent::MCP::Server::HTTP/FIRST USE> for an executable HTTP
25 assembly or L<AnyEvent::MCP::Server::JSONL/EXAMPLE> for stdio.
26 The corresponding client entry point is L<AnyEvent::MCP::Client>.
27  
28 Only embedders that already own their transport need C<rpc> or
29 C<json_rpc> directly; these methods do not create connections or run
30 the event loop.
31  
32 =head1 METHODS
33  
34 =over
35  
36 =item $server = AnyEvent::MCP::Server->new (%config)
37  
38 Creates the protocol object without opening a listener or starting an
39 event loop. Options are:
40  
41 =over
42  
43 =item toolsets => [$toolset...]
44  
45 L<AnyEvent::MCP::Server::Toolset> objects searched in order, defaulting to
46 an empty array. The first Toolset containing a called tool handles it.
47  
48 =item server_info => { name => $name, version => $version }
49  
50 Advertised server identity, defaulting to C<AnyEvent::MCP> and this
51 distribution's version.
52  
53 =item instructions => $text
54  
55 Optional human-readable guidance. Surrounding whitespace and common
56 indentation are stripped. Empty instructions are omitted from discovery
57 and initialization results.
58  
59 =item short_instructions => $text
60  
61 Optional condensed guidance for deciding when to discover this server's tools.
62 Used instead of C<instructions> in discovery when C<auto_instructions> is true.
63 Without either short or custom instructions, the full instructions remain
64 advertised.
65  
66 =item custom_instructions => $text
67  
68 Instance-specific purpose, prepended to the advertised instructions.
69  
70 =item auto_instructions => $boolean
71  
72 When true, expose full C<instructions>, prefixed by any custom instance
73 purpose, in a C<meta-instructions> tool's description and call result.
74 Advertise C<short_instructions> instead, when provided, preceded by any
75 custom purpose. Append a pointer to the generated tool's description when
76 short or custom instructions exist. With neither, advertise the original
77 full instructions without a redundant pointer. Defaults to false;
78 a conflicting tool name is an error.
79  
80 =item capabilities => { %capabilities }
81  
82 Advertised server capabilities, defaulting to C<{ tools =E<gt> {} }>.
83 Declaring a capability does not implement it.
84  
85 =item versions => [$version...]
86  
87 Supported revisions in preference order. Defaults to C<2026-07-28>,
88 C<2025-11-25>, C<2025-06-18> and C<2025-03-26>. The 2026 protocol uses
89 discovery and per-request metadata; the 2025 protocol uses initialization.
90  
91 =item permissions => $permissions
92  
93 L<AnyEvent::MCP::Server::Permissions> object used by
94 C<< $req->require_permission >>. The server handles permission-needed
95 exceptions. The permission object's C<ask> setting chooses between modern
96 input challenges and local prompts; local asking retries the handler
97 internally. Checks must precede side effects.
98  
99 =back
100  
101 Event callbacks are also constructor options; see L</EVENTS>.
102  
103 =item $req = $server->rpc ($message, $reply->($message), %context)
104  
105 Accepts the decoded JSON-RPC hash reference C<$message>. C<$reply> receives
106 the decoded response, or undef when a notification is accepted or a request
107 is cancelled. Undef completes transport bookkeeping without a JSON-RPC
108 response. Returns the Request object for a request, or undef for
109 notifications and rejected messages.
110 C<$reply> can be called before this method returns, or later.
111  
112 C<peer> in C<%context> is a hash reference shared by messages on one connection.
113 It holds legacy initialization state and weak references to outstanding
114 requests for cancellation. Embedders supply a different peer for each
115 independent connection. Modern request metadata takes precedence over legacy
116 peer state.
117  
118 C<protocol_version> supplies the legacy HTTP protocol version.
119 C<on_notify> is an optional C<$callback->($req, $message)> receiving decoded
120 outgoing notifications. Without it, notifications are dropped.
121  
122 =item $req = $server->json_rpc ($json, $reply->($json), %context)
123  
124 Like C<rpc>, but C<$json> and the response are UTF-8 encoded JSON strings.
125 The notification callback still receives decoded objects. Parse errors are
126 returned as JSON-RPC errors.
127  
128 =item $server->dispatch ($req)
129  
130 Dispatches an already constructed Request. Normally called by C<rpc>.
131 Subclasses can override this method while retaining JSON-RPC handling.
132  
133 =back
134  
135 =head1 EVENTS
136  
137 =over
138  
139 =item on_request => $callback->($server, $req)
140  
141 Called before each dispatch attempt, including permission retries. This
142 synchronous hook can inspect the request or refresh application state.
143 It does not replace dispatch; avoid side effects that must happen only once.
144  
145 =item on_tools_list => $callback->($server, $req)
146  
147 Replaces the default Toolset listing. C<$callback> completes C<$req>.
148  
149 =item on_tools_call => $callback->($server, $req, $args)
150  
151 Replaces the default Toolset lookup and invocation. C<$args> is also available
152 as C<< $req->{args} >>. C<$callback> completes C<$req>.
153  
154 =item on_error => $callback->($server, $req, $error)
155  
156 Reports an exception caught during synchronous dispatch. A tool exception
157 becomes a text tool-error result; other exceptions become internal JSON-RPC
158 errors. Exceptions after a reply are propagated, as are exceptions from
159 asynchronous application callbacks.
160  
161 =back
162  
163 =cut
164  
165 package AnyEvent::MCP::Server;
166  
167 93 ▶use common::sense;
Subroutine BEGIN: called CC=1 SCAR=0.0
168 93 ▶use AnyEvent::MCP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
169 93 ▶use AnyEvent::MCP::Server::Request ();
Subroutine BEGIN: called CC=1 SCAR=0.0
170 93 ▶use AnyEvent ();
Subroutine BEGIN: called CC=1 SCAR=0.0
171 93 ▶use JSON::XS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
172 93 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
173  
174 93 our @ISA = qw(AnyEvent::MCP::Base);
175  
176 190 ▶sub new {
Subroutine new: called CC=10 SCAR=23.0
Pod documented
177 190 my $class = shift;
178  
179 190 my $self = $class->SUPER::new (
180 toolsets => [],
181 server_info => { name => "AnyEvent::MCP", version => "$AnyEvent::MCP::VERSION" },
182 capabilities => { tools => {} },
183 versions => [qw(2026-07-28 2025-11-25 2025-06-18 2025-03-26)],
184 @_,
185 );
186  
187 $self->{instructions} = AnyEvent::MCP::_clean_text $self->{instructions}
188 190 ▶ if exists $self->{instructions};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"instructions"} 66 124 190
189  
190 190 my $instructions = $self->{instructions};
191 my $custom = exists $self->{custom_instructions}
192 190 ▶ ? AnyEvent::MCP::_clean_text $self->{custom_instructions} : "";
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'custom_instructions'} ? : 7 183 190
193  
194 190 ▶ if ($self->{auto_instructions} && length $instructions) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'auto_instructions'} and length $instructions) { } 59 131 190
elsif (length $custom) { } 2 129 131
Condition100%3/3
$self->{"auto_instructions"} and length $instructions
!ll&&!rl&&r
943759
MC/DC100%2/2
$self->{"auto_instructions"} and length $instructions
$self->{"auto_instructions"} length $instructions
Truth table100%3/3
A and B
A= $self->{"auto_instructions"}B= length $instructions
ABresult
0X0
100
111
195 59 require AnyEvent::MCP::Server::Toolset;
196  
197 59 my $name = "meta-instructions";
198 59 ▶ !grep { exists $_->{tool}{$name} } @{$self->{toolsets}}
Branch: 1 branch
BranchTrueFalseTotal
grep {exists $_->{"tool"}{$name};} @{$$self{"toolsets"};} and die "duplicate MCP tool '${name}'\n" 1 58 59
199 or die "duplicate MCP tool '$name'\n";
200  
201 58 my $full = join "\n\n", grep length, $custom, $instructions;
202 58 my $toolset = AnyEvent::MCP::Server::Toolset->new;
203 $toolset->tool (meta_instructions =>
204 "Server instructions. Call for full text if truncated.\n\n$full",
205 { type => "object", properties => {} },
206 4 ▶ sub { $_[0]->reply ({ content => [{ type => "text", text => $full }] }) },
Subroutine __ANON__: called CC=1 SCAR=0.0
207 58 );
208 58 $self->{toolsets} = [@{$self->{toolsets}}, $toolset];
209  
210 my $short = exists $self->{short_instructions}
211 58 ▶ ? AnyEvent::MCP::_clean_text $self->{short_instructions} : "";
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'short_instructions'} ? : 41 17 58
212 58 ▶ $self->{instructions} = length $custom || length $short
Branch: 1 branch
BranchTrueFalseTotal
length $custom || length $short ? : 42 16 58
Condition100%3/3
length $custom or length $short
l!l&&r!l&&!r
53716
MC/DC100%2/2
length $custom or length $short
length $custom length $short
Truth table100%3/3
A or B
A= length $customB= length $short
ABresult
1X1
011
000
213 ? (join "\n\n", grep length, $custom, $short, "Full instructions: meta-instructions tool description.")
214 : $instructions;
215  
216 } elsif (length $custom) {
217 2 $self->{instructions} = join "\n\n", grep length, $custom, $instructions;
218 }
219  
220 $self
221 189 }
222  
223 23 ▶sub _rpc_error {
Subroutine _rpc_error: called CC=2 SCAR=6.9
224 23 my ($self, $reply, $id, $code, $message, $data) = @_;
225  
226 23 my $error = { code => $code, message => $message };
227 23 ▶ $error->{data} = $data if defined $data;
Branch: 1 branch
BranchTrueFalseTotal
if defined $data 5 18 23
228  
229 23 $reply->({ jsonrpc => "2.0", id => $id, error => $error });
230 undef
231 23 }
232  
233 424 ▶sub json_rpc {
Subroutine json_rpc: called CC=2 SCAR=6.9
Pod documented
234 424 my ($self, $json, $reply, @context) = @_;
235  
236 424 ▶ my $send = sub { $reply->(defined $_[0] ? JSON::XS::encode_json $_[0] : undef) };
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 408 14 422
237 424 my $message = eval { JSON::XS::decode_json $json };
238  
239 424 ▶ return $self->_rpc_error ($send, undef, -32700, "Parse error")
Branch: 1 branch
BranchTrueFalseTotal
if $@ 1 423 424
240 if $@;
241  
242 423 $self->rpc ($message, $send, @context)
243 }
244  
245 718 ▶sub rpc {
Subroutine rpc: called CC=69 SCAR=46.4
Pod documented
246 718 my ($self, $message, $reply, %context) = @_;
247  
248 return $self->_rpc_error ($reply, undef, -32600, "Invalid request")
249 unless ref $message eq "HASH"
250 && $message->{jsonrpc} eq "2.0"
251 && defined $message->{method} && !ref $message->{method}
252 718 ▶ && (!exists $message->{id} || defined $message->{id} && !ref $message->{id});
Branch: 1 branch
BranchTrueFalseTotal
unless ref $message eq "HASH" and $message->{"jsonrpc"} eq "2.0" and defined $message->{"method"} and not ref $message->{"method"} and !exists $message->{"id"} || defined $message->{"id"} && !ref($message->{"id"}) 1 717 718
Condition61%11/18
ref $message eq "HASH" and $message->{"jsonrpc"} eq "2.0" and defined $message->{"method"} and not ref $message->{"method"} and !exists $message->{"id"} || defined $message->{"id"} && !ref($message->{"id"})
!ll&&!rl&&r
10717
ref $message eq "HASH" and $message->{"jsonrpc"} eq "2.0" and defined $message->{"method"} and not ref $message->{"method"}
!ll&&!rl&&r
10717
ref $message eq "HASH" and $message->{"jsonrpc"} eq "2.0" and defined $message->{"method"}
!ll&&!rl&&r
10717
ref $message eq "HASH" and $message->{"jsonrpc"} eq "2.0"
!ll&&!rl&&r
10717
not exists $message->{"id"} or defined $message->{"id"} and not ref $message->{"id"}
l!l&&r!l&&!r
137040
defined $message->{"id"} and not ref $message->{"id"}
!ll&&!rl&&r
00704
MC/DC14%1/7
ref $message eq "HASH" and $message->{"jsonrpc"} eq "2.0" and defined $message->{"method"} and not ref $message->{"method"} and !exists $message->{"id"} || defined $message->{"id"} && !ref($message->{"id"})
ref $message eq "HASH" $message->{"jsonrpc"} eq "2.0" defined $message->{"method"} not ref $message->{"method"} not exists $message->{"id"} defined $message->{"id"} not ref $message->{"id"}
Truth table37%3/8
A and B and C and not(D) and not(E) or F and not(G)
A= ref $message eq "HASH"B= $message->{"jsonrpc"} eq "2.0"C= defined $message->{"method"}D= not ref $message->{"method"}E= not exists $message->{"id"}F= defined $message->{"id"}G= not ref $message->{"id"}
ABCDEFGresult
0XXXXXX0
10XXXXX0
110XXXX0
1110XXX0
111100X0
11110100
11111XX1
11110111
253  
254 717 my $id = $message->{id};
255 717 my $key = $id; # Hash lookups must not stringify the wire ID.
256 717 my $method = $message->{method};
257 717 ▶ my $params = exists $message->{params} ? $message->{params} : {};
Branch: 1 branch
BranchTrueFalseTotal
exists $message->{'params'} ? : 702 15 717
258 717 ▶ my $peer = $context{peer} || {};
Condition100%2/2
$context{'peer'} || {}
l!l
62691
MC/DC100%1/1
$context{'peer'} || {}
$context{'peer'}
Truth table100%2/2
A
A= $context{'peer'}
Aresult
11
00
259  
260 717 ▶ unless (exists $message->{id}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $message->{"id"}) 13 704 717
261 13 ▶ if ($method eq "notifications/cancelled" && ref $params eq "HASH" && defined $params->{requestId}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method eq "notifications/cancelled" and ref $params eq "HASH" and defined $params->{"requestId"}) 5 8 13
Condition66%4/6
$method eq "notifications/cancelled" and ref $params eq "HASH" and defined $params->{"requestId"}
!ll&&!rl&&r
805
$method eq "notifications/cancelled" and ref $params eq "HASH"
!ll&&!rl&&r
805
MC/DC33%1/3
$method eq "notifications/cancelled" and ref $params eq "HASH" and defined $params->{"requestId"}
$method eq "notifications/cancelled" ref $params eq "HASH" defined $params->{"requestId"}
Truth table50%2/4
A and B and C
A= $method eq "notifications/cancelled"B= ref $params eq "HASH"C= defined $params->{"requestId"}
ABCresult
0XX0
10X0
1100
1111
262 5 my $req = delete $peer->{requests}{$params->{requestId}};
263 5 ▶ $req->cancel ($params->{reason}) if $req;
Branch: 1 branch
BranchTrueFalseTotal
if $req 5 0 5
264 }
265  
266 13 $reply->(undef);
267 return
268 13 }
269  
270 return $self->_rpc_error ($reply, $id, -32602, "Invalid params")
271 unless ref $params eq "HASH"
272 704 ▶ && (!exists $params->{_meta} || ref $params->{_meta} eq "HASH");
Branch: 1 branch
BranchTrueFalseTotal
unless ref $params eq "HASH" and !exists $params->{"_meta"} || ref $params->{"_meta"} eq "HASH" 0 704 704
Condition50%3/6
ref $params eq "HASH" and !exists $params->{"_meta"} || ref $params->{"_meta"} eq "HASH"
!ll&&!rl&&r
00704
not exists $params->{"_meta"} or ref $params->{"_meta"} eq "HASH"
l!l&&r!l&&!r
1155890
MC/DC0%0/3
ref $params eq "HASH" and !exists $params->{"_meta"} || ref $params->{"_meta"} eq "HASH"
ref $params eq "HASH" not exists $params->{"_meta"} ref $params->{"_meta"} eq "HASH"
Truth table50%2/4
A and not(B) or C
A= ref $params eq "HASH"B= not exists $params->{"_meta"}C= ref $params->{"_meta"} eq "HASH"
ABCresult
0XX0
1000
11X1
1011
273  
274 704 ▶ my $meta = $params->{_meta} || {};
Condition100%2/2
$params->{'_meta'} || {}
l!l
589115
MC/DC100%1/1
$params->{'_meta'} || {}
$params->{'_meta'}
Truth table100%2/2
A
A= $params->{'_meta'}
Aresult
11
00
275 my $version = $meta->{"io.modelcontextprotocol/protocolVersion"}
276 704 ▶ || $context{protocol_version} || $peer->{protocol_version};
Condition100%6/6
$meta->{'io.modelcontextprotocol/protocolVersion'} || $context{'protocol_version'} || $peer->{'protocol_version'}
l!l&&r!l&&!r
6326210
$meta->{"io.modelcontextprotocol/protocolVersion"} or $context{"protocol_version"}
l!l&&r!l&&!r
5864672
MC/DC100%3/3
$meta->{'io.modelcontextprotocol/protocolVersion'} || $context{'protocol_version'} || $peer->{'protocol_version'}
$meta->{"io.modelcontextprotocol/protocolVersion"} $context{"protocol_version"} $peer->{'protocol_version'}
Truth table100%4/4
A or B || C
A= $meta->{"io.modelcontextprotocol/protocolVersion"}B= $context{"protocol_version"}C= $peer->{'protocol_version'}
ABCresult
1XX1
01X1
0011
0000
277  
278 $peer->{client_info} = $meta->{"io.modelcontextprotocol/clientInfo"}
279 704 ▶ if $version && $version ge "2026" && ref $meta->{"io.modelcontextprotocol/clientInfo"} eq "HASH";
Branch: 1 branch
BranchTrueFalseTotal
if $version and $version ge 2026 and ref $meta->{"io.modelcontextprotocol/clientInfo"} eq "HASH" 468 236 704
Condition100%6/6
$version and $version ge 2026 and ref $meta->{"io.modelcontextprotocol/clientInfo"} eq "HASH"
!ll&&!rl&&r
118118468
$version and $version ge 2026
!ll&&!rl&&r
10108586
MC/DC100%3/3
$version and $version ge 2026 and ref $meta->{"io.modelcontextprotocol/clientInfo"} eq "HASH"
$version $version ge 2026 ref $meta->{"io.modelcontextprotocol/clientInfo"} eq "HASH"
Truth table100%4/4
A and B and C
A= $versionB= $version ge 2026C= ref $meta->{"io.modelcontextprotocol/clientInfo"} eq "HASH"
ABCresult
0XX0
10X0
1100
1111
280  
281 704 ▶ if ($method eq "initialize") {
Branch: 1 branch
BranchTrueFalseTotal
if ($method eq 'initialize') { } 19 685 704
282 19 $version = $params->{protocolVersion};
283  
284 return $self->_rpc_error ($reply, $id, -32602, "Invalid initialize params")
285 unless defined $version && !ref $version
286 && ref $params->{capabilities} eq "HASH"
287 19 ▶ && ref $params->{clientInfo} eq "HASH";
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version and not ref $version and ref $params->{"capabilities"} eq "HASH" and ref $params->{"clientInfo"} eq "HASH" 0 19 19
Condition33%3/9
defined $version and not ref $version and ref $params->{"capabilities"} eq "HASH" and ref $params->{"clientInfo"} eq "HASH"
!ll&&!rl&&r
0019
defined $version and not ref $version and ref $params->{"capabilities"} eq "HASH"
!ll&&!rl&&r
0019
defined $version and not ref $version
!ll&&!rl&&r
0019
MC/DC0%0/4
defined $version and not ref $version and ref $params->{"capabilities"} eq "HASH" and ref $params->{"clientInfo"} eq "HASH"
defined $version not ref $version ref $params->{"capabilities"} eq "HASH" ref $params->{"clientInfo"} eq "HASH"
Truth table20%1/5
A and not(B) and C and D
A= defined $versionB= not ref $versionC= ref $params->{"capabilities"} eq "HASH"D= ref $params->{"clientInfo"} eq "HASH"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
288  
289 19 ▶ unless (grep $_ eq $version && $_ lt "2026", @{$self->{versions}}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep(($_ eq $version && $_ lt 2026), @{$$self{"versions"};})) 4 15 19
Condition66%2/3
$_ eq $version && $_ lt '2026'
!ll&&!rl&&r
49015
MC/DC50%1/2
$_ eq $version && $_ lt '2026'
$_ eq $version $_ lt '2026'
Truth table66%2/3
A && B
A= $_ eq $versionB= $_ lt '2026'
ABresult
0X0
100
111
290 4 ($version) = grep $_ lt "2026", @{$self->{versions}};
291 4 ▶ return $self->_rpc_error ($reply, $id, -32601, "Legacy initialization is not supported")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version 0 4 4
292 unless defined $version;
293 }
294 } else {
295 685 ▶ return $self->_rpc_error ($reply, $id, -32602, "Missing protocol version")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version and not ref $version 1 684 685
Condition66%2/3
defined $version and not ref $version
!ll&&!rl&&r
10684
MC/DC50%1/2
defined $version and not ref $version
defined $version not ref $version
Truth table66%2/3
A and not(B)
A= defined $versionB= not ref $version
ABresult
0X0
100
111
296 unless defined $version && !ref $version;
297  
298 return $self->_rpc_error ($reply, $id, -32022, "Unsupported protocol version", {
299 requested => $version,
300 supported => $self->{versions},
301 684 ▶ }) unless grep $_ eq $version, @{$self->{versions}};
Branch: 1 branch
BranchTrueFalseTotal
unless grep(($_ eq $version), @{$$self{"versions"};}) 5 679 684
302  
303 679 ▶ if ($version ge "2026") {
Branch: 1 branch
BranchTrueFalseTotal
if ($version ge 2026) 577 102 679
304 return $self->_rpc_error ($reply, $id, -32602, "Missing per-request metadata")
305 unless $meta->{"io.modelcontextprotocol/protocolVersion"} eq $version
306 577 ▶ && ref $meta->{"io.modelcontextprotocol/clientCapabilities"} eq "HASH";
Branch: 1 branch
BranchTrueFalseTotal
unless $meta->{"io.modelcontextprotocol/protocolVersion"} eq $version and ref $meta->{"io.modelcontextprotocol/clientCapabilities"} eq "HASH" 0 577 577
Condition33%1/3
$meta->{"io.modelcontextprotocol/protocolVersion"} eq $version and ref $meta->{"io.modelcontextprotocol/clientCapabilities"} eq "HASH"
!ll&&!rl&&r
00577
MC/DC0%0/2
$meta->{"io.modelcontextprotocol/protocolVersion"} eq $version and ref $meta->{"io.modelcontextprotocol/clientCapabilities"} eq "HASH"
$meta->{"io.modelcontextprotocol/protocolVersion"} eq $version ref $meta->{"io.modelcontextprotocol/clientCapabilities"} eq "HASH"
Truth table33%1/3
A and B
A= $meta->{"io.modelcontextprotocol/protocolVersion"} eq $versionB= ref $meta->{"io.modelcontextprotocol/clientCapabilities"} eq "HASH"
ABresult
0X0
100
111
307 }
308 }
309  
310 return $self->_rpc_error ($reply, $id, -32600, "Request id already outstanding")
311 698 ▶ if $peer->{requests}{$key};
Branch: 1 branch
BranchTrueFalseTotal
if $peer->{"requests"}{$key} 0 698 698
312  
313 # the private multibroker protocol uses the normal MCP capability handshake.
314 # keep the negotiated version on this stream's peer, not on the server.
315 my $capabilities = $method eq "initialize"
316 698 ▶ ? $params->{capabilities} : $meta->{"io.modelcontextprotocol/clientCapabilities"};
Branch: 1 branch
BranchTrueFalseTotal
$method eq 'initialize' ? : 19 679 698
317 698 ▶ if (ref $capabilities eq "HASH") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $capabilities eq "HASH") 596 102 698
318 596 my $extensions = $capabilities->{extensions};
319 596 ▶ if (ref $extensions eq "HASH") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $extensions eq "HASH") 137 459 596
320 137 my $extension = $extensions->{"anyevent-mcp/multibroker"};
321 $peer->{aemcp_multibroker} = 1
322 137 ▶ if ref $extension eq "HASH" && ($extension->{version} || 0) eq "1";
Branch: 1 branch
BranchTrueFalseTotal
if ref $extension eq "HASH" and ($extension->{"version"} || 0) eq 1 137 0 137
Condition40%2/5
ref $extension eq "HASH" and ($extension->{"version"} || 0) eq 1
!ll&&!rl&&r
00137
$extension->{'version'} || 0
l!l
1370
MC/DC0%0/2
ref $extension eq "HASH" and ($extension->{"version"} || 0) eq 1
ref $extension eq "HASH" $extension->{'version'}
Truth table33%1/3
A and B
A= ref $extension eq "HASH"B= $extension->{'version'}
ABresult
0X0
100
111
323 }
324 }
325  
326 698 my $user = $context{user};
327 698 ▶ my $ask = $self->{permissions} && $self->{permissions}{ask};
Condition66%2/3
$self->{'permissions'} && $self->{'permissions'}{'ask'}
!ll&&!rl&&r
4350263
MC/DC50%1/2
$self->{'permissions'} && $self->{'permissions'}{'ask'}
$self->{'permissions'} $self->{'permissions'}{'ask'}
Truth table66%2/3
A && B
A= $self->{'permissions'}B= $self->{'permissions'}{'ask'}
ABresult
0X0
100
111
328 my $trust = defined $ask && !ref $ask && (
329 $ask eq "mcp"
330 || $ask eq "auto" && $version ge "2026"
331 && ref $meta->{"io.modelcontextprotocol/clientCapabilities"} eq "HASH"
332 && ref $meta->{"io.modelcontextprotocol/clientCapabilities"}{elicitation} eq "HASH"
333 1 && (!keys %{$meta->{"io.modelcontextprotocol/clientCapabilities"}{elicitation}}
334 698 ▶ || ref $meta->{"io.modelcontextprotocol/clientCapabilities"}{elicitation}{form} eq "HASH")
Condition79%19/24
defined $ask && !ref($ask) && ($ask eq 'mcp' || $ask eq 'auto' && $version ge '2026' && ref $meta->{'io.modelcontextprotocol/clientCapabilities'} eq 'HASH' && ref $meta->{'io.modelcontextprotocol/clientCapabilities'}{'elicitation'} eq 'HASH' && (!keys(%{$$meta{'io.modelcontextprotocol/clientCapabilities'}{'elicitation'};}) || ref $meta->{'io.modelcontextprotocol/clientCapabilities'}{'elicitation'}{'form'} eq 'HASH'))
!ll&&!rl&&r
44152205
defined $ask and not ref $ask
!ll&&!rl&&r
4356257
$ask eq "mcp" or $ask eq "auto" and $version ge 2026 and ref $meta->{"io.modelcontextprotocol/clientCapabilities"} eq "HASH" and ref $meta->{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"} eq "HASH" and !keys(%{$$meta{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"};}) || ref $meta->{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"}{"form"} eq "HASH"
l!l&&r!l&&!r
204152
$ask eq "auto" and $version ge 2026 and ref $meta->{"io.modelcontextprotocol/clientCapabilities"} eq "HASH" and ref $meta->{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"} eq "HASH" and !keys(%{$$meta{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"};}) || ref $meta->{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"}{"form"} eq "HASH"
!ll&&!rl&&r
5201
$ask eq "auto" and $version ge 2026 and ref $meta->{"io.modelcontextprotocol/clientCapabilities"} eq "HASH" and ref $meta->{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"} eq "HASH"
!ll&&!rl&&r
5201
$ask eq "auto" and $version ge 2026 and ref $meta->{"io.modelcontextprotocol/clientCapabilities"} eq "HASH"
!ll&&!rl&&r
5201
$ask eq "auto" and $version ge 2026
!ll&&!rl&&r
5021
not keys %{$$meta{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"};} or ref $meta->{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"}{"form"} eq "HASH"
l!l&&r!l&&!r
010
MC/DC55%5/9
defined $ask && !ref($ask) && ($ask eq 'mcp' || $ask eq 'auto' && $version ge '2026' && ref $meta->{'io.modelcontextprotocol/clientCapabilities'} eq 'HASH' && ref $meta->{'io.modelcontextprotocol/clientCapabilities'}{'elicitation'} eq 'HASH' && (!keys(%{$$meta{'io.modelcontextprotocol/clientCapabilities'}{'elicitation'};}) || ref $meta->{'io.modelcontextprotocol/clientCapabilities'}{'elicitation'}{'form'} eq 'HASH'))
defined $ask not ref $ask $ask eq "mcp" $ask eq "auto" $version ge 2026 ref $meta->{"io.modelcontextprotocol/clientCapabilities"} eq "HASH" ref $meta->{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"} eq "HASH" not keys %{$$meta{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"};} ref $meta->{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"}{"form"} eq "HASH"
Truth table60%6/10
A and not(B) && C or D and E and F and G and not(H) or I
A= defined $askB= not ref $askC= $ask eq "mcp"D= $ask eq "auto"E= $version ge 2026F= ref $meta->{"io.modelcontextprotocol/clientCapabilities"} eq "HASH"G= ref $meta->{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"} eq "HASH"H= not keys %{$$meta{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"};}I= ref $meta->{"io.modelcontextprotocol/clientCapabilities"}{"elicitation"}{"form"} eq "HASH"
ABCDEFGHIresult
0XXXXXXXX0
10XXXXXXX0
1100XXXXX0
11010XXXX0
110110XXX0
1101110XX0
1101111000
111XXXXXX1
11011111X1
1101111011
335 );
336 698 ▶ if ($trust && exists $meta->{"anyevent-mcp/user"}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($trust and exists $meta->{"anyevent-mcp/user"}) 38 660 698
Condition100%3/3
$trust and exists $meta->{"anyevent-mcp/user"}
!ll&&!rl&&r
49316738
MC/DC100%2/2
$trust and exists $meta->{"anyevent-mcp/user"}
$trust exists $meta->{"anyevent-mcp/user"}
Truth table100%3/3
A and B
A= $trustB= exists $meta->{"anyevent-mcp/user"}
ABresult
0X0
100
111
337 38 $user = $meta->{"anyevent-mcp/user"};
338 38 ▶ return $self->_rpc_error ($reply, $id, -32602, "Invalid delegated user")
Branch: 1 branch
BranchTrueFalseTotal
if defined $user and ref $user || !($user =~ /\A(?:global|program|instance):[A-Za-z_][A-Za-z0-9_-]*\z/u) 1 37 38
Condition83%5/6
defined $user and ref $user || !($user =~ /\A(?:global|program|instance):[A-Za-z_][A-Za-z0-9_-]*\z/u)
!ll&&!rl&&r
3341
ref $user or not $user =~ /\A(?:global|program|instance):[A-Za-z_][A-Za-z0-9_-]*\z/u
l!l&&r!l&&!r
014
MC/DC66%2/3
defined $user and ref $user || !($user =~ /\A(?:global|program|instance):[A-Za-z_][A-Za-z0-9_-]*\z/u)
defined $user ref $user not $user =~ /\A(?:global|program|instance):[A-Za-z_][A-Za-z0-9_-]*\z/u
Truth table75%3/4
A and B or not(C)
A= defined $userB= ref $userC= not $user =~ /\A(?:global|program|instance):[A-Za-z_][A-Za-z0-9_-]*\z/u
ABCresult
0XX0
1000
11X1
1011
339 if defined $user && (ref $user
340 || $user !~ /\A(?:global|program|instance):[A-Za-z_][A-Za-z0-9_-]*\z/);
341 }
342  
343 my $req = AnyEvent::MCP::Server::Request->new (
344 server => $self,
345 peer => $peer,
346 id => $id,
347 method => $method,
348 params => $params,
349 user => $user,
350 protocol_version => $version,
351 672 ▶ on_reply => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
352 672 my ($req, $result) = @_;
353  
354 672 delete $peer->{requests}{$key};
355  
356 672 ▶ if ($req->{protocol_version} ge "2026") {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->{"protocol_version"} ge 2026) 559 113 672
357 $result = {
358 ($req->{method} =~ /\A(?:server\/discover|tools\/list|prompts\/list|resources\/(?:list|templates\/list|read))\z/
359 ? (ttlMs => 0, cacheScope => "private") : ()),
360 resultType => "complete",
361 %$result,
362 _meta => {
363 "io.modelcontextprotocol/serverInfo" => $self->{server_info},
364 559 ▶ %{$result->{_meta} || {}},
Branch: 1 branch
BranchTrueFalseTotal
$req->{'method'} =~ m[\A(?:server/discover|tools/list|prompts/list|resources/(?:list|templates/list|read))\z]u ? : 164 395 559
Condition100%2/2
$result->{'_meta'} || {}
l!l
52507
MC/DC100%1/1
$result->{'_meta'} || {}
$result->{'_meta'}
Truth table100%2/2
A
A= $result->{'_meta'}
Aresult
11
00
365 },
366 };
367 }
368  
369 672 $reply->({ jsonrpc => "2.0", id => $id, result => $result });
370 },
371 697 );
372  
373 697 ▶ if (my $notify = $context{on_notify}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $notify = $context{"on_notify"}) 577 120 697
374 4 ▶ $req->{on_notify} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
375 4 my ($req, $method, $params) = @_;
376  
377 4 $notify->($req, { jsonrpc => "2.0", method => $method, params => $params });
378 577 };
379 }
380  
381 697 ▶ if ($method eq "tools/call" && $req->{on_notify} && exists $meta->{progressToken}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method eq "tools/call" and $req->{"on_notify"} and exists $meta->{"progressToken"}) 12 685 697
Condition100%6/6
$method eq "tools/call" and $req->{"on_notify"} and exists $meta->{"progressToken"}
!ll&&!rl&&r
29738812
$method eq "tools/call" and $req->{"on_notify"}
!ll&&!rl&&r
23265400
MC/DC100%3/3
$method eq "tools/call" and $req->{"on_notify"} and exists $meta->{"progressToken"}
$method eq "tools/call" $req->{"on_notify"} exists $meta->{"progressToken"}
Truth table100%4/4
A and B and C
A= $method eq "tools/call"B= $req->{"on_notify"}C= exists $meta->{"progressToken"}
ABCresult
0XX0
10X0
1100
1111
382 12 my $started = AE::now;
383 12 my $weak = $req;
384 12 weaken $weak;
385 0 ▶ $req->{progress_timer} = AnyEvent->timer (after => 30, interval => 30, cb => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
386 0 ▶ return unless $weak && !$weak->{finished};
Branch: 1 branch
BranchTrueFalseTotal
unless $weak and not $weak->{"finished"} 0 0 0
Condition0%0/3
$weak and not $weak->{"finished"}
!ll&&!rl&&r
000
MC/DC0%0/2
$weak and not $weak->{"finished"}
$weak not $weak->{"finished"}
Truth table0%0/3
A and not(B)
A= $weakB= not $weak->{"finished"}
ABresult
0X0
100
111
387 0 my $elapsed = int (AE::now - $started);
388 0 $weak->progress ($elapsed, undef, "Working for ${elapsed}s");
389 12 });
390 }
391  
392 697 $peer->{requests}{$key} = $req;
393 697 weaken $peer->{requests}{$key};
394  
395 697 ▶ if ($method eq "tools/call") {
Branch: 1 branch
BranchTrueFalseTotal
if ($method eq "tools/call") 465 232 697
396 465 ▶ unless (defined $params->{name} && !ref $params->{name}
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $params->{"name"} and not ref $params->{"name"} and !exists $params->{"arguments"} || ref $params->{"arguments"} eq "HASH") 1 464 465
Condition66%6/9
defined $params->{"name"} and not ref $params->{"name"} and !exists $params->{"arguments"} || ref $params->{"arguments"} eq "HASH"
!ll&&!rl&&r
01464
defined $params->{"name"} and not ref $params->{"name"}
!ll&&!rl&&r
00465
not exists $params->{"arguments"} or ref $params->{"arguments"} eq "HASH"
l!l&&r!l&&!r
144501
MC/DC50%2/4
defined $params->{"name"} and not ref $params->{"name"} and !exists $params->{"arguments"} || ref $params->{"arguments"} eq "HASH"
defined $params->{"name"} not ref $params->{"name"} not exists $params->{"arguments"} ref $params->{"arguments"} eq "HASH"
Truth table60%3/5
A and not(B) and not(C) or D
A= defined $params->{"name"}B= not ref $params->{"name"}C= not exists $params->{"arguments"}D= ref $params->{"arguments"} eq "HASH"
ABCDresult
0XXX0
10XX0
11000
111X1
11011
397 && (!exists $params->{arguments} || ref $params->{arguments} eq "HASH")) {
398 1 $self->_reject ($req, $reply, -32602, "Invalid tool call");
399 1 return $req
400 }
401  
402 464 $req->{tool} = $params->{name};
403 464 ▶ $req->{args} = exists $params->{arguments} ? $params->{arguments} : {};
Branch: 1 branch
BranchTrueFalseTotal
exists $params->{'arguments'} ? : 450 14 464
404 }
405  
406 696 $req->{_reply} = $reply;
407  
408 696 $self->_dispatch ($req);
409  
410 694 $req
411 }
412  
413 702 ▶sub _dispatch {
Subroutine _dispatch: called CC=11 SCAR=24.0
414 702 my ($self, $req) = @_;
415  
416 eval {
417 $self->{permissions}->_resume ($req)
418 702 ▶ if $self->{permissions} && $req->{method} eq "tools/call";
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"permissions"} and $req->{"method"} eq "tools/call" 214 488 702
Condition100%3/3
$self->{"permissions"} and $req->{"method"} eq "tools/call"
!ll&&!rl&&r
43454214
MC/DC100%2/2
$self->{"permissions"} and $req->{"method"} eq "tools/call"
$self->{"permissions"} $req->{"method"} eq "tools/call"
Truth table100%3/3
A and B
A= $self->{"permissions"}B= $req->{"method"} eq "tools/call"
ABresult
0X0
100
111
419 682 $self->event (request => $req);
420 681 ▶ $self->dispatch ($req) unless $req->{finished};
Branch: 1 branch
BranchTrueFalseTotal
unless $req->{"finished"} 670 11 681
421 593 1
422 702 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->{"permissions"}->_resume($req) if $self->{"permissions"} and $req->{"method"} eq "tools/call"; $self->event("request", $req); $self->dispatch($req) unless $req->{"finished"}; 1 } } or do { my $error = $@; die $error if $req->{"finished"}; if (ref $error eq "AnyEvent::MCP::Server::Permissions::Required" and $self->{"permissions"}) { eval { do { $self->{"permissions"}->require($req, $error->{"request"}, sub { my($success, $grant) = @_; return if $req->{"finished"}; return $req->error($grant) unless $success; $self->{"permissions"}->_remember($req, $error->{"request"}, $grant); $self->_dispatch($req); } ); 1 } } or do { my $failure = $@; die $failure if $req->{"finished"}; $self->event("error", $req, $failure); $req->error($failure) }; } else { $self->event("error", $req, $error); if ($req->{"method"} eq "tools/call") { $req->error($error); } else { $self->_reject($req, $req->{"_reply"}, -32603, "Internal error"); } ; } } 593 107 700
423 107 my $error = $@;
424 107 ▶ die $error if $req->{finished};
Branch: 1 branch
BranchTrueFalseTotal
if $req->{"finished"} 0 107 107
425  
426 107 ▶ if (ref $error eq "AnyEvent::MCP::Server::Permissions::Required" && $self->{permissions}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $error eq 'AnyEvent::MCP::Server::Permissions::Required' and $self->{'permissions'}) { } 48 59 107
Condition66%2/3
ref $error eq "AnyEvent::MCP::Server::Permissions::Required" and $self->{"permissions"}
!ll&&!rl&&r
59048
MC/DC50%1/2
ref $error eq "AnyEvent::MCP::Server::Permissions::Required" and $self->{"permissions"}
ref $error eq "AnyEvent::MCP::Server::Permissions::Required" $self->{"permissions"}
Truth table66%2/3
A and B
A= ref $error eq "AnyEvent::MCP::Server::Permissions::Required"B= $self->{"permissions"}
ABresult
0X0
100
111
427 eval {
428 9 ▶ $self->{permissions}->require ($req, $error->{request}, sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
429 9 my ($success, $grant) = @_;
430  
431 9 ▶ return if $req->{finished};
Branch: 1 branch
BranchTrueFalseTotal
if $req->{"finished"} 0 9 9
432 9 ▶ return $req->error ($grant) unless $success;
Branch: 1 branch
BranchTrueFalseTotal
unless $success 3 6 9
433  
434 6 $self->{permissions}->_remember ($req, $error->{request}, $grant);
435 6 $self->_dispatch ($req);
436 48 });
437 47 1
438 48 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->{"permissions"}->require($req, $error->{"request"}, sub { my($success, $grant) = @_; return if $req->{"finished"}; return $req->error($grant) unless $success; $self->{"permissions"}->_remember($req, $error->{"request"}, $grant); $self->_dispatch($req); } ); 1 } } or do { my $failure = $@; die $failure if $req->{"finished"}; $self->event("error", $req, $failure); $req->error($failure) } 47 1 48
439 1 my $failure = $@;
440 1 ▶ die $failure if $req->{finished};
Branch: 1 branch
BranchTrueFalseTotal
if $req->{"finished"} 0 1 1
441 1 $self->event (error => $req, $failure);
442 1 $req->error ($failure);
443 };
444 } else {
445 59 $self->event (error => $req, $error);
446  
447 59 ▶ if ($req->{method} eq "tools/call") {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->{'method'} eq 'tools/call') { } 58 1 59
448 58 $req->error ($error);
449 } else {
450 1 $self->_reject ($req, $req->{_reply}, -32603, "Internal error");
451 }
452 }
453 };
454 }
455  
456 11 ▶sub _reject {
Subroutine _reject: called CC=1 SCAR=0.0
457 11 my ($self, $req, $reply, $code, $message) = @_;
458  
459 11 $req->{finished} = 1;
460 11 my $key = $req->{id};
461 11 delete $req->{peer}{requests}{$key};
462 11 delete $req->{progress_timer};
463 11 delete @$req{qw(on_reply on_notify on_cancel _reply)};
464  
465 11 $self->_rpc_error ($reply, $req->{id}, $code, $message)
466 }
467  
468 670 ▶sub dispatch {
Subroutine dispatch: called CC=11 SCAR=24.0
Pod documented
469 670 my ($self, $req) = @_;
470  
471 670 my $method = $req->{method};
472  
473 670 ▶ if ($method eq "initialize") {
Branch: 5 branches
BranchTrueFalseTotal
if ($method eq 'initialize') { } 19 651 670
elsif ($method eq 'server/discover') { } 104 547 651
elsif ($method eq 'ping') { } 34 513 547
elsif ($method eq 'tools/list') { } 64 449 513
elsif ($method eq 'tools/call') { } 441 8 449
474 19 $req->{peer}{protocol_version} = $req->{protocol_version};
475 19 $req->{peer}{client_info} = $req->{params}{clientInfo};
476 19 $req->{peer}{client_capabilities} = $req->{params}{capabilities};
477  
478 my $result = {
479 protocolVersion => $req->{protocol_version},
480 serverInfo => $self->{server_info},
481 capabilities => $self->{capabilities},
482 19 };
483 19 ▶ $result->{instructions} = $self->{instructions} if length $self->{instructions};
Branch: 1 branch
BranchTrueFalseTotal
if length $self->{"instructions"} 7 12 19
484  
485 19 $req->reply ($result);
486  
487 } elsif ($method eq "server/discover") {
488 my $result = {
489 supportedVersions => $self->{versions},
490 capabilities => $self->{capabilities},
491 104 };
492 104 ▶ $result->{instructions} = $self->{instructions} if length $self->{instructions};
Branch: 1 branch
BranchTrueFalseTotal
if length $self->{"instructions"} 64 40 104
493  
494 104 $req->reply ($result);
495  
496 } elsif ($method eq "ping") {
497 34 $req->reply ({});
498  
499 } elsif ($method eq "tools/list") {
500 64 ▶ if ($self->{on_tools_list}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'on_tools_list'}) { } 12 52 64
501 12 $self->event (tools_list => $req);
502 } else {
503 52 $req->reply ({ tools => [map @{$_->list}, @{$self->{toolsets}}] });
504 }
505  
506 } elsif ($method eq "tools/call") {
507 441 ▶ if ($self->{on_tools_call}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'on_tools_call'}) { } 193 248 441
508 193 $self->event (tools_call => $req, $req->{args});
509 } else {
510 248 my ($toolset) = grep exists $_->{tool}{$req->{tool}}, @{$self->{toolsets}};
511  
512 248 ▶ if ($toolset) {
Branch: 1 branch
BranchTrueFalseTotal
if ($toolset) { } 247 1 248
513 247 $toolset->call ($req);
514 } else {
515 1 $self->_reject ($req, $req->{_reply}, -32602, "Unknown tool '$req->{tool}'");
516 }
517 }
518  
519 } else {
520 8 $self->_reject ($req, $req->{_reply}, -32601, "Method not found");
521 }
522 }
523  
524 93 1
« blib/lib/AnyEvent/MCP/Server/Permissions.pm ↑ Summary blib/lib/AnyEvent/MCP.pm »