Class: RailsAiBridge::Tools::UseAgent

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

Overview

MCP tool that resolves an agent/workflow and returns it framed for adoption.

The agent content is wrapped in an activation directive (intent header and a follow-through footer requiring the workflow to be executed end to end) so the assistant adopts the workflow rather than merely reading it.

Examples:

Adopt an agent workflow for the current task

rails_use_agent name=tdd-workflow

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

Returns activation directive or an error message.

Parameters:

  • name (String)

    agent name

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

    reserved for MCP transport metadata

Returns:

  • (MCP::Tool::Response)

    activation directive or an error message



37
38
39
40
41
42
43
44
45
# File 'lib/rails_ai_bridge/tools/use_agent.rb', line 37

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_agent(name)
  return text_response(format(UsageFormatter::NOT_FOUND_AGENT_MESSAGE, name: name)) unless resolved

  text_response(format_usage(resolved, kind: :agent))
end