Class: RailsAiBridge::Tools::ResolveSkill

Inherits:
BaseTool
  • Object
show all
Extended by:
Registry::Truncatable
Defined in:
lib/rails_ai_bridge/tools/resolve_skill.rb

Overview

MCP tool that resolves and returns the full content of a named skill or agent.

Looks up the skill or agent in the loaded skill pack registry, following priority ordering and deprecation redirects, and returns its complete markdown content so AI assistants can read and apply the guidance directly without falling back to rake tasks or file reads.

Examples:

Resolve a skill by name

rails_resolve_skill name=code-review

Resolve from a specific pack

rails_resolve_skill name=code-review pack=rails

Resolve an agent

rails_resolve_skill name=tdd-workflow type=agent

Constant Summary collapse

NOT_FOUND_MESSAGE =
"Skill `%<name>s` not found in the loaded skill packs.\n\n" \
'Use `rails_list_registry type=skills` to see available skills.'
NOT_FOUND_AGENT_MESSAGE =
"Agent `%<name>s` not found in the loaded skill packs.\n\n" \
'Use `rails_list_registry type=agents` to see available agents.'
NO_REGISTRY_MESSAGE =
"No registry manifest found at `%<path>s`.\n\n" \
'Use `rails_list_registry type=skills` for setup instructions.'
PACK_MISMATCH_MESSAGE =
"Skill `%<name>s` was found in pack `%<actual>s`, not `%<requested>s`.\n\n" \
'Returning the skill from `%<actual>s`. Use `pack=` only to disambiguate ' \
'when the same skill name exists in multiple packs.'

Class Method Summary collapse

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:, pack: nil, type: 'skill', _server_context: nil) ⇒ MCP::Tool::Response

Returns full skill/agent content or an error message.

Parameters:

  • name (String)

    skill or agent name

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

    optional pack name filter

  • type (String) (defaults to: 'skill')

    "skill" or "agent" (default: "skill")

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

    reserved for MCP transport metadata

Returns:

  • (MCP::Tool::Response)

    full skill/agent content or an error message



65
66
67
68
69
70
71
72
73
# File 'lib/rails_ai_bridge/tools/resolve_skill.rb', line 65

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

  resolved = resolve(resolver, name: name, pack: pack, type: type)
  return text_response(not_found_message(name, type)) unless resolved

  text_response(format_response(resolved, requested_pack: pack))
end