Module: CompletionKit::McpTools::Base
- Included in:
- Agreements, Datasets, Imports, Judges, MetricGroups, MetricVersions, Metrics, Prompts, ProviderCredentials, Responses, Runs, Tags
- Defined in:
- app/services/completion_kit/mcp_tools/base.rb
Constant Summary collapse
- DEFAULT_PAGE_LIMIT =
50- MAX_PAGE_LIMIT =
500
Instance Method Summary collapse
- #call(name, arguments) ⇒ Object
- #definitions ⇒ Object
- #error_result(message) ⇒ Object
- #page_bounds(args) ⇒ Object
- #text_result(data) ⇒ Object
Instance Method Details
#call(name, arguments) ⇒ Object
20 21 22 23 |
# File 'app/services/completion_kit/mcp_tools/base.rb', line 20 def call(name, arguments) tool = self::TOOLS.fetch(name) send(tool[:handler], arguments) end |
#definitions ⇒ Object
16 17 18 |
# File 'app/services/completion_kit/mcp_tools/base.rb', line 16 def definitions self::TOOLS.map { |name, config| {name: name, description: config[:description], inputSchema: config[:inputSchema]} } end |
#error_result(message) ⇒ Object
30 31 32 |
# File 'app/services/completion_kit/mcp_tools/base.rb', line 30 def error_result() {content: [{type: "text", text: }], isError: true} end |
#page_bounds(args) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'app/services/completion_kit/mcp_tools/base.rb', line 7 def page_bounds(args) limit = args["limit"].to_i limit = DEFAULT_PAGE_LIMIT if limit <= 0 limit = MAX_PAGE_LIMIT if limit > MAX_PAGE_LIMIT offset = args["offset"].to_i offset = 0 if offset < 0 [limit, offset] end |
#text_result(data) ⇒ Object
25 26 27 28 |
# File 'app/services/completion_kit/mcp_tools/base.rb', line 25 def text_result(data) text = data.is_a?(String) ? data : data.to_json {content: [{type: "text", text: text}]} end |