Class: ActiveMcp::Server
- Inherits:
-
Object
- Object
- ActiveMcp::Server
- Defined in:
- lib/active_mcp/server.rb,
lib/active_mcp/server/fetcher.rb,
lib/active_mcp/server/protocol_handler.rb
Defined Under Namespace
Classes: Fetcher, Logger, ProtocolHandler
Instance Attribute Summary collapse
-
#fetcher ⇒ Object
readonly
Returns the value of attribute fetcher.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#protocol_handler ⇒ Object
readonly
Returns the value of attribute protocol_handler.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #fetch(params:) ⇒ Object
-
#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.
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/active_mcp/server.rb', line 40 def initialize( version: ActiveMcp::VERSION, name: "ActiveMcp", uri: nil, auth: nil ) @name = name @version = version @uri = uri @fetcher = Fetcher.new(base_uri: uri, auth:) @protocol_handler = ProtocolHandler.new(self) end |
Instance Attribute Details
#fetcher ⇒ Object (readonly)
Returns the value of attribute fetcher.
38 39 40 |
# File 'lib/active_mcp/server.rb', line 38 def fetcher @fetcher end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
38 39 40 |
# File 'lib/active_mcp/server.rb', line 38 def name @name end |
#protocol_handler ⇒ Object (readonly)
Returns the value of attribute protocol_handler.
38 39 40 |
# File 'lib/active_mcp/server.rb', line 38 def protocol_handler @protocol_handler end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
38 39 40 |
# File 'lib/active_mcp/server.rb', line 38 def uri @uri end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
38 39 40 |
# File 'lib/active_mcp/server.rb', line 38 def version @version end |
Class Method Details
.log_error(message, error) ⇒ Object
33 34 35 |
# File 'lib/active_mcp/server.rb', line 33 def log_error(, error) logger.log(, error) end |
Instance Method Details
#fetch(params:) ⇒ Object
53 54 55 |
# File 'lib/active_mcp/server.rb', line 53 def fetch(params:) @fetcher.call(params:) end |
#initialized ⇒ Object
77 78 79 |
# File 'lib/active_mcp/server.rb', line 77 def initialized @protocol_handler.initialized end |
#serve(connection) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/active_mcp/server.rb', line 65 def serve(connection) loop do = connection. break if .nil? response = @protocol_handler.() next if response.nil? connection.(response) end end |
#serve_stdio ⇒ Object
61 62 63 |
# File 'lib/active_mcp/server.rb', line 61 def serve_stdio serve(StdioConnection.new) end |
#start ⇒ Object
57 58 59 |
# File 'lib/active_mcp/server.rb', line 57 def start serve_stdio end |
#tools ⇒ Object
81 82 83 |
# File 'lib/active_mcp/server.rb', line 81 def tools @tool_manager.tools end |