Module: CompletionKit::McpTools::Tags

Extended by:
Base
Defined in:
app/services/completion_kit/mcp_tools/tags.rb

Constant Summary collapse

TOOLS =
{
  "tags_list" => {
    description: "List all tags",
    inputSchema: {type: "object", properties: {}, required: []},
    handler: :list
  },
  "tags_get" => {
    description: "Get a tag by ID",
    inputSchema: {type: "object", properties: {id: {type: "integer"}}, required: ["id"]},
    handler: :get
  },
  "tags_create" => {
    description: "Create a tag. Color is auto-assigned.",
    inputSchema: {
      type: "object",
      properties: {name: {type: "string"}},
      required: ["name"]
    },
    handler: :create
  },
  "tags_update" => {
    description: "Rename a tag.",
    inputSchema: {
      type: "object",
      properties: {id: {type: "integer"}, name: {type: "string"}},
      required: ["id"]
    },
    handler: :update
  },
  "tags_delete" => {
    description: "Delete a tag. Removes the tag from every linked metric, prompt, run, and dataset.",
    inputSchema: {type: "object", properties: {id: {type: "integer"}}, required: ["id"]},
    handler: :delete
  }
}.freeze

Class Method Summary collapse

Methods included from Base

call, definitions, error_result, text_result

Class Method Details

.create(args) ⇒ Object



50
51
52
53
54
55
56
57
# File 'app/services/completion_kit/mcp_tools/tags.rb', line 50

def self.create(args)
  tag = CompletionKit::Tag.new(name: args["name"])
  if tag.save
    text_result(tag.as_json)
  else
    error_result(tag.errors.full_messages.join(", "))
  end
end

.delete(args) ⇒ Object



68
69
70
71
# File 'app/services/completion_kit/mcp_tools/tags.rb', line 68

def self.delete(args)
  CompletionKit::Tag.find(args["id"]).destroy!
  text_result("Tag #{args["id"]} deleted")
end

.get(args) ⇒ Object



46
47
48
# File 'app/services/completion_kit/mcp_tools/tags.rb', line 46

def self.get(args)
  text_result(CompletionKit::Tag.find(args["id"]).as_json)
end

.list(_args) ⇒ Object



42
43
44
# File 'app/services/completion_kit/mcp_tools/tags.rb', line 42

def self.list(_args)
  text_result(CompletionKit::Tag.order(:name).map(&:as_json))
end

.update(args) ⇒ Object



59
60
61
62
63
64
65
66
# File 'app/services/completion_kit/mcp_tools/tags.rb', line 59

def self.update(args)
  tag = CompletionKit::Tag.find(args["id"])
  if tag.update(name: args["name"])
    text_result(tag.as_json)
  else
    error_result(tag.errors.full_messages.join(", "))
  end
end