Module: Pgbus::MCP
- Defined in:
- lib/pgbus/mcp.rb,
lib/pgbus/mcp/runner.rb,
lib/pgbus/mcp/server.rb,
lib/pgbus/mcp/rack_app.rb,
lib/pgbus/mcp/redactor.rb,
lib/pgbus/mcp/base_tool.rb,
lib/pgbus/mcp/tools/dlq_tool.rb,
lib/pgbus/mcp/health_analyzer.rb,
lib/pgbus/mcp/tools/jobs_tool.rb,
lib/pgbus/mcp/tools/locks_tool.rb,
lib/pgbus/mcp/tools/stats_tool.rb,
lib/pgbus/mcp/tools/health_tool.rb,
lib/pgbus/mcp/tools/queues_tool.rb,
lib/pgbus/mcp/tools/processes_tool.rb,
lib/pgbus/mcp/tools/recurring_tool.rb,
lib/pgbus/mcp/tools/dlq_detail_tool.rb,
lib/pgbus/mcp/tools/job_detail_tool.rb,
lib/pgbus/mcp/tools/throughput_tool.rb,
lib/pgbus/mcp/tools/queue_detail_tool.rb
Overview
Optional read-only MCP (Model Context Protocol) diagnostic server.
This namespace is deliberately kept out of pgbus's Zeitwerk loader because
its tool classes subclass MCP::Tool from the optional mcp gem.
Referencing that gem at autoload time would force every pgbus user to
install it. Instead the subsystem is loaded explicitly via MCP.load!, which
is called by the pgbus mcp CLI command (and by specs).
Defined Under Namespace
Modules: Redactor, Runner, Server, Tools Classes: BaseTool, HealthAnalyzer, RackApp
Constant Summary collapse
- REQUIRES =
Files in dependency order: the gem first, then the base classes the tools depend on, then the tools, then the server/runner.
%w[ pgbus/mcp/redactor pgbus/mcp/base_tool pgbus/mcp/health_analyzer pgbus/mcp/tools/health_tool pgbus/mcp/tools/queues_tool pgbus/mcp/tools/queue_detail_tool pgbus/mcp/tools/processes_tool pgbus/mcp/tools/jobs_tool pgbus/mcp/tools/job_detail_tool pgbus/mcp/tools/dlq_tool pgbus/mcp/tools/dlq_detail_tool pgbus/mcp/tools/locks_tool pgbus/mcp/tools/throughput_tool pgbus/mcp/tools/stats_tool pgbus/mcp/tools/recurring_tool pgbus/mcp/server pgbus/mcp/runner pgbus/mcp/rack_app ].freeze
Class Method Summary collapse
-
.load! ⇒ Object
Require the
mcpgem and the whole pgbus MCP subsystem. -
.rack_app(data_source: Pgbus::Web::DataSource.new, allow_payloads: false, token: nil, auth: nil) ⇒ Object
Build a gated Rack app serving the read-only diagnostic tools over HTTP.
Class Method Details
.load! ⇒ Object
Require the mcp gem and the whole pgbus MCP subsystem. Idempotent.
Raises Pgbus::Error with an actionable message if the gem is missing.
Only the require "mcp" is wrapped — a LoadError from an internal
pgbus/mcp/... path (typo, missing file) propagates verbatim so the
real broken require shows up in the message instead of being masked
as "add gem mcp".
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/pgbus/mcp.rb', line 44 def load! begin require "mcp" rescue LoadError raise Pgbus::Error, "The pgbus MCP server requires the `mcp` gem. Add `gem \"mcp\"` to your Gemfile and run `bundle install`." end REQUIRES.each { |path| require path } end |
.rack_app(data_source: Pgbus::Web::DataSource.new, allow_payloads: false, token: nil, auth: nil) ⇒ Object
Build a gated Rack app serving the read-only diagnostic tools over HTTP. See RackApp for the parameters and deployment guidance.
93 94 95 |
# File 'lib/pgbus/mcp/rack_app.rb', line 93 def rack_app(data_source: Pgbus::Web::DataSource.new, allow_payloads: false, token: nil, auth: nil) RackApp.new(data_source: data_source, allow_payloads: allow_payloads, token: token, auth: auth) end |