Class: RosettAi::Mcp::Resources::ConfigResource

Inherits:
Object
  • Object
show all
Defined in:
lib/rosett_ai/mcp/resources/config_resource.rb

Overview

MCP resource provider for compiled configuration.

Exposes compiled configuration scopes as MCP resources.

Author:

  • hugo

  • claude

Constant Summary collapse

URI_PREFIX =
'rosett-ai://config/'
SCOPES =
['managed', 'user', 'project', 'local'].freeze

Instance Method Summary collapse

Instance Method Details

#listArray<Hash>

Lists available config resources.

Returns:

  • (Array<Hash>)

    resource entries



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rosett_ai/mcp/resources/config_resource.rb', line 22

def list
  SCOPES.filter_map do |scope|
    path = scope_path(scope)
    next unless path&.exist?

    {
      uri: "#{URI_PREFIX}#{scope}",
      name: "config-#{scope}",
      description: "Compiled configuration: #{scope} scope",
      mime_type: 'application/json'
    }
  end
end

#read(scope) ⇒ Hash?

Reads a specific config scope.

Parameters:

  • scope (String)

    scope name (managed, user, project, local)

Returns:

  • (Hash, nil)

    resource content



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rosett_ai/mcp/resources/config_resource.rb', line 40

def read(scope)
  return nil unless SCOPES.include?(scope)

  path = scope_path(scope)
  return nil unless path&.exist?

  {
    uri: "#{URI_PREFIX}#{scope}",
    content: File.read(path),
    mime_type: 'application/json'
  }
end