Class: ShapeupCli::Client
- Inherits:
-
Object
- Object
- ShapeupCli::Client
- Defined in:
- lib/shapeup_cli/client.rb
Defined Under Namespace
Classes: ApiError, AuthError, NotFoundError, PermissionError, RateLimitError
Constant Summary collapse
- MCP_PROTOCOL_VERSION =
"2025-06-18"
Instance Method Summary collapse
-
#call_tool(name, **arguments) ⇒ Object
Call an MCP tool by name with arguments.
-
#initialize(host: Config.host, token: Auth.token) ⇒ Client
constructor
A new instance of Client.
-
#initialize_session ⇒ Object
Initialise the MCP session.
-
#list_resources ⇒ Object
List available resources.
-
#list_tools ⇒ Object
List available tools (useful for –agent –help introspection).
-
#read_resource(uri) ⇒ Object
Read a resource by URI.
Constructor Details
#initialize(host: Config.host, token: Auth.token) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 |
# File 'lib/shapeup_cli/client.rb', line 13 def initialize(host: Config.host, token: Auth.token) raise AuthError, "Not authenticated" unless token @host = host @token = token @request_id = 0 end |
Instance Method Details
#call_tool(name, **arguments) ⇒ Object
Call an MCP tool by name with arguments
31 32 33 |
# File 'lib/shapeup_cli/client.rb', line 31 def call_tool(name, **arguments) call_method("tools/call", name: name, arguments: arguments) end |
#initialize_session ⇒ Object
Initialise the MCP session
21 22 23 |
# File 'lib/shapeup_cli/client.rb', line 21 def initialize_session call_method("initialize", protocolVersion: MCP_PROTOCOL_VERSION) end |
#list_resources ⇒ Object
List available resources
36 37 38 |
# File 'lib/shapeup_cli/client.rb', line 36 def list_resources call_method("resources/list") end |
#list_tools ⇒ Object
List available tools (useful for –agent –help introspection)
26 27 28 |
# File 'lib/shapeup_cli/client.rb', line 26 def list_tools call_method("tools/list") end |
#read_resource(uri) ⇒ Object
Read a resource by URI
41 42 43 |
# File 'lib/shapeup_cli/client.rb', line 41 def read_resource(uri) call_method("resources/read", uri: uri) end |