Class: McpAuthorization::Configuration
- Inherits:
-
Object
- Object
- McpAuthorization::Configuration
- Defined in:
- lib/mcp_authorization/configuration.rb
Overview
Holds gem-wide settings. A single global instance is created lazily by McpAuthorization.configuration and configured in a Rails initializer:
McpAuthorization.configure do |c|
c.server_name = "my-app"
c.server_version = MyApp::VERSION
c.tool_paths = %w[app/mcp]
c.context_builder = ->(request) { ... }
end
Required settings
context_builder must be set before the first MCP request. Everything else has sensible defaults.
The context contract
Both context_builder and cli_context_builder must return an object whose current_user responds to:
current_user.can?(:symbol) # required — gates field/tool visibility
current_user.default_for(:symbol) # optional — populates @default_for tags
Instance Attribute Summary collapse
-
#cli_context_builder ⇒ Object
Lambda that builds a server context for CLI/rake usage.
-
#context_builder ⇒ Object
Lambda that builds a server context from a Rack request.
-
#default_domain ⇒ Object
Domain name used when the request URL has no
:domainsegment. -
#mount_path ⇒ Object
URL prefix where the Engine mounts its routes.
-
#server_name ⇒ Object
Server name reported in the MCP
initializehandshake. -
#server_version ⇒ Object
Server version reported in the MCP
initializehandshake. -
#shared_type_paths ⇒ Object
Directories (relative to
Rails.root) where shared.rbstype files live. -
#strict_schema ⇒ Object
When true, strips JSON Schema keywords that cause 400 errors in Anthropic’s strict tool use mode (minLength, maximum, maxItems, etc.) and adds additionalProperties: false to all objects.
-
#tool_paths ⇒ Object
Directories (relative to
Rails.root) that contain tool classes.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
: () -> void.
Constructor Details
#initialize ⇒ Configuration
: () -> void
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/mcp_authorization/configuration.rb', line 69 def initialize @server_name = "mcp-authorization" @server_version = "1.0.0" @tool_paths = %w[app/mcp] @shared_type_paths = %w[sig/shared] @default_domain = "default" @mount_path = "/mcp" @context_builder = nil @cli_context_builder = nil @strict_schema = false end |
Instance Attribute Details
#cli_context_builder ⇒ Object
Lambda that builds a server context for CLI/rake usage. Same duck-type contract as context_builder. : (^(domain: String, role: String) -> untyped)?
60 61 62 |
# File 'lib/mcp_authorization/configuration.rb', line 60 def cli_context_builder @cli_context_builder end |
#context_builder ⇒ Object
Lambda that builds a server context from a Rack request. The returned object must satisfy the context contract above. : (^(untyped) -> untyped)?
55 56 57 |
# File 'lib/mcp_authorization/configuration.rb', line 55 def context_builder @context_builder end |
#default_domain ⇒ Object
Domain name used when the request URL has no :domain segment. : String
46 47 48 |
# File 'lib/mcp_authorization/configuration.rb', line 46 def default_domain @default_domain end |
#mount_path ⇒ Object
URL prefix where the Engine mounts its routes. : String
50 51 52 |
# File 'lib/mcp_authorization/configuration.rb', line 50 def mount_path @mount_path end |
#server_name ⇒ Object
Server name reported in the MCP initialize handshake. : String
28 29 30 |
# File 'lib/mcp_authorization/configuration.rb', line 28 def server_name @server_name end |
#server_version ⇒ Object
Server version reported in the MCP initialize handshake. : String
32 33 34 |
# File 'lib/mcp_authorization/configuration.rb', line 32 def server_version @server_version end |
#shared_type_paths ⇒ Object
Directories (relative to Rails.root) where shared .rbs type files live. Used by RbsSchemaCompiler to resolve # @rbs import. : Array
42 43 44 |
# File 'lib/mcp_authorization/configuration.rb', line 42 def shared_type_paths @shared_type_paths end |
#strict_schema ⇒ Object
When true, strips JSON Schema keywords that cause 400 errors in Anthropic’s strict tool use mode (minLength, maximum, maxItems, etc.) and adds additionalProperties: false to all objects. : bool
66 67 68 |
# File 'lib/mcp_authorization/configuration.rb', line 66 def strict_schema @strict_schema end |
#tool_paths ⇒ Object
Directories (relative to Rails.root) that contain tool classes. Added to autoload_paths and eager_load_paths by the Engine. : Array
37 38 39 |
# File 'lib/mcp_authorization/configuration.rb', line 37 def tool_paths @tool_paths end |