Class: MCP::Server::Capabilities
- Inherits:
-
Object
- Object
- MCP::Server::Capabilities
- Defined in:
- lib/mcp/server/capabilities.rb
Instance Method Summary collapse
-
#initialize(capabilities_hash = nil) ⇒ Capabilities
constructor
A new instance of Capabilities.
- #support_completions ⇒ Object
- #support_experimental(config = {}) ⇒ Object
- #support_logging ⇒ Object
- #support_prompts ⇒ Object
- #support_prompts_list_changed ⇒ Object
- #support_resources ⇒ Object
- #support_resources_list_changed ⇒ Object
- #support_resources_subscribe ⇒ Object
- #support_tools ⇒ Object
- #support_tools_list_changed ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(capabilities_hash = nil) ⇒ Capabilities
Returns a new instance of Capabilities.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mcp/server/capabilities.rb', line 6 def initialize(capabilities_hash = nil) @completions = nil @experimental = nil @logging = nil @prompts = nil @resources = nil @tools = nil if capabilities_hash support_completions if capabilities_hash.key?(:completions) support_experimental(capabilities_hash[:experimental]) if capabilities_hash.key?(:experimental) support_logging if capabilities_hash.key?(:logging) if capabilities_hash.key?(:prompts) support_prompts prompts_config = capabilities_hash[:prompts] || {} support_prompts_list_changed if prompts_config[:listChanged] end if capabilities_hash.key?(:resources) support_resources resources_config = capabilities_hash[:resources] || {} support_resources_list_changed if resources_config[:listChanged] support_resources_subscribe if resources_config[:subscribe] end if capabilities_hash.key?(:tools) support_tools tools_config = capabilities_hash[:tools] || {} support_tools_list_changed if tools_config[:listChanged] end end end |
Instance Method Details
#support_completions ⇒ Object
40 41 42 |
# File 'lib/mcp/server/capabilities.rb', line 40 def support_completions @completions ||= {} end |
#support_experimental(config = {}) ⇒ Object
44 45 46 |
# File 'lib/mcp/server/capabilities.rb', line 44 def support_experimental(config = {}) @experimental = config || {} end |
#support_logging ⇒ Object
48 49 50 |
# File 'lib/mcp/server/capabilities.rb', line 48 def support_logging @logging ||= {} end |
#support_prompts ⇒ Object
52 53 54 |
# File 'lib/mcp/server/capabilities.rb', line 52 def support_prompts @prompts ||= {} end |
#support_prompts_list_changed ⇒ Object
56 57 58 59 |
# File 'lib/mcp/server/capabilities.rb', line 56 def support_prompts_list_changed support_prompts @prompts[:listChanged] = true end |
#support_resources ⇒ Object
61 62 63 |
# File 'lib/mcp/server/capabilities.rb', line 61 def support_resources @resources ||= {} end |
#support_resources_list_changed ⇒ Object
65 66 67 68 |
# File 'lib/mcp/server/capabilities.rb', line 65 def support_resources_list_changed support_resources @resources[:listChanged] = true end |
#support_resources_subscribe ⇒ Object
70 71 72 73 |
# File 'lib/mcp/server/capabilities.rb', line 70 def support_resources_subscribe support_resources @resources[:subscribe] = true end |
#support_tools ⇒ Object
75 76 77 |
# File 'lib/mcp/server/capabilities.rb', line 75 def support_tools @tools ||= {} end |
#support_tools_list_changed ⇒ Object
79 80 81 82 |
# File 'lib/mcp/server/capabilities.rb', line 79 def support_tools_list_changed support_tools @tools[:listChanged] = true end |
#to_h ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/mcp/server/capabilities.rb', line 84 def to_h { completions: @completions, experimental: @experimental, logging: @logging, prompts: @prompts, resources: @resources, tools: @tools, }.compact end |