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_json_feed, Capture.build, Config.validate, Html2rss.feed). This module only maps MCP kwargs ↔ those APIs and shapes Tool::Response.
Strategy note: MCP auto passes through to FeedPipeline AutoFallback
(faraday → botasaurus). Concrete strategies are used as-is.
Botasaurus requires BOTASAURUS_SCRAPER_URL.
Defined Under Namespace
Modules: Inspect
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).
- .error_response(error) ⇒ ::MCP::Tool::Response
-
.resolve_mcp_strategy(strategy) ⇒ Symbol
Maps MCP strategy shortcut to a feed-level strategy plan.
-
.start(transport: :stdio, port: 8080) ⇒ Object
Starts the MCP server with the given transport.
- .text_response(text, error: false, meta: nil) ⇒ ::MCP::Tool::Response
Class Method Details
.build ⇒ ::MCP::Server
Builds the configured MCP protocol server (tools/resources/prompts).
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/html2rss/mcp/server.rb', line 46 def build ::MCP::Server.new( name: SERVER_NAME, version: SERVER_VERSION, instructions: instructions_text ).tap do |server| register_tools(server) register_resources(server) register_prompts(server) end end |
.error_response(error) ⇒ ::MCP::Tool::Response
81 82 83 |
# File 'lib/html2rss/mcp/server.rb', line 81 def error_response(error) text_response("Error: #{error.}", error: true) end |
.resolve_mcp_strategy(strategy) ⇒ Symbol
Maps MCP strategy shortcut to a feed-level strategy plan.
:auto passes through as :auto so the FeedPipeline's AutoFallback
chain (faraday → botasaurus) is triggered for JS-rendered sites.
65 66 67 |
# File 'lib/html2rss/mcp/server.rb', line 65 def resolve_mcp_strategy(strategy) (strategy || :auto).to_sym end |
.start(transport: :stdio, port: 8080) ⇒ Object
Starts the MCP server with the given transport.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/html2rss/mcp/server.rb', line 29 def start(transport: :stdio, port: 8080) app = build case transport when :stdio ::MCP::Server::Transports::StdioTransport.new(app).open when :http start_http(app, port:) else raise ArgumentError, "Unknown transport: #{transport.inspect}" end end |
.text_response(text, error: false, meta: nil) ⇒ ::MCP::Tool::Response
74 75 76 |
# File 'lib/html2rss/mcp/server.rb', line 74 def text_response(text, error: false, meta: nil) ::MCP::Tool::Response.new([{ type: 'text', text: }], error:, meta:) end |