39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/klee/mcp/tools/find_collaborators.rb', line 39
def call(patterns:, object:, threshold: 2, scope: "file", ignore: [], server_context: nil)
validator = Klee::MCP::PathValidator.new
validator.validate!(patterns)
codebase = Klee.scan(*patterns, ignore: ignore, threshold: threshold)
pairs = codebase.collaborators.pairs(scope: scope.to_sym)
relevant_pairs = pairs.select { |pair, _| pair.include?(object) }
collaborators = relevant_pairs.map do |pair, count|
other = (pair - [object]).first
{
name: other,
co_occurrences: count,
scope: scope
}
end.sort_by { |c| -c[:co_occurrences] }
result = {
object: object,
collaborators: collaborators
}
::MCP::Tool::Response.new([{
type: "text",
text: JSON.pretty_generate(result)
}])
end
|