blib/lib/SignalWire/Skills/Builtin/McpGateway.pm

filter: Statementstmt 93.0% 40 / 43 Branchbran 50.0% 2 / 4 Conditioncond 60.0% 9 / 15 MC/DCmcdc 25.0% 2 / 8 Subroutinesub 92.8% 13 / 14 Podpod 0.0% 0 / 5 totaltotal 74.1% 66 / 89 CC 12 SCAR 12.9
CC
12
Cov
82%
register_tools
6.8
get_hints
5.7
get_global_data
3.3
CRAP 3.7
« blib/lib/SignalWire/DataMap.pm ↑ Summary blib/lib/SignalWire/Prefabs/FAQBot.pm »
1 package SignalWire::Skills::Builtin::McpGateway;
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 extends 'SignalWire::Skills::SkillBase';
6  
7 4 ▶use SignalWire::Skills::SkillRegistry;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 SignalWire::Skills::SkillRegistry->register_skill('mcp_gateway', __PACKAGE__);
9  
10 8 ▶has '+skill_name' => (default => sub { 'mcp_gateway' });
Subroutine __ANON__: called CC=1 SCAR=0.0
11 8 ▶has '+skill_description' => (default => sub { 'Bridge MCP servers with SWAIG functions' });
Subroutine __ANON__: called CC=1 SCAR=0.0
12 8 ▶has '+supports_multiple_instances' => (default => sub { 0 });
Subroutine __ANON__: called CC=1 SCAR=0.0
13  
14 4 ▶sub setup { 1 }
Subroutine setup: called CC=1 SCAR=0.0
Pod undocumented
15  
16 3 ▶sub register_tools {
Subroutine register_tools: called CC=6 SCAR=19.1
Pod undocumented
17 3 my ($self) = @_;
18 3 ▶ my $prefix = $self->params->{tool_prefix} // 'mcp_';
Condition100%2/2
$self->params->{"tool_prefix"} // "mcp_"
l!l
12
MC/DC100%1/1
$self->params->{"tool_prefix"} // "mcp_"
$self->params->{"tool_prefix"}
Truth table100%2/2
A
A= $self->params->{"tool_prefix"}
Aresult
11
00
19 3 ▶ my $services = $self->params->{services} // [];
Condition100%2/2
$self->params->{"services"} // []
l!l
21
MC/DC100%1/1
$self->params->{"services"} // []
$self->params->{"services"}
Truth table100%2/2
A
A= $self->params->{"services"}
Aresult
11
00
20  
21 # Register a stub tool for each service
22 3 for my $svc (@$services) {
23 3 ▶ my $svc_name = ref $svc eq 'HASH' ? ($svc->{name} // 'default') : $svc;
Branch: 1 branch
BranchTrueFalseTotal
ref $svc eq 'HASH' ? : 3 0 3
Condition50%1/2
$svc->{"name"} // "default"
l!l
30
MC/DC0%0/1
$svc->{"name"} // "default"
$svc->{"name"}
Truth table50%1/2
A
A= $svc->{"name"}
Aresult
11
00
24 3 my $tool_name = "${prefix}${svc_name}";
25 $self->define_tool(
26 name => $tool_name,
27 description => "[$svc_name] MCP gateway tool",
28 parameters => {
29 type => 'object',
30 properties => {
31 arguments => { type => 'string', description => 'Arguments to pass to MCP service' },
32 },
33 },
34 0 ▶ handler => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
35 0 my ($args, $raw) = @_;
36 0 require SignalWire::SWAIG::FunctionResult;
37 0 return SignalWire::SWAIG::FunctionResult->new(
38 response => "MCP gateway call to $svc_name"
39 );
40 },
41 3 );
42 }
43 }
44  
45 1 ▶sub get_hints {
Subroutine get_hints: called CC=5 SCAR=17.5
Pod undocumented
46 1 my ($self) = @_;
47 1 my @hints = ('MCP', 'gateway');
48 1 ▶ for my $svc (@{ $self->params->{services} // [] }) {
Condition50%1/2
$self->params->{"services"} // []
l!l
10
MC/DC0%0/1
$self->params->{"services"} // []
$self->params->{"services"}
Truth table50%1/2
A
A= $self->params->{"services"}
Aresult
11
00
49 1 ▶ push @hints, ref $svc eq 'HASH' ? ($svc->{name} // ()) : $svc;
Branch: 1 branch
BranchTrueFalseTotal
ref $svc eq 'HASH' ? : 1 0 1
Condition33%1/3
$svc->{"name"} // ()
l!l&&r!l&&!r
100
MC/DC0%0/2
$svc->{"name"} // ()
$svc->{"name"} ()
Truth table33%1/3
A // B
A= $svc->{"name"}B= ()
ABresult
1X1
011
000
50 }
51 1 return \@hints;
52 }
53  
54 1 ▶sub get_global_data {
Subroutine get_global_data: called CC=3 SCAR=12.0
Pod undocumented
55 1 my ($self) = @_;
56 return {
57 mcp_gateway_url => $self->params->{gateway_url} // '',
58 mcp_session_id => undef,
59 1 ▶ mcp_services => $self->params->{services} // [],
Condition50%2/4
$self->params->{"gateway_url"} // ""
l!l
10
$self->params->{"services"} // []
l!l
01
MC/DC0%0/1
$self->params->{"gateway_url"} // ""
$self->params->{"gateway_url"}
MC/DC0%0/1
$self->params->{"services"} // []
$self->params->{"services"}
Truth table50%1/2
A
A= $self->params->{"gateway_url"}
Aresult
11
00
Truth table50%1/2
A
A= $self->params->{"services"}
Aresult
11
00
60 };
61 }
62  
63 1 ▶sub _get_prompt_sections {
Subroutine _get_prompt_sections: called CC=1 SCAR=0.0
64 return [{
65 1 title => 'MCP Gateway Integration',
66 body => 'You have access to MCP gateway services.',
67 bullets => ['Use MCP tools to interact with connected services'],
68 }];
69 }
70  
71 1 ▶sub get_parameter_schema {
Subroutine get_parameter_schema: called CC=1 SCAR=0.0
Pod undocumented
72 return {
73 1 %{ SignalWire::Skills::SkillBase->get_parameter_schema },
74 gateway_url => { type => 'string', required => 1 },
75 auth_token => { type => 'string', hidden => 1 },
76 services => { type => 'array' },
77 tool_prefix => { type => 'string', default => 'mcp_' },
78 };
79 }
80  
81 4 1;
« blib/lib/SignalWire/DataMap.pm ↑ Summary blib/lib/SignalWire/Prefabs/FAQBot.pm »