| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SignalWire::Agents::Skills::Builtin::McpGateway; |
|
2
|
3
|
|
|
3
|
|
21
|
use strict; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
132
|
|
|
3
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
205
|
|
|
4
|
3
|
|
|
3
|
|
20
|
use Moo; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
23
|
|
|
5
|
|
|
|
|
|
|
extends 'SignalWire::Agents::Skills::SkillBase'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1354
|
use SignalWire::Agents::Skills::SkillRegistry; |
|
|
3
|
|
|
|
|
48
|
|
|
|
3
|
|
|
|
|
2449
|
|
|
8
|
|
|
|
|
|
|
SignalWire::Agents::Skills::SkillRegistry->register_skill('mcp_gateway', __PACKAGE__); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has '+skill_name' => (default => sub { 'mcp_gateway' }); |
|
11
|
|
|
|
|
|
|
has '+skill_description' => (default => sub { 'Bridge MCP servers with SWAIG functions' }); |
|
12
|
|
|
|
|
|
|
has '+supports_multiple_instances' => (default => sub { 0 }); |
|
13
|
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
0
|
2280
|
sub setup { 1 } |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub register_tools { |
|
17
|
3
|
|
|
3
|
0
|
565
|
my ($self) = @_; |
|
18
|
3
|
|
100
|
|
|
28
|
my $prefix = $self->params->{tool_prefix} // 'mcp_'; |
|
19
|
3
|
|
100
|
|
|
22
|
my $services = $self->params->{services} // []; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Register a stub tool for each service |
|
22
|
3
|
|
|
|
|
11
|
for my $svc (@$services) { |
|
23
|
3
|
50
|
50
|
|
|
19
|
my $svc_name = ref $svc eq 'HASH' ? ($svc->{name} // 'default') : $svc; |
|
24
|
3
|
|
|
|
|
9
|
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
|
|
|
|
|
|
|
handler => sub { |
|
35
|
0
|
|
|
0
|
|
0
|
my ($args, $raw) = @_; |
|
36
|
0
|
|
|
|
|
0
|
require SignalWire::Agents::SWAIG::FunctionResult; |
|
37
|
0
|
|
|
|
|
0
|
return SignalWire::Agents::SWAIG::FunctionResult->new( |
|
38
|
|
|
|
|
|
|
response => "MCP gateway call to $svc_name" |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
}, |
|
41
|
3
|
|
|
|
|
47
|
); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub get_hints { |
|
46
|
1
|
|
|
1
|
0
|
8
|
my ($self) = @_; |
|
47
|
1
|
|
|
|
|
4
|
my @hints = ('MCP', 'gateway'); |
|
48
|
1
|
|
50
|
|
|
3
|
for my $svc (@{ $self->params->{services} // [] }) { |
|
|
1
|
|
|
|
|
8
|
|
|
49
|
1
|
50
|
33
|
|
|
9
|
push @hints, ref $svc eq 'HASH' ? ($svc->{name} // ()) : $svc; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
1
|
|
|
|
|
3
|
return \@hints; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub get_global_data { |
|
55
|
1
|
|
|
1
|
0
|
8
|
my ($self) = @_; |
|
56
|
|
|
|
|
|
|
return { |
|
57
|
|
|
|
|
|
|
mcp_gateway_url => $self->params->{gateway_url} // '', |
|
58
|
|
|
|
|
|
|
mcp_session_id => undef, |
|
59
|
1
|
|
50
|
|
|
17
|
mcp_services => $self->params->{services} // [], |
|
|
|
|
50
|
|
|
|
|
|
60
|
|
|
|
|
|
|
}; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _get_prompt_sections { |
|
64
|
|
|
|
|
|
|
return [{ |
|
65
|
1
|
|
|
1
|
|
8
|
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
|
|
|
|
|
|
|
sub get_parameter_schema { |
|
72
|
|
|
|
|
|
|
return { |
|
73
|
1
|
|
|
1
|
0
|
4342
|
%{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema }, |
|
|
1
|
|
|
|
|
7
|
|
|
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
|
|
|
|
|
|
|
1; |