Module: CompletionKit::McpTools::Prompts
- Extended by:
- Base
- Defined in:
- app/services/completion_kit/mcp_tools/prompts.rb
Constant Summary collapse
- TOOLS =
{ "prompts_list" => { description: "List all prompts", inputSchema: {type: "object", properties: {}, required: []}, handler: :list }, "prompts_get" => { description: "Get a prompt by ID", inputSchema: {type: "object", properties: {id: {type: "integer", description: "Prompt ID"}}, required: ["id"]}, handler: :get }, "prompts_create" => { description: "Create a prompt", inputSchema: { type: "object", properties: { name: {type: "string"}, description: {type: "string"}, template: {type: "string"}, llm_model: {type: "string"}, tag_names: {type: "array", items: {type: "string"}} }, required: ["name", "template", "llm_model"] }, handler: :create }, "prompts_update" => { description: "Update a prompt", inputSchema: { type: "object", properties: { id: {type: "integer"}, name: {type: "string"}, description: {type: "string"}, template: {type: "string"}, llm_model: {type: "string"}, tag_names: {type: "array", items: {type: "string"}} }, required: ["id"] }, handler: :update }, "prompts_delete" => { description: "Delete a prompt", inputSchema: {type: "object", properties: {id: {type: "integer"}}, required: ["id"]}, handler: :delete }, "prompts_publish" => { description: "Publish a prompt version, making it the current version", inputSchema: {type: "object", properties: {id: {type: "integer"}}, required: ["id"]}, handler: :publish }, }.freeze
Class Method Summary collapse
- .create(args) ⇒ Object
- .delete(args) ⇒ Object
- .get(args) ⇒ Object
- .list(_args) ⇒ Object
- .publish(args) ⇒ Object
- .update(args) ⇒ Object
Methods included from Base
call, definitions, error_result, text_result
Class Method Details
.create(args) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'app/services/completion_kit/mcp_tools/prompts.rb', line 63 def self.create(args) prompt = Prompt.new(args.slice("name", "description", "template", "llm_model")) prompt.tag_names = args["tag_names"] if args.key?("tag_names") if prompt.save text_result(prompt.reload.as_json) else error_result(prompt.errors..join(", ")) end end |
.delete(args) ⇒ Object
89 90 91 92 |
# File 'app/services/completion_kit/mcp_tools/prompts.rb', line 89 def self.delete(args) Prompt.find(args["id"]).destroy! text_result("Prompt #{args["id"]} deleted") end |
.get(args) ⇒ Object
59 60 61 |
# File 'app/services/completion_kit/mcp_tools/prompts.rb', line 59 def self.get(args) text_result(Prompt.find(args["id"]).as_json) end |
.list(_args) ⇒ Object
55 56 57 |
# File 'app/services/completion_kit/mcp_tools/prompts.rb', line 55 def self.list(_args) text_result(Prompt.order(created_at: :desc).map(&:as_json)) end |
.publish(args) ⇒ Object
94 95 96 97 98 |
# File 'app/services/completion_kit/mcp_tools/prompts.rb', line 94 def self.publish(args) prompt = Prompt.find(args["id"]) prompt.publish! text_result(prompt.reload.as_json) end |
.update(args) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/services/completion_kit/mcp_tools/prompts.rb', line 73 def self.update(args) prompt = Prompt.find(args["id"]) attrs = args.except("id").slice("name", "description", "template", "llm_model") if prompt.runs.exists? new_prompt = prompt.clone_as_new_version(attrs) new_prompt.publish! new_prompt.update!(tag_names: args["tag_names"]) if args.key?("tag_names") text_result(new_prompt.reload.as_json) elsif prompt.update(attrs) prompt.update!(tag_names: args["tag_names"]) if args.key?("tag_names") text_result(prompt.reload.as_json) else error_result(prompt.errors..join(", ")) end end |