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"}} }, 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"}} }, 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
56 57 58 59 60 61 62 63 64 |
# File 'app/services/completion_kit/mcp_tools/metric_groups.rb', line 56 def self.create(args) metric_group = CompletionKit::MetricGroup.new(args.slice("name", "description")) 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
76 77 78 79 |
# File 'app/services/completion_kit/mcp_tools/metric_groups.rb', line 76 def self.delete(args) CompletionKit::MetricGroup.find(args["id"]).destroy! text_result("Metric group #{args["id"]} deleted") end |
.get(args) ⇒ Object
52 53 54 |
# File 'app/services/completion_kit/mcp_tools/metric_groups.rb', line 52 def self.get(args) text_result(CompletionKit::MetricGroup.find(args["id"]).as_json) end |
.list(_args) ⇒ Object
48 49 50 |
# File 'app/services/completion_kit/mcp_tools/metric_groups.rb', line 48 def self.list(_args) text_result(CompletionKit::MetricGroup.order(created_at: :desc).map(&:as_json)) end |
.update(args) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'app/services/completion_kit/mcp_tools/metric_groups.rb', line 66 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") text_result(metric_group.reload.as_json) else error_result(metric_group.errors..join(", ")) end end |