bin/mcp-run-bash

filter: Statementstmt 84.6% 22 / 26 Branchbran 71.4% 10 / 14 Conditioncond 83.3% 10 / 12 MC/DCmcdc 71.4% 5 / 7 Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 80.6% 50 / 62 CC 1 SCAR 0.0
CC
1
Cov
81%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/MCP/Run.pm ↑ Summary lib/MCP/Run/Compress/Filters.pm »
1 #!/usr/bin/env perl
2 # PODNAME: mcp-run-bash
3 # ABSTRACT: MCP server that executes shell commands via bash over stdio
4  
5 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 ▶use MCP::Run::Bash;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 19 my %args;
10  
11 19 ▶if (my $allowed = $ENV{MCP_RUN_ALLOWED_COMMANDS}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $allowed = $ENV{"MCP_RUN_ALLOWED_COMMANDS"}) 0 19 19
12 0 $args{allowed_commands} = [ grep { length } split /\s*,\s*/, $allowed ];
13 }
14  
15 19 ▶if (my $wd = $ENV{MCP_RUN_WORKING_DIRECTORY}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $wd = $ENV{"MCP_RUN_WORKING_DIRECTORY"}) 0 19 19
16 0 $args{working_directory} = $wd;
17 }
18  
19 # Configuration a human wrote into a client config, not an argument the model
20 # passes per call - so a bad value is a mistake worth stopping for. `+ 0` took
21 # any string ('30s' became 30, 'abc' became 0, '1e400' became Inf), warned on
22 # the stderr of a stdio server, and left the user believing the timeout they
23 # configured was in force. MCP::Run::Bash normalises unusable per-call
24 # timeouts to the server default instead of dying, because those arrive
25 # mid-session from the model and must not take the server down with them;
26 # here nothing is running yet, and a client that cannot start its server says
27 # so, while a silent default is invisible until a command dies early.
28 # The ceiling is the module's own constant, so the two layers cannot drift:
29 # anything above it is a timeout alarm() cannot arm.
30 19 ▶if (defined $ENV{MCP_RUN_TIMEOUT} && length $ENV{MCP_RUN_TIMEOUT}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"MCP_RUN_TIMEOUT"} and length $ENV{"MCP_RUN_TIMEOUT"}) 11 8 19
Condition66%2/3
defined $ENV{"MCP_RUN_TIMEOUT"} and length $ENV{"MCP_RUN_TIMEOUT"}
!ll&&!rl&&r
8011
MC/DC50%1/2
defined $ENV{"MCP_RUN_TIMEOUT"} and length $ENV{"MCP_RUN_TIMEOUT"}
defined $ENV{"MCP_RUN_TIMEOUT"} length $ENV{"MCP_RUN_TIMEOUT"}
Truth table66%2/3
A and B
A= defined $ENV{"MCP_RUN_TIMEOUT"}B= length $ENV{"MCP_RUN_TIMEOUT"}
ABresult
0X0
100
111
31 11 my $timeout = $ENV{MCP_RUN_TIMEOUT};
32 11 my $max = MCP::Run::Bash->MAX_TIMEOUT;
33  
34 # Digits only: whole seconds is what alarm() counts, and a pattern rules out
35 # the numeric warning as much as the wrong value behind it.
36 11 ▶ die "MCP_RUN_TIMEOUT must be a whole number of seconds between 1 and $max, "
Branch: 1 branch
BranchTrueFalseTotal
unless $timeout =~ /\A[0-9]+\z/ and $timeout > 0 and $timeout <= $max 9 2 11
Condition100%6/6
$timeout =~ /\A[0-9]+\z/ and $timeout > 0 and $timeout <= $max
!ll&&!rl&&r
812
$timeout =~ /\A[0-9]+\z/ and $timeout > 0
!ll&&!rl&&r
713
MC/DC100%3/3
$timeout =~ /\A[0-9]+\z/ and $timeout > 0 and $timeout <= $max
$timeout =~ /\A[0-9]+\z/ $timeout > 0 $timeout <= $max
Truth table100%4/4
A and B and C
A= $timeout =~ /\A[0-9]+\z/B= $timeout > 0C= $timeout <= $max
ABCresult
0XX0
10X0
1100
1111
37 . "got '$timeout'\n"
38 unless $timeout =~ /\A[0-9]+\z/ && $timeout > 0 && $timeout <= $max;
39  
40 2 $args{timeout} = $timeout + 0;
41 }
42  
43 10 $args{compress} = 1;
44 10 ▶if (defined $ENV{MCP_RUN_COMPRESS} && length $ENV{MCP_RUN_COMPRESS}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"MCP_RUN_COMPRESS"} and length $ENV{"MCP_RUN_COMPRESS"}) 2 8 10
Condition66%2/3
defined $ENV{"MCP_RUN_COMPRESS"} and length $ENV{"MCP_RUN_COMPRESS"}
!ll&&!rl&&r
802
MC/DC50%1/2
defined $ENV{"MCP_RUN_COMPRESS"} and length $ENV{"MCP_RUN_COMPRESS"}
defined $ENV{"MCP_RUN_COMPRESS"} length $ENV{"MCP_RUN_COMPRESS"}
Truth table66%2/3
A and B
A= defined $ENV{"MCP_RUN_COMPRESS"}B= length $ENV{"MCP_RUN_COMPRESS"}
ABresult
0X0
100
111
45 2 ▶ $args{compress} = ( $ENV{MCP_RUN_COMPRESS} =~ /^(?:1|true|yes|on)$/i ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'MCP_RUN_COMPRESS'} =~ /^(?:1|true|yes|on)$/i ? : 0 2 2
46 }
47  
48 10 ▶if (my $name = $ENV{MCP_RUN_TOOL_NAME}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $name = $ENV{"MCP_RUN_TOOL_NAME"}) 0 10 10
49 0 $args{tool_name} = $name;
50 }
51  
52 10 MCP::Run::Bash->run_stdio(%args);
53  
54 __END__
« blib/lib/MCP/Run.pm ↑ Summary lib/MCP/Run/Compress/Filters.pm »