Class: MCPClient::ServerBase

Inherits:
Object
  • Object
show all
Defined in:
lib/mcp_client/server_base.rb

Overview

Base class for MCP servers - serves as the interface for different server implementations

Direct Known Subclasses

ServerSSE, ServerStdio

Instance Method Summary collapse

Instance Method Details

#call_tool(tool_name, parameters) ⇒ Object

Call a tool with the given parameters

Parameters:

  • tool_name (String)

    the name of the tool to call

  • parameters (Hash)

    the parameters to pass to the tool

Returns:

  • (Object)

    the result of the tool invocation

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/mcp_client/server_base.rb', line 22

def call_tool(tool_name, parameters)
  raise NotImplementedError, 'Subclasses must implement call_tool'
end

#cleanupObject

Clean up the server connection

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/mcp_client/server_base.rb', line 27

def cleanup
  raise NotImplementedError, 'Subclasses must implement cleanup'
end

#connectBoolean

Initialize a connection to the MCP server

Returns:

  • (Boolean)

    true if connection successful

Raises:

  • (NotImplementedError)


8
9
10
# File 'lib/mcp_client/server_base.rb', line 8

def connect
  raise NotImplementedError, 'Subclasses must implement connect'
end

#list_toolsArray<MCPClient::Tool>

List all tools available from the MCP server

Returns:

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/mcp_client/server_base.rb', line 14

def list_tools
  raise NotImplementedError, 'Subclasses must implement list_tools'
end