Implement StreamableHTTP transport
Co-authored-by: Topher Bullock <topher.bullock@shopify.com>
This commit is contained in:
parent
04710ac472
commit
3e03a2af66
1 changed files with 1807 additions and 6 deletions
|
|
@ -24,7 +24,7 @@ module MCP
|
|||
include Instrumentation
|
||||
|
||||
attr_writer :capabilities
|
||||
attr_accessor :name, :version, :tools, :prompts, :resources, :server_context, :configuration
|
||||
attr_accessor :name, :version, :tools, :prompts, :resources, :server_context, :configuration, :transport
|
||||
|
||||
def initialize(
|
||||
name: "model_context_protocol",
|
||||
|
|
@ -35,7 +35,8 @@ module MCP
|
|||
resource_templates: [],
|
||||
server_context: nil,
|
||||
configuration: nil,
|
||||
capabilities: nil
|
||||
capabilities: nil,
|
||||
transport: nil
|
||||
)
|
||||
@name = name
|
||||
@version = version
|
||||
|
|
@ -68,6 +69,7 @@ module MCP
|
|||
Methods::COMPLETION_COMPLETE => ->(_) {},
|
||||
Methods::LOGGING_SET_LEVEL => ->(_) {},
|
||||
}
|
||||
@transport = transport
|
||||
end
|
||||
|
||||
def capabilities
|
||||
|
|
@ -96,6 +98,14 @@ module MCP
|
|||
@prompts[prompt.name_value] = prompt
|
||||
end
|
||||
|
||||
def handle_rack_request(request)
|
||||
@transport.handle_request(request)
|
||||
end
|
||||
|
||||
def close
|
||||
@transport.close
|
||||
end
|
||||
|
||||
def resources_list_handler(&block)
|
||||
@capabilities.support_resources
|
||||
@handlers[Methods::RESOURCES_LIST] = block
|
||||
|
|
|
|||
Loading…
Reference in a new issue