Class: RailsAiBridge::Tools::UseSkill

Inherits:
BaseTool
  • Object
show all
Extended by:
UsageFormatter
Defined in:
lib/rails_ai_bridge/tools/use_skill.rb

Overview

MCP tool that resolves a skill and returns it framed for immediate application.

Whereas rails_resolve_skill returns content for inspection, this tool wraps the resolved skill in an application directive (intent header, deprecation notice when redirected, follow-through footer) so the assistant treats it as instructions to execute rather than reference material to read.

Examples:

Apply a skill to the current task

rails_use_skill name=code-review

Constant Summary

Constants included from UsageFormatter

RailsAiBridge::Tools::UsageFormatter::NOT_FOUND_AGENT_MESSAGE, RailsAiBridge::Tools::UsageFormatter::NOT_FOUND_SKILL_MESSAGE, RailsAiBridge::Tools::UsageFormatter::NO_REGISTRY_MESSAGE, RailsAiBridge::Tools::UsageFormatter::USAGE_FOOTERS, RailsAiBridge::Tools::UsageFormatter::USAGE_VERBS

Class Method Summary collapse

Methods included from UsageFormatter

format_usage

Methods included from Registry::Truncatable

#sanitize_markdown, #truncate

Methods inherited from BaseTool

cached_context, cached_section, config, rails_app, reset_cache!, text_response

Class Method Details

.call(name:, _server_context: nil) ⇒ MCP::Tool::Response

:reek:TooManyStatements -- linear tool flow: resolver, resolve, deprecation, render

Parameters:

  • name (String)

    skill name

  • _server_context (Object, nil) (defaults to: nil)

    reserved for MCP transport metadata

Returns:

  • (MCP::Tool::Response)

    application directive or an error message



39
40
41
42
43
44
45
46
47
48
# File 'lib/rails_ai_bridge/tools/use_skill.rb', line 39

def self.call(name:, _server_context: nil)
  resolver = Registry.build_resolver
  return text_response(format(UsageFormatter::NO_REGISTRY_MESSAGE, path: manifest_path)) unless resolver

  resolved = resolver.resolve_skill(name)
  return text_response(format(UsageFormatter::NOT_FOUND_SKILL_MESSAGE, name: name)) unless resolved

  warning = resolver.check_deprecated(name)
  text_response(format_usage(resolved, kind: :skill, deprecation_warning: warning))
end