Module: CompletionKit::McpTools::MetricGroups
- Extended by:
- Base
- Defined in:
- app/services/completion_kit/mcp_tools/metric_groups.rb
Constant Summary collapse
- TOOLS =
{ "metric_groups_list" => { description: "List all metric groups", inputSchema: {type: "object", properties: {}, required: []}, handler: :list }, "metric_groups_get" => { description: "Get a metric group by ID", inputSchema: {type: "object", properties: {id: {type: "integer"}}, required: ["id"]}, handler: :get }, "metric_groups_create" => { description: "Create a metric group", inputSchema: { type: "object", properties: { name: {type: "string"}, description: {type: "string"}, metric_ids: {type: "array", items: {type: "integer"}}, tag_names: {type: "array", items: {type: "string"}} }, required: ["name"] }, handler: :create }, "metric_groups_update" => { description: "Update a metric group", inputSchema: { type: "object", properties: { id: {type: "integer"}, name: {type: "string"}, description: {type: "string"}, metric_ids: {type: "array", items: {type: "integer"}}, tag_names: {type: "array", items: {type: "string"}} }, required: ["id"] }, handler: :update }, "metric_groups_delete" => { description: "Delete a metric group", inputSchema: {type: "object", properties: {id: {type: "integer"}}, required: ["id"]}, handler: :delete } }.freeze
Class Method Summary collapse
- .create(args) ⇒ Object
- .delete(args) ⇒ Object
- .get(args) ⇒ Object
- .list(_args) ⇒ Object
- .update(args) ⇒ Object
Methods included from Base
call, definitions, error_result, text_result
Class Method Details
.create(args) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'app/services/completion_kit/mcp_tools/metric_groups.rb', line 58 def self.create(args) metric_group = CompletionKit::MetricGroup.new(args.slice("name", "description")) metric_group.tag_names = args["tag_names"] if args.key?("tag_names") if metric_group.save metric_group.replace_metrics!(args["metric_ids"]) text_result(metric_group.reload.as_json) else error_result(metric_group.errors..join(", ")) end end |
.delete(args) ⇒ Object
80 81 82 83 |
# File 'app/services/completion_kit/mcp_tools/metric_groups.rb', line 80 def self.delete(args) CompletionKit::MetricGroup.find(args["id"]).destroy! text_result("Metric group #{args["id"]} deleted") end |
.get(args) ⇒ Object
54 55 56 |
# File 'app/services/completion_kit/mcp_tools/metric_groups.rb', line 54 def self.get(args) text_result(CompletionKit::MetricGroup.find(args["id"]).as_json) end |
.list(_args) ⇒ Object
50 51 52 |
# File 'app/services/completion_kit/mcp_tools/metric_groups.rb', line 50 def self.list(_args) text_result(CompletionKit::MetricGroup.order(created_at: :desc).map(&:as_json)) end |
.update(args) ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'app/services/completion_kit/mcp_tools/metric_groups.rb', line 69 def self.update(args) metric_group = CompletionKit::MetricGroup.find(args["id"]) if metric_group.update(args.except("id", "metric_ids").slice("name", "description")) metric_group.replace_metrics!(args["metric_ids"]) if args.key?("metric_ids") metric_group.update!(tag_names: args["tag_names"]) if args.key?("tag_names") text_result(metric_group.reload.as_json) else error_result(metric_group.errors..join(", ")) end end |