Module: VectorMCP::Server::Capabilities

Included in:
VectorMCP::Server
Defined in:
lib/vector_mcp/server/capabilities.rb

Overview

Handles server capabilities and configuration

Instance Method Summary collapse

Instance Method Details

#clear_prompts_list_changedvoid

This method returns an undefined value.

Resets the prompts_list_changed flag to false.



35
36
37
38
# File 'lib/vector_mcp/server/capabilities.rb', line 35

def clear_prompts_list_changed
  @prompts_list_changed = false
  logger.debug("Prompts listChanged flag cleared.")
end

#clear_roots_list_changedvoid

This method returns an undefined value.

Resets the roots_list_changed flag to false.



63
64
65
66
# File 'lib/vector_mcp/server/capabilities.rb', line 63

def clear_roots_list_changed
  @roots_list_changed = false
  logger.debug("Roots listChanged flag cleared.")
end

#notify_prompts_list_changedvoid

This method returns an undefined value.

Notifies connected clients that the list of available prompts has changed.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/vector_mcp/server/capabilities.rb', line 42

def notify_prompts_list_changed
  return unless transport && @prompts_list_changed

  notification_method = "notifications/prompts/list_changed"
  begin
    if transport.respond_to?(:broadcast_notification)
      logger.info("Broadcasting prompts list changed notification.")
      transport.broadcast_notification(notification_method)
    elsif transport.respond_to?(:send_notification)
      logger.info("Sending prompts list changed notification (transport may broadcast or send to first client).")
      transport.send_notification(notification_method)
    else
      logger.warn("Transport does not support sending notifications/prompts/list_changed.")
    end
  rescue StandardError => e
    logger.error("Failed to send prompts list changed notification: #{e.class.name}: #{e.message}")
  end
end

#notify_roots_list_changedvoid

This method returns an undefined value.

Notifies connected clients that the list of available roots has changed.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/vector_mcp/server/capabilities.rb', line 70

def notify_roots_list_changed
  return unless transport && @roots_list_changed

  notification_method = "notifications/roots/list_changed"
  begin
    if transport.respond_to?(:broadcast_notification)
      logger.info("Broadcasting roots list changed notification.")
      transport.broadcast_notification(notification_method)
    elsif transport.respond_to?(:send_notification)
      logger.info("Sending roots list changed notification (transport may broadcast or send to first client).")
      transport.send_notification(notification_method)
    else
      logger.warn("Transport does not support sending notifications/roots/list_changed.")
    end
  rescue StandardError => e
    logger.error("Failed to send roots list changed notification: #{e.class.name}: #{e.message}")
  end
end

#sampling_configHash

Returns the sampling configuration for this server.

Returns:

  • (Hash)

    The sampling configuration including capabilities and limits.



17
18
19
# File 'lib/vector_mcp/server/capabilities.rb', line 17

def sampling_config
  @sampling_config[:config]
end

#server_capabilitiesHash

Describes the capabilities of this server according to MCP specifications.

Returns:

  • (Hash)

    A capabilities object.



23
24
25
26
27
28
29
30
31
# File 'lib/vector_mcp/server/capabilities.rb', line 23

def server_capabilities
  caps = {}
  caps[:tools] = { listChanged: false } unless @tools.empty?
  caps[:resources] = { subscribe: false, listChanged: false } unless @resources.empty?
  caps[:prompts] = { listChanged: @prompts_list_changed } unless @prompts.empty?
  caps[:roots] = { listChanged: true } unless @roots.empty?
  caps[:sampling] = @sampling_config[:capabilities]
  caps
end

#server_infoHash

Provides basic information about the server.

Returns:

  • (Hash)

    Server name and version.



11
12
13
# File 'lib/vector_mcp/server/capabilities.rb', line 11

def server_info
  { name: @name, version: @version }
end

#subscribe_prompts(session) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Registers a session as a subscriber to prompt list changes.



91
92
93
94
# File 'lib/vector_mcp/server/capabilities.rb', line 91

def subscribe_prompts(session)
  @prompt_subscribers << session unless @prompt_subscribers.include?(session)
  logger.debug("Session subscribed to prompt list changes: #{session.object_id}")
end