Class: RosettAi::Mcp::Resources::SchemaResource

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

Overview

MCP resource provider for JSON Schema files.

Exposes validation schemas as MCP resources with URIs in the format rosett-ai://schema/name.

Author:

  • hugo

  • claude

Constant Summary collapse

URI_PREFIX =
'rosett-ai://schema/'

Instance Method Summary collapse

Instance Method Details

#listArray<Hash>

Lists all available schema resources.

Returns:

  • (Array<Hash>)

    resource entries



22
23
24
25
26
27
# File 'lib/rosett_ai/mcp/resources/schema_resource.rb', line 22

def list
  dir = RosettAi.root.join('conf', 'schemas')
  return [] unless dir.directory?

  dir.glob('*.json').map { |path| resource_entry(path) }
end

#read(name) ⇒ Hash?

Reads a specific schema resource.

Parameters:

  • name (String)

    schema name (without _schema.json)

Returns:

  • (Hash, nil)

    resource content



33
34
35
36
37
38
39
40
41
42
# File 'lib/rosett_ai/mcp/resources/schema_resource.rb', line 33

def read(name)
  path = resolve_path(name)
  return nil unless path&.exist?

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