Class: Sidekiq::Mcp::Tool
- Inherits:
-
Object
- Object
- Sidekiq::Mcp::Tool
show all
- Defined in:
- lib/sidekiq/mcp/tool.rb
Direct Known Subclasses
Sidekiq::Mcp::Tools::ClearQueueTool, Sidekiq::Mcp::Tools::DeadJobsTool, Sidekiq::Mcp::Tools::FailedJobsTool, Sidekiq::Mcp::Tools::JobClassStatsTool, Sidekiq::Mcp::Tools::JobDetailsTool, Sidekiq::Mcp::Tools::KillJobTool, Sidekiq::Mcp::Tools::ListRetryJobsTool, Sidekiq::Mcp::Tools::ListScheduledJobsTool, Sidekiq::Mcp::Tools::ProcessSetTool, Sidekiq::Mcp::Tools::QueueDetailsTool, Sidekiq::Mcp::Tools::QueueHealthTool, Sidekiq::Mcp::Tools::RemoveJobTool, Sidekiq::Mcp::Tools::RescheduleJobTool, Sidekiq::Mcp::Tools::RetryJobTool, Sidekiq::Mcp::Tools::SidekiqStatsTool, Sidekiq::Mcp::Tools::StreamStatsTool, Sidekiq::Mcp::Tools::WorkersCountTool
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Class Attribute Details
.argument_schema ⇒ Object
Returns the value of attribute argument_schema.
9
10
11
|
# File 'lib/sidekiq/mcp/tool.rb', line 9
def argument_schema
@argument_schema
end
|
Returns the value of attribute tool_description.
9
10
11
|
# File 'lib/sidekiq/mcp/tool.rb', line 9
def tool_description
@tool_description
end
|
Class Method Details
.arguments(&block) ⇒ Object
15
16
17
|
# File 'lib/sidekiq/mcp/tool.rb', line 15
def arguments(&block)
@argument_schema = Dry::Schema.Params(&block) if block_given?
end
|
.description(text) ⇒ Object
11
12
13
|
# File 'lib/sidekiq/mcp/tool.rb', line 11
def description(text)
@tool_description = text
end
|
.schema_to_json_schema ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/sidekiq/mcp/tool.rb', line 19
def schema_to_json_schema
return { type: "object", properties: {}, required: [] } unless @argument_schema
{
type: "object",
properties: {},
required: []
}
end
|
31
32
33
34
35
36
37
38
|
# File 'lib/sidekiq/mcp/tool.rb', line 31
def self.to_tool_definition
tool_name = name.split("::").last.gsub(/Tool$/, "").gsub(/([A-Z])/, '_\1').downcase.sub(/^_/, "")
{
name: tool_name,
description: @tool_description || "#{name} tool",
inputSchema: schema_to_json_schema
}
end
|
Instance Method Details
#call(**args) ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/sidekiq/mcp/tool.rb', line 40
def call(**args)
if self.class.argument_schema
result = self.class.argument_schema.call(args)
raise ArgumentError, "Invalid arguments: #{result.errors.to_h}" unless result.success?
args = result.to_h
end
perform(**args)
end
|
51
52
53
|
# File 'lib/sidekiq/mcp/tool.rb', line 51
def perform(**args)
raise NotImplementedError, "Subclasses must implement #perform"
end
|