Class: HotwireClub::MCP::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/hotwire_club/mcp/server.rb

Overview

MCP Server for Hotwire Club knowledge base

This server provides MCP tools for searching and browsing the knowledge base. It wraps a FastMcp::Server and registers all the required tools.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container: nil, adapter: nil, name: "hotwire-club-mcp", version: VERSION) ⇒ Server

Initialize the MCP server

Parameters:

  • container (ROM::Container, nil) (defaults to: nil)

    ROM container instance

  • adapter (Database::Adapter, nil) (defaults to: nil)

    Database adapter instance

  • name (String) (defaults to: "hotwire-club-mcp")

    Server name (default: "hotwire-club-mcp")

  • version (String) (defaults to: VERSION)

    Server version (default: HotwireClub::MCP::VERSION)



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/hotwire_club/mcp/server.rb', line 20

def initialize(container: nil, adapter: nil, name: "hotwire-club-mcp", version: VERSION)
  if adapter
    @adapter = adapter
    @container = adapter.instance_variable_get(:@container)
  elsif container
    @container = container
    @adapter = Database::Adapter.new(container: container)
  else
    raise ArgumentError, "Either container: or adapter: must be provided"
  end
  @fast_mcp_server = ::FastMcp::Server.new(name: name, version: version)
  register_tools
end

Instance Attribute Details

#fast_mcp_serverFastMcp::Server (readonly)

Get the underlying FastMcp server instance

Returns:

  • (FastMcp::Server)

    FastMcp server instance



37
38
39
# File 'lib/hotwire_club/mcp/server.rb', line 37

def fast_mcp_server
  @fast_mcp_server
end

Instance Method Details

#runObject

Run the MCP server (alias for start to match pseudocode API)



45
46
47
# File 'lib/hotwire_club/mcp/server.rb', line 45

def run
  start
end

#startObject

Start the MCP server (delegates to FastMcp server)



40
41
42
# File 'lib/hotwire_club/mcp/server.rb', line 40

def start
  @fast_mcp_server.start
end

#toolsHash

Get all registered tools

Returns:

  • (Hash)

    Hash of tool names to tool classes



52
53
54
# File 'lib/hotwire_club/mcp/server.rb', line 52

def tools
  @fast_mcp_server.tools
end