Module: Otto::MCP::Core
- Included in:
- Otto
- Defined in:
- lib/otto/mcp/core.rb
Overview
Core MCP (Model Context Protocol) methods included in the Otto class. Provides the public API for enabling and querying MCP server support.
Instance Method Summary collapse
-
#enable_mcp!(options = {}) ⇒ Object
Enable MCP (Model Context Protocol) server support.
-
#mcp_enabled? ⇒ Boolean
Check if MCP is enabled.
Instance Method Details
#enable_mcp!(options = {}) ⇒ Object
Enable MCP (Model Context Protocol) server support
Options are normalized by Otto::MCP::Server.normalize_options under the :explicit scope. That scope accepts the canonical keys below and their mcp_-prefixed spellings (:mcp_endpoint, :mcp_auth_tokens, ...), as String or Symbol keys, so one hash can feed both Otto.new and this method.
It is STRICT: any other key raises ArgumentError rather than being
ignored, so a typo such as enable_mcp!(auth_token: 'x') fails at boot
instead of quietly leaving the endpoint unauthenticated. That includes
the constructor-only gating keys (:mcp_enabled, :mcp_http, :mcp_stdio):
this method always enables the HTTP endpoint, so it cannot honour them.
36 37 38 39 40 41 42 |
# File 'lib/otto/mcp/core.rb', line 36 def enable_mcp!( = {}) ensure_not_frozen! @mcp_server ||= Otto::MCP::Server.new(self) @mcp_server.enable!(Otto::MCP::Server.()) Otto.logger.info '[MCP] Enabled MCP server' if Otto.debug end |
#mcp_enabled? ⇒ Boolean
Check if MCP is enabled
46 47 48 |
# File 'lib/otto/mcp/core.rb', line 46 def mcp_enabled? @mcp_server&.enabled? end |