Class: McpAuthorization::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/mcp_authorization/engine.rb

Overview

Rails Engine that wires the gem into a host application.

The engine handles three things automatically so the host app doesn’t have to:

  1. *Autoload paths* — tool directories (default app/mcp) are added to the Rails autoloader so tool and handler classes are discovered without explicit requires.

  2. *Cache invalidation* — on code reload (development mode) the ToolRegistry and RbsSchemaCompiler caches are cleared. Tools re-register themselves via the inherited hook when their classes are reloaded.

  3. *Route mounting* — MCP endpoints are prepended to the host app’s router at config.mount_path (default /mcp). The routes support multi-domain routing via an optional :domain segment:

    POST /mcp              → default domain
    POST /mcp/operator     → "operator" domain
    POST /mcp/recruiting   → "recruiting" domain
    

    All three HTTP methods required by the MCP StreamableHTTP transport (GET, POST, DELETE) are accepted.