Merge pull request #405 from koic/capability_extensions
Support Capability Extensions per SEP-2133
This commit is contained in:
commit
7f266d48ef
3 changed files with 189 additions and 2 deletions
|
|
@ -77,7 +77,9 @@ module MCP
|
|||
#
|
||||
# @param client_info [Hash, nil] `{ name:, version: }` identifying the client.
|
||||
# @param protocol_version [String, nil] Protocol version to offer.
|
||||
# @param capabilities [Hash] Capabilities advertised by the client.
|
||||
# @param capabilities [Hash] Capabilities advertised by the client. May include
|
||||
# an `extensions` member per SEP-2133, keyed by reverse-DNS extension identifiers,
|
||||
# e.g. `{ extensions: { "com.example/feature" => {} } }`.
|
||||
# @return [Hash, nil] The server's `InitializeResult`, or `nil` when the transport
|
||||
# does not expose an explicit handshake.
|
||||
# https://modelcontextprotocol.io/specification/2025-11-25/basic/lifecycle#initialization
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ require_relative "methods"
|
|||
require_relative "logging_message_notification"
|
||||
require_relative "progress"
|
||||
require_relative "server_context"
|
||||
require_relative "server/capabilities"
|
||||
require_relative "server/pagination"
|
||||
require_relative "server/transports"
|
||||
|
||||
|
|
@ -142,7 +143,12 @@ module MCP
|
|||
|
||||
validate!
|
||||
|
||||
@capabilities = capabilities || default_capabilities
|
||||
# Accept either a plain Hash or an `MCP::Server::Capabilities` builder.
|
||||
@capabilities = if capabilities.is_a?(Capabilities)
|
||||
capabilities.to_h
|
||||
else
|
||||
capabilities || default_capabilities
|
||||
end
|
||||
@client_capabilities = nil
|
||||
@logging_message_notification = nil
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ module MCP
|
|||
def initialize(capabilities_hash = nil)
|
||||
@completions = nil
|
||||
@experimental = nil
|
||||
@extensions = nil
|
||||
@logging = nil
|
||||
@prompts = nil
|
||||
@resources = nil
|
||||
|
|
@ -14,6 +15,7 @@ module MCP
|
|||
if capabilities_hash
|
||||
support_completions if capabilities_hash.key?(:completions)
|
||||
support_experimental(capabilities_hash[:experimental]) if capabilities_hash.key?(:experimental)
|
||||
support_extensions(capabilities_hash[:extensions]) if capabilities_hash.key?(:extensions)
|
||||
support_logging if capabilities_hash.key?(:logging)
|
||||
|
||||
if capabilities_hash.key?(:prompts)
|
||||
|
|
@ -45,6 +47,17 @@ module MCP
|
|||
@experimental = config || {}
|
||||
end
|
||||
|
||||
# Declares support for capability extensions per SEP-2133. Keys are
|
||||
# extension identifiers using the reverse-DNS prefix convention
|
||||
# (e.g. `"io.modelcontextprotocol/tasks"`, `"com.example/feature"`);
|
||||
# values are arbitrary extension-defined configuration objects,
|
||||
# with an empty hash meaning "supported with no settings".
|
||||
# Repeated calls merge, so several extensions can be declared independently.
|
||||
# https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2133
|
||||
def support_extensions(extensions = {})
|
||||
@extensions = (@extensions || {}).merge(extensions || {})
|
||||
end
|
||||
|
||||
def support_logging
|
||||
@logging ||= {}
|
||||
end
|
||||
|
|
@ -85,6 +98,7 @@ module MCP
|
|||
{
|
||||
completions: @completions,
|
||||
experimental: @experimental,
|
||||
extensions: @extensions,
|
||||
logging: @logging,
|
||||
prompts: @prompts,
|
||||
resources: @resources,
|
||||
|
|
|
|||
Loading…
Reference in a new issue