Class: RosettAi::Mcp::Tools::SchemaGetTool

Inherits:
Object
  • Object
show all
Defined in:
lib/rosett_ai/mcp/tools/schema_get_tool.rb

Overview

MCP tool: retrieve JSON Schema content for validation.

Returns the raw JSON Schema used for validating behaviour, design, or tooling configuration files. Read-only.

Author:

  • hugo

  • claude

Constant Summary collapse

TOOL_NAME =
'rai_schema_get'
DESCRIPTION =
'Get JSON Schema content for behaviour/design/tooling validation'
ANNOTATIONS =
{
  'readOnlyHint' => true,
  'destructiveHint' => false,
  'idempotentHint' => true,
  'openWorldHint' => false
}.freeze
VALID_SCHEMAS =
{
  'behaviour' => 'behaviour_schema.json',
  'design' => 'design_schema.json',
  'tooling' => 'tooling_schema.json',
  'workflow' => 'workflow_schema.json',
  'provenance' => 'provenance_schema.json',
  'policy' => 'policy_schema.json'
}.freeze

Instance Method Summary collapse

Instance Method Details

#call(schema_name:) ⇒ Hash

Retrieves the JSON Schema content.

Parameters:

  • schema_name (String)

    one of: behaviour, design, tooling, workflow, provenance, policy

Returns:

  • (Hash)

    schema content and metadata



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rosett_ai/mcp/tools/schema_get_tool.rb', line 43

def call(schema_name:)
  filename = VALID_SCHEMAS[schema_name]
  return invalid_schema_response(schema_name) unless filename

  schema_path = RosettAi.root.join('conf', 'schemas', filename)
  return missing_schema_response(schema_path) unless schema_path.exist?

  content = JSON.parse(schema_path.read)
  {
    schema_name: schema_name,
    filename: filename,
    content: content,
    path: schema_path.to_s
  }
rescue JSON::ParserError => e
  ResponseHelper.error("Schema parse error: #{e.message}")
rescue StandardError => e
  ResponseHelper.error("Schema get failed: #{e.message}")
end