Class: Otto::MCP::Server
- Inherits:
-
Object
- Object
- Otto::MCP::Server
- Defined in:
- lib/otto/mcp/server.rb
Overview
MCP server implementation providing Model Context Protocol endpoints
Instance Attribute Summary collapse
-
#otto_instance ⇒ Object
readonly
Returns the value of attribute otto_instance.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
Instance Method Summary collapse
- #enable!(options = {}) ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(otto_instance) ⇒ Server
constructor
A new instance of Server.
- #register_mcp_route(route_info) ⇒ Object
Constructor Details
Instance Attribute Details
#otto_instance ⇒ Object (readonly)
Returns the value of attribute otto_instance.
16 17 18 |
# File 'lib/otto/mcp/server.rb', line 16 def otto_instance @otto_instance end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
16 17 18 |
# File 'lib/otto/mcp/server.rb', line 16 def protocol @protocol end |
Instance Method Details
#enable!(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/otto/mcp/server.rb', line 24 def enable!( = {}) @enabled = true @http_endpoint = .fetch(:http_endpoint, '/_mcp') @auth_tokens = [:auth_tokens] || [] @enable_validation = .fetch(:enable_validation, true) @enable_rate_limiting = .fetch(:enable_rate_limiting, true) # Configure middleware configure_middleware() # Add MCP endpoint route to Otto add_mcp_endpoint_route Otto.logger.info "[MCP] Server enabled with HTTP endpoint: #{@http_endpoint}" if Otto.debug end |
#enabled? ⇒ Boolean
40 41 42 |
# File 'lib/otto/mcp/server.rb', line 40 def enabled? @enabled end |
#register_mcp_route(route_info) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/otto/mcp/server.rb', line 44 def register_mcp_route(route_info) case route_info[:type] when :mcp_resource register_resource(route_info) when :mcp_tool register_tool(route_info) end end |