Class: SwarmCLI::Commands::McpTools
- Inherits:
-
Object
- Object
- SwarmCLI::Commands::McpTools
- Defined in:
- lib/swarm_cli/commands/mcp_tools.rb
Overview
McpTools command starts an MCP server that exposes SwarmSDK tools.
Usage:
swarm mcp tools # Expose all available tools
swarm mcp tools Bash Grep # Expose only Bash and Grep
The server uses stdio transport and exposes SwarmSDK tools as MCP tools.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(options) ⇒ McpTools
constructor
A new instance of McpTools.
Constructor Details
#initialize(options) ⇒ McpTools
Returns a new instance of McpTools.
15 16 17 18 19 20 |
# File 'lib/swarm_cli/commands/mcp_tools.rb', line 15 def initialize() @options = # Create volatile scratchpad for MCP server # Note: Scratchpad is always volatile - data is not persisted between sessions @scratchpad = SwarmSDK::Tools::Stores::ScratchpadStorage.new end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/swarm_cli/commands/mcp_tools.rb', line 13 def @options end |
Instance Method Details
#execute ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/swarm_cli/commands/mcp_tools.rb', line 22 def execute # Validate options .validate! # Determine which tools to expose tools_to_expose = determine_tools if tools_to_expose.empty? $stderr.puts "Error: No tools available to expose" exit(1) end # Start the MCP server start_mcp_server(tools_to_expose) rescue Interrupt # User cancelled (Ctrl+C) - silent exit exit(130) rescue StandardError => e # Unexpected errors - always log to stderr $stderr.puts "Fatal error: #{e.}" $stderr.puts e.backtrace.first(5).join("\n") if ENV["DEBUG"] exit(1) end |