Class: ActiveMcp::Server
- Inherits:
-
Object
- Object
- ActiveMcp::Server
- Defined in:
- lib/active_mcp/server.rb,
lib/active_mcp/server/tool_manager.rb,
lib/active_mcp/server/protocol_handler.rb
Defined Under Namespace
Classes: ProtocolHandler, ToolManager
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#protocol_handler ⇒ Object
readonly
Returns the value of attribute protocol_handler.
-
#tool_manager ⇒ Object
readonly
Returns the value of attribute tool_manager.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(version: ActiveMcp::VERSION, name: "ActiveMcp", uri: nil, auth: nil) ⇒ Server
constructor
A new instance of Server.
- #initialized ⇒ Object
- #serve(connection) ⇒ Object
- #serve_stdio ⇒ Object
- #start ⇒ Object
- #tools ⇒ Object
Constructor Details
#initialize(version: ActiveMcp::VERSION, name: "ActiveMcp", uri: nil, auth: nil) ⇒ Server
Returns a new instance of Server.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_mcp/server.rb', line 13 def initialize( version: ActiveMcp::VERSION, name: "ActiveMcp", uri: nil, auth: nil ) @name = name @version = version @uri = uri @tool_manager = ToolManager.new(uri: uri, auth:) @protocol_handler = ProtocolHandler.new(self) @tool_manager.load_registered_tools end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/active_mcp/server.rb', line 11 def name @name end |
#protocol_handler ⇒ Object (readonly)
Returns the value of attribute protocol_handler.
11 12 13 |
# File 'lib/active_mcp/server.rb', line 11 def protocol_handler @protocol_handler end |
#tool_manager ⇒ Object (readonly)
Returns the value of attribute tool_manager.
11 12 13 |
# File 'lib/active_mcp/server.rb', line 11 def tool_manager @tool_manager end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
11 12 13 |
# File 'lib/active_mcp/server.rb', line 11 def uri @uri end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
11 12 13 |
# File 'lib/active_mcp/server.rb', line 11 def version @version end |
Instance Method Details
#initialized ⇒ Object
47 48 49 |
# File 'lib/active_mcp/server.rb', line 47 def initialized @protocol_handler.initialized end |
#serve(connection) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/active_mcp/server.rb', line 35 def serve(connection) loop do = connection. break if .nil? response = @protocol_handler.() next if response.nil? connection.(response) end end |
#serve_stdio ⇒ Object
31 32 33 |
# File 'lib/active_mcp/server.rb', line 31 def serve_stdio serve(StdioConnection.new) end |
#start ⇒ Object
27 28 29 |
# File 'lib/active_mcp/server.rb', line 27 def start serve_stdio end |
#tools ⇒ Object
51 52 53 |
# File 'lib/active_mcp/server.rb', line 51 def tools @tool_manager.tools end |