Class: RosettAi::Mcp::Resources::SchemaResource
- Inherits:
-
Object
- Object
- RosettAi::Mcp::Resources::SchemaResource
- 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.
Constant Summary collapse
- URI_PREFIX =
'rosett-ai://schema/'
Instance Method Summary collapse
-
#list ⇒ Array<Hash>
Lists all available schema resources.
-
#read(name) ⇒ Hash?
Reads a specific schema resource.
Instance Method Details
#list ⇒ Array<Hash>
Lists all available schema resources.
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.
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 |