Module: TalkToYourApp::Transport::RailsMount

Defined in:
lib/talk_to_your_app/transport/rails_mount.rb

Overview

Builds the Rack application the host app mounts. It assembles an MCP::Server from the enabled plugins’ tools, wraps it in the SDK’s Streamable HTTP transport, and fronts the whole thing with the auth middleware. The session layer lives entirely in the SDK transport, so a future stateless flip (2026-07-28 RC) is a one-line change here.

Class Method Summary collapse

Class Method Details

.buildObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/talk_to_your_app/transport/rails_mount.rb', line 16

def build
  config = TalkToYourApp.configuration
  server = MCP::Server.new(
    name: config.server_name,
    title: config.server_title,
    version: config.server_version,
    description: config.server_description,
    instructions: config.instructions,
    tools: collect_tools,
  )
  transport = MCP::Server::Transports::StreamableHTTPTransport.new(
    server,
    enable_json_response: true,
  )
  Auth::Middleware.new(transport)
end

.collect_toolsObject

Compiles every enabled plugin’s tools into MCP::Tool subclasses, each audit-wrapped with its plugin name and (optional) per-plugin log level.



35
36
37
38
39
40
41
42
43
# File 'lib/talk_to_your_app/transport/rails_mount.rb', line 35

def collect_tools
  TalkToYourApp.enabled_plugins.flat_map do |name, plugin_class, _opts|
    next [] unless plugin_class

    plugin_class.tools.map do |tool_class|
      tool_class.to_mcp_tool(plugin_name: name, log_level: plugin_class.log_level)
    end
  end
end