Class: Rubydex::MCPServer::Tool
- Inherits:
-
Object
- Object
- Rubydex::MCPServer::Tool
- Defined in:
- lib/rubydex/mcp_server/protocol.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Response
Class Attribute Summary collapse
-
.tools ⇒ Object
readonly
Returns the value of attribute tools.
Class Method Summary collapse
-
.description(value = nil) ⇒ Object
: (?String) -> String.
-
.inherited(tool) ⇒ Object
: (Class) -> void.
-
.input_schema(properties: nil, required: nil) ⇒ Object
: (?Hash, ?Array) -> Hash.
-
.to_h ⇒ Object
: -> Hash.
-
.tool_name(value = nil) ⇒ Object
: (?String) -> String.
-
.tools_by_name ⇒ Object
: -> Hash[String, Class].
Class Attribute Details
.tools ⇒ Object (readonly)
Returns the value of attribute tools.
74 75 76 |
# File 'lib/rubydex/mcp_server/protocol.rb', line 74 def tools @tools end |
Class Method Details
.description(value = nil) ⇒ Object
: (?String) -> String
94 95 96 97 |
# File 'lib/rubydex/mcp_server/protocol.rb', line 94 def description(value = nil) @description = value if value @description || raise(NotImplementedError, "#{name} must define description") end |
.inherited(tool) ⇒ Object
: (Class) -> void
77 78 79 80 |
# File 'lib/rubydex/mcp_server/protocol.rb', line 77 def inherited(tool) Tool.tools << tool unless tool.name&.end_with?("::BaseTool") super end |
.input_schema(properties: nil, required: nil) ⇒ Object
: (?Hash, ?Array) -> Hash
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/rubydex/mcp_server/protocol.rb', line 100 def input_schema(properties: nil, required: nil) if properties @input_schema = { type: "object", properties: properties, } @input_schema[:required] = required if required end @input_schema || { type: "object", properties: {} } end |
.to_h ⇒ Object
: -> Hash
113 114 115 116 117 118 119 |
# File 'lib/rubydex/mcp_server/protocol.rb', line 113 def to_h { name: tool_name, description: description, inputSchema: input_schema, } end |
.tool_name(value = nil) ⇒ Object
: (?String) -> String
88 89 90 91 |
# File 'lib/rubydex/mcp_server/protocol.rb', line 88 def tool_name(value = nil) @tool_name = value if value @tool_name || raise(NotImplementedError, "#{name} must define tool_name") end |
.tools_by_name ⇒ Object
: -> Hash[String, Class]
83 84 85 |
# File 'lib/rubydex/mcp_server/protocol.rb', line 83 def tools_by_name tools.to_h { |tool| [tool.tool_name, tool] } end |