Class: ClaudeSwarm::McpGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_swarm/mcp_generator.rb

Constant Summary collapse

CLAUDE_MCP_SERVER_CONFIG =
{
  "type" => "stdio",
  "command" => "claude",
  "args" => ["mcp", "serve"],
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(configuration, vibe: false, restore_session_path: nil) ⇒ McpGenerator

Returns a new instance of McpGenerator.



11
12
13
14
15
16
17
18
# File 'lib/claude_swarm/mcp_generator.rb', line 11

def initialize(configuration, vibe: false, restore_session_path: nil)
  @config = configuration
  @vibe = vibe
  @restore_session_path = restore_session_path
  @session_path = nil # Will be set when needed
  @instance_ids = {} # Store instance IDs for all instances
  @restore_states = {} # Store loaded state data during restoration
end

Instance Method Details

#generate_allObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/claude_swarm/mcp_generator.rb', line 20

def generate_all
  ensure_swarm_directory

  if @restore_session_path
    # Load existing instance IDs and states from state files
    load_instance_states
  else
    # Generate new instance IDs
    @config.instances.each_key do |name|
      @instance_ids[name] = "#{name}_#{SecureRandom.hex(4)}"
    end
  end

  @config.instances.each do |name, instance|
    generate_mcp_config(name, instance)
  end
end

#mcp_config_path(instance_name) ⇒ Object



38
39
40
# File 'lib/claude_swarm/mcp_generator.rb', line 38

def mcp_config_path(instance_name)
  File.join(session_path, "#{instance_name}.mcp.json")
end