KnowledgeStore/Tools.pm

filter: Statementstmt 60.0% 3 / 5 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 71.4% 5 / 7 CC 1 SCAR 1.4
CC
1
Cov
60%
BEGIN
1.3
BEGIN
1.0
CRAP 1.1
« KnowledgeStore/TermWeight.pm ↑ Summary KnowledgeStore/Tools/Revisioned.pm »
1 package MCP::Server::KnowledgeStore::Tools;
2 1 ▶use v5.38;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 0 ▶use Mojo::Base -strict, -signatures;
Subroutine BEGIN: called CC=1 SCAR=2.6
4  
5 our $VERSION = '0.001';
6  
7 # ABSTRACT: Discovers and assembles the installed MCP::Server::KnowledgeStore::Tools::* plugins
8  
9 use MCP::Server;
10 use Mojo::JSON qw(false);
11 use Module::Pluggable::Object;
12 use MCP::Server::KnowledgeStore::ResourceTemplates;
13  
14 sub build ($class, $store, %opts) {
15  
16 # Use our extended server class for resource template support
17 my $server = MCP::Server::KnowledgeStore::ResourceTemplates->new(
18 name => 'mcp-knowledge-store',
19 version => $VERSION,
20 instructions => <<~'END',
21 One canonical store for project memories and skills, shared by every
22 agent. Prefer these tools over any local copy: this store is
23 authoritative. Search or list before saving, so an existing entry
24 gets updated instead of duplicated under a new name.
25 END
26 );
27  
28 # Server-level configuration
29 my $allow_purge = exists $opts{allow_purge} ? $opts{allow_purge} : 1;
30  
31 # Cross-cutting, not owned by any one resource plugin - it aggregates
32 # across whatever memory/skill/spec/agent tags exist, so it stays here
33 # rather than being invented by one plugin and missed by the others.
34 $server->tool(
35 name => 'list_projects',
36 description =>
37 'List distinct project names in use across memories, skills, specs '
38 . 'and agents',
39 input_schema =>
40 { type => 'object', properties => {}, additionalProperties => false },
41 code => sub ($tool, $args) {
42 return $tool->structured_result({ projects => $store->list_projects });
43 },
44 );
45  
46 for my $plugin ($class->plugins) {
47 $plugin->register($server, $store, allow_purge => $allow_purge);
48 }
49  
50 return $server;
51 }
52  
53 # One plugin per resource (Memory, Skill, Spec, Agent, ...), each its
54 # own distribution depending on this one for Store and Support. Adding
55 # a resource means installing a new MCP::Server::KnowledgeStore::Tools::* dist,
56 # not editing this file.
57 sub plugins ($class) {
58 my $finder = Module::Pluggable::Object->new(
59 search_path => 'MCP::Server::KnowledgeStore::Tools',
60 require => 1,
61 except => qr/^MCP::Server::KnowledgeStore::Tools::(Support|Revisioned)\z/,
62 );
63 return $finder->plugins;
64 }
65  
66 1;
67  
68 __END__
« KnowledgeStore/TermWeight.pm ↑ Summary KnowledgeStore/Tools/Revisioned.pm »