Module: Html2rss::MCP::Server
- Defined in:
- lib/html2rss/mcp/server.rb
Overview
Thin MCP wire adapter over public html2rss APIs.
Ownership: scraping/capture/validate/feed stay on gem entrypoints (Html2rss.auto_feed_result, Capture.build, Config.validate, Html2rss.feed_result). This module maps MCP kwargs to those APIs, then Outcome + Contract shape the envelope.
Strategy note: MCP auto passes through to FeedPipeline AutoFallback
(faraday → botasaurus). Concrete strategies are used as-is.
Botasaurus requires BOTASAURUS_SCRAPER_URL.
Constant Summary collapse
- SERVER_NAME =
MCP server display name.
'html2rss'- SERVER_VERSION =
MCP server version (mirrors the gem version).
Html2rss::VERSION
- HTTP_BIND_HOST =
Loopback bind for HTTP transport (local use only).
'127.0.0.1'
Class Method Summary collapse
-
.build ⇒ ::MCP::Server
Builds the configured MCP protocol server (tools/resources/prompts).
-
.start(transport: :stdio, port: 8080) ⇒ Object
Starts the MCP server with the given transport.
Class Method Details
.build ⇒ ::MCP::Server
Builds the configured MCP protocol server (tools/resources/prompts).
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/html2rss/mcp/server.rb', line 48 def build # rubocop:disable Metrics/MethodLength -- protocol server construction ::MCP::Server.new( name: SERVER_NAME, title: SERVER_NAME, version: SERVER_VERSION, instructions: instructions_text, configuration: protocol_configuration ).tap do |server| register_tools(server) register_resources(server) register_prompts(server) end end |
.start(transport: :stdio, port: 8080) ⇒ Object
Starts the MCP server with the given transport.
Points Html2rss.logger at $stderr so stdio JSON-RPC on stdout stays
intact, and raises the process log level to info unless LOG_LEVEL is set.
A foreground watcher then sees the start banner, tool calls, and pipeline warns.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/html2rss/mcp/server.rb', line 33 def start(transport: :stdio, port: 8080) raise ArgumentError, "Unknown transport: #{transport.inspect}" unless %i[stdio http].include?(transport) configure_daemon_logging! app = build Log.info((transport:, port:)) return start_http(app, port:) if transport == :http ::MCP::Server::Transports::StdioTransport.new(app).open end |