Class: ModelContextProtocol::Server
- Inherits:
-
Object
- Object
- ModelContextProtocol::Server
- Defined in:
- lib/model_context_protocol/server.rb,
lib/model_context_protocol/server/redis_client_proxy.rb
Defined Under Namespace
Modules: Cancellable, Content, ContentHelpers, Progressable Classes: Completion, Configuration, MCPLogger, NullCompletion, Pagination, ParameterValidationError, Prompt, RedisClientProxy, RedisConfig, RedisPoolManager, Registry, Resource, ResourceTemplate, ResponseArgumentsError, Router, StdioTransport, StreamableHttpTransport, Tool
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#router ⇒ Object
readonly
Returns the value of attribute router.
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize {|@configuration| ... } ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
Constructor Details
#initialize {|@configuration| ... } ⇒ Server
Returns a new instance of Server.
13 14 15 16 17 18 |
# File 'lib/model_context_protocol/server.rb', line 13 def initialize @configuration = Configuration.new yield(@configuration) if block_given? @router = Router.new(configuration:) map_handlers end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
11 12 13 |
# File 'lib/model_context_protocol/server.rb', line 11 def configuration @configuration end |
#router ⇒ Object (readonly)
Returns the value of attribute router.
11 12 13 |
# File 'lib/model_context_protocol/server.rb', line 11 def router @router end |
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
11 12 13 |
# File 'lib/model_context_protocol/server.rb', line 11 def transport @transport end |
Class Method Details
.configure_redis(&block) ⇒ Object
286 287 288 |
# File 'lib/model_context_protocol/server.rb', line 286 def configure_redis(&block) RedisConfig.configure(&block) end |
Instance Method Details
#start ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/model_context_protocol/server.rb', line 20 def start configuration.validate! @transport = case configuration.transport_type when :stdio, nil StdioTransport.new(router: @router, configuration: @configuration) when :streamable_http StreamableHttpTransport.new( router: @router, configuration: @configuration ) else raise ArgumentError, "Unknown transport: #{configuration.transport_type}" end @transport.handle end |