Class: Mcp::HealthCheck
- Inherits:
-
Object
- Object
- Mcp::HealthCheck
- Defined in:
- lib/mcp/health_check.rb
Overview
Probes an MCP server to verify connectivity and count available tools. Used by the CLI list command to show server health status.
Constant Summary collapse
- TIMEOUT =
Health check probe timeout in seconds. Balances responsiveness (CLI shouldn’t hang) vs. giving slow servers a fair chance.
5
Class Method Summary collapse
-
.call(server) ⇒ Hash
{ status: :connected, tools: Integer } or { status: :failed, error: String }.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(server) ⇒ HealthCheck
constructor
A new instance of HealthCheck.
Constructor Details
#initialize(server) ⇒ HealthCheck
Returns a new instance of HealthCheck.
25 26 27 28 |
# File 'lib/mcp/health_check.rb', line 25 def initialize(server) @server = server @stdio_transport = nil end |
Class Method Details
.call(server) ⇒ Hash
Returns { status: :connected, tools: Integer } or { status: :failed, error: String }.
21 22 23 |
# File 'lib/mcp/health_check.rb', line 21 def self.call(server) new(server).call end |
Instance Method Details
#call ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/mcp/health_check.rb', line 30 def call Timeout.timeout(TIMEOUT) { check } rescue Timeout::Error {status: :failed, error: "connection timeout"} rescue KeyError => key_error {status: :failed, error: "missing credential #{key_error.}"} rescue => error {status: :failed, error: error.} end |