Agent/MCP/StdioServer.pm

filter: Statementstmt 100% 33 / 33 Branchbran 61.1% 11 / 18 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 50.0% 1 / 2 totaltotal 81.5% 53 / 65 CC 13 SCAR 23.6
CC
13
Cov
83%
BUILD
15.1
BEGIN
1.0
BEGIN
1.0
CRAP 10.6
« Agent/CLI.pm ↑ Summary Agent/Options.pm »
1 package Claude::Agent::MCP::StdioServer;
2  
3 8 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 8 ▶use Object::Proto ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
10 8 Object::Proto::define('Claude::Agent::MCP::StdioServer',
11 'command:Str:required',
12 'args:ArrayRef:default([])',
13 'env:HashRef:default({})',
14 'type:Str:readonly:default(stdio)',
15 );
16 }
17  
18 8 ▶sub BUILD {
Subroutine BUILD: called CC=13 SCAR=27.1
Pod undocumented
19 8 my ($self) = @_;
20  
21 8 ▶ die "Command must be absolute path" unless $self->command =~ m{^/};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->command =~ m[^/]u 1 7 8
22 7 require Cwd;
23 7 my $canon = Cwd::abs_path($self->command);
24 7 ▶ die "Invalid command path" unless $canon && $canon =~ m{^/};
Branch: 1 branch
BranchTrueFalseTotal
unless $canon and $canon =~ m[^/]u 0 7 7
Condition33%1/3
$canon and $canon =~ m[^/]u
!ll&&!rl&&r
007
MC/DC0%0/2
$canon and $canon =~ m[^/]u
$canon $canon =~ m[^/]u
Truth table33%1/3
A and B
A= $canonB= $canon =~ m[^/]u
ABresult
0X0
100
111
25  
26 7 for my $arg (@{$self->args}) {
27 5 ▶ next unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 5 5
28 5 ▶ die "Invalid arg: contains null byte" if $arg =~ /\0/;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ /\0/u 0 5 5
29 5 ▶ die "Invalid arg: contains shell metacharacters"
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ /[`\$\(\)\{\};\|<>\\\n\r]/u 1 4 5
30 if $arg =~ /[`\$\(\)\{\};\|<>\\\n\r]/;
31 }
32  
33 6 for my $key (keys %{$self->env}) {
34 1 ▶ die "Invalid env var name '$key': must match [A-Za-z_][A-Za-z0-9_]*"
Branch: 1 branch
BranchTrueFalseTotal
unless $key =~ /^[A-Za-z_][A-Za-z0-9_]*$/u 0 1 1
35 unless $key =~ /^[A-Za-z_][A-Za-z0-9_]*$/;
36 1 my $value = $self->env->{$key};
37 1 ▶ next unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 1 1
38 1 ▶ die "Invalid env var value for '$key': contains null byte" if $value =~ /\0/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /\0/u 0 1 1
39 1 ▶ die "Invalid env var value for '$key': contains control characters"
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/u 0 1 1
40 if $value =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/;
41 }
42 6 return;
43 }
44  
45 2 ▶sub to_hash {
Subroutine to_hash: called CC=1 SCAR=0.0
Pod documented
46 2 my ($self) = @_;
47 return {
48 2 type => 'stdio',
49 command => $self->command,
50 args => $self->args,
51 env => $self->env,
52 };
53 }
54  
55 8 1;
56  
57 __END__
« Agent/CLI.pm ↑ Summary Agent/Options.pm »