Class: LinearToonMcp::Tools::Base
- Inherits:
-
MCP::Tool
- Object
- MCP::Tool
- LinearToonMcp::Tools::Base
- Defined in:
- lib/linear_toon_mcp/tools/base.rb
Overview
Base class for all MCP tools. Subclasses implement #perform; responses are TOON-encoded and Error is caught at the boundary. The Linear client is read from LinearToonMcp.client.
class ListTeams < Tools::List
description "..."
input_schema(...)
QUERY = "..."
end
Direct Known Subclasses
ArchiveProject, Create, Delete, DeleteStatusUpdate, Get, GetStatusUpdate, List, ListStatusUpdates, SaveComment, SaveInitiative, SaveIssue, SaveProject, SaveStatusUpdate
Class Method Summary collapse
-
.call(server_context: nil, **params) ⇒ MCP::Tool::Response
Entry point invoked by the MCP server.
-
.error_response(message) ⇒ MCP::Tool::Response
Returns an error MCP response carrying
message. -
.success_response(data) ⇒ MCP::Tool::Response
Returns a successful MCP response with TOON-encoded
data.
Instance Method Summary collapse
-
#call(**params) ⇒ Object
Runs the tool with validated parameters and returns the MCP response.
-
#perform ⇒ Object
Subclass hook.
Class Method Details
.call(server_context: nil, **params) ⇒ MCP::Tool::Response
23 24 25 26 27 |
# File 'lib/linear_toon_mcp/tools/base.rb', line 23 def call(server_context: nil, **params) new.call(**params) rescue Error => e error_response(e.) end |
.error_response(message) ⇒ MCP::Tool::Response
Returns an error MCP response carrying message.
37 38 39 |
# File 'lib/linear_toon_mcp/tools/base.rb', line 37 def error_response() MCP::Tool::Response.new([{type: "text", text: }], error: true) end |
.success_response(data) ⇒ MCP::Tool::Response
Returns a successful MCP response with TOON-encoded data.
31 32 33 |
# File 'lib/linear_toon_mcp/tools/base.rb', line 31 def success_response(data) MCP::Tool::Response.new([{type: "text", text: Toon.encode(data)}]) end |
Instance Method Details
#call(**params) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/linear_toon_mcp/tools/base.rb', line 46 def call(**params) result = perform(**params) result.is_a?(MCP::Tool::Response) ? result : self.class.success_response(result) rescue Error => e self.class.error_response(e.) end |
#perform ⇒ Object
Subclass hook. Returns the Ruby value to TOON-encode, or a pre-built MCP::Tool::Response.
55 56 57 |
# File 'lib/linear_toon_mcp/tools/base.rb', line 55 def perform(**) raise NotImplementedError, "#{self.class.name} must implement #perform" end |