Class: Toolchest::App

Inherits:
Object
  • Object
show all
Defined in:
lib/toolchest/app.rb

Overview

Rack app for a named mount. Used for multi-mount:

mount Toolchest.app(:admin) => "/admin-mcp"

Handles OAuth routes (authorize, token, register, authorized_applications) and delegates everything else to the MCP transport (RackApp).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mount_key = :default) ⇒ App

Returns a new instance of App.



12
13
14
15
# File 'lib/toolchest/app.rb', line 12

def initialize(mount_key = :default)
  @mount_key = mount_key.to_sym
  @router = build_action_dispatch_router
end

Instance Attribute Details

#mount_keyObject (readonly)

Returns the value of attribute mount_key.



10
11
12
# File 'lib/toolchest/app.rb', line 10

def mount_key
  @mount_key
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/toolchest/app.rb', line 17

def call(env)
  Engine.ensure_initialized!
  env["toolchest.mount_key"] = @mount_key.to_s

  cfg = Toolchest.configuration(@mount_key)
  if cfg.mount_path.nil? && env["SCRIPT_NAME"].present?
    cfg.mount_path = env["SCRIPT_NAME"]
  end

  @router.call(env)
end