Module: BSV::MCP::Server

Defined in:
lib/bsv/mcp/server.rb

Overview

Builds and returns an MCP::Server instance configured for the BSV SDK.

Tools are registered here as the feature set grows. Currently returns an empty tool list — Tasks 2 and 3 will add concrete tools.

Logging goes to $stderr only; $stdout is the MCP protocol channel.

Class Method Summary collapse

Class Method Details

.build(config = nil) ⇒ ::MCP::Server

Builds the MCP::Server instance with the given config.

Parameters:

  • config (BSV::MCP::Config) (defaults to: nil)

    network and ARC configuration

Returns:

  • (::MCP::Server)


18
19
20
21
22
23
24
25
26
27
# File 'lib/bsv/mcp/server.rb', line 18

def self.build(config = nil)
  config ||= Config.new

  ::MCP::Server.new(
    name: 'bsv-sdk',
    version: BSV::VERSION,
    instructions: server_instructions(config),
    tools: registered_tools
  )
end

.registered_toolsArray<Class>

Returns the list of tool classes registered with this server.

Returns:

  • (Array<Class>)

    tool classes inheriting from MCP::Tool



32
33
34
35
36
37
38
39
40
41
# File 'lib/bsv/mcp/server.rb', line 32

def self.registered_tools
  [
    Tools::GenerateKey,
    Tools::DecodeTx,
    Tools::FetchUtxos,
    Tools::FetchTx,
    Tools::CheckBalance,
    Tools::BroadcastP2pkh
  ]
end

.start(config = nil) ⇒ Object

Starts the MCP server over stdio using the standard StdioTransport. Blocks until the client disconnects or the process is interrupted.

Parameters:

  • config (BSV::MCP::Config) (defaults to: nil)

    network and ARC configuration



47
48
49
50
51
52
53
54
55
# File 'lib/bsv/mcp/server.rb', line 47

def self.start(config = nil)
  config ||= Config.new

  warn "BSV MCP server starting (network: #{config.network}, version: #{BSV::VERSION})"

  server = build(config)
  transport = ::MCP::Server::Transports::StdioTransport.new(server)
  transport.open
end