Class: RosettAi::Mcp::Tools::ProvenanceTool

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

Overview

MCP tool: query AI provenance information.

Validates, shows, and logs provenance entries. Read-only operation.

Author:

  • hugo

  • claude

Constant Summary collapse

TOOL_NAME =
'rai_provenance'
DESCRIPTION =
'Query AI provenance (validate, show, log)'
ANNOTATIONS =
{
  'readOnlyHint' => true,
  'destructiveHint' => false,
  'idempotentHint' => true,
  'openWorldHint' => false
}.freeze
VALID_ACTIONS =
['validate', 'show', 'log'].freeze
INPUT_SCHEMA =
{
  type: 'object',
  properties: {
    action: {
      type: 'string',
      enum: ['validate', 'show', 'log'],
      description: 'Provenance action (default: log)'
    },
    commit: {
      type: 'string',
      description: 'Commit SHA to show provenance for (for show action)'
    },
    file: {
      type: 'string',
      description: 'File path to show provenance for (for show action)'
    },
    role: {
      type: 'string',
      description: 'Filter by AI role (for log action)'
    }
  }
}.freeze

Instance Method Summary collapse

Instance Method Details

#call(action: 'log', commit: nil, file: nil, role: nil) ⇒ Hash

Executes the provenance query.

Parameters:

  • action (String) (defaults to: 'log')

    one of 'validate', 'show', 'log'

  • commit (String, nil) (defaults to: nil)

    commit SHA for show action

  • file (String, nil) (defaults to: nil)

    file path filter

  • role (String, nil) (defaults to: nil)

    AI role filter for log

Returns:

  • (Hash)

    provenance information



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/rosett_ai/mcp/tools/provenance_tool.rb', line 59

def call(action: 'log', commit: nil, file: nil, role: nil)
  return ResponseHelper.error("Invalid action: #{action}") unless VALID_ACTIONS.include?(action)

  tracker = RosettAi::Provenance::Tracker.new
  case action
  when 'validate' then action_validate(tracker)
  when 'show' then action_show(tracker, commit: commit, file: file)
  when 'log' then action_log(tracker, role: role)
  end
rescue StandardError => e
  ResponseHelper.error("Provenance #{action} failed: #{e.message}")
end