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 =

Returns MCP tool identifier string.

Returns:

  • (String)

    MCP tool identifier string.

'rai_schema_get'
DESCRIPTION =

Returns Human-readable description of this tool.

Returns:

  • (String)

    Human-readable description of this tool.

'Get JSON Schema content for behaviour/design/tooling validation'
ANNOTATIONS =

Returns MCP protocol annotations describing tool capabilities.

Returns:

  • (Hash)

    MCP protocol annotations describing tool capabilities.

{
  'readOnlyHint' => true,
  'destructiveHint' => false,
  'idempotentHint' => true,
  'openWorldHint' => false
}.freeze
VALID_SCHEMAS =

Returns Valid schemas constant.

Returns:

  • (Hash)

    Valid schemas constant.

{
  '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
INPUT_SCHEMA =

Returns JSON Schema defining the tool input parameters.

Returns:

  • (Hash)

    JSON Schema defining the tool input parameters.

{
  type: 'object',
  properties: {
    schema_name: {
      type: 'string',
      enum: ['behaviour', 'design', 'tooling', 'workflow', 'provenance', 'policy'],
      description: 'Schema name to retrieve'
    }
  },
  required: ['schema_name']
}.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



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/rosett_ai/mcp/tools/schema_get_tool.rb', line 60

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