Method: MCPClient::ServerSSE#list_tools
- Defined in:
- lib/mcp_client/server_sse.rb
#list_tools ⇒ Array<MCPClient::Tool>
List all tools available from the MCP server
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/mcp_client/server_sse.rb', line 68 def list_tools @mutex.synchronize do return @tools if @tools end ensure_initialized begin tools_data = request_tools_list @mutex.synchronize do @tools = tools_data.map do |tool_data| MCPClient::Tool.from_json(tool_data) end end @mutex.synchronize { @tools } rescue MCPClient::Errors::TransportError # Re-raise TransportError directly raise rescue JSON::ParserError => e raise MCPClient::Errors::TransportError, "Invalid JSON response from server: #{e.}" rescue StandardError => e raise MCPClient::Errors::ToolCallError, "Error listing tools: #{e.}" end end |