Class: Sxn::Commands::MCP

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/sxn/commands/mcp.rb

Overview

Manage MCP server for Claude Code integration

Instance Method Summary collapse

Constructor Details

#initialize(args = ARGV, local_options = {}, config = {}) ⇒ MCP

Returns a new instance of MCP.



13
14
15
16
# File 'lib/sxn/commands/mcp.rb', line 13

def initialize(args = ARGV, local_options = {}, config = {})
  super
  @ui = Sxn::UI::Output.new
end

Instance Method Details

#installObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sxn/commands/mcp.rb', line 20

def install
  sxn_mcp_path = find_sxn_mcp_executable

  if sxn_mcp_path.nil?
    @ui.error("Could not find sxn-mcp executable")
    @ui.recovery_suggestion("Ensure the sxn gem is properly installed")
    exit(1)
  end

  if options[:project]
    install_to_project(sxn_mcp_path)
  else
    install_to_claude_code(sxn_mcp_path)
  end
end

#serverObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/sxn/commands/mcp.rb', line 72

def server
  require "sxn/mcp"

  mcp_server = Sxn::MCP::Server.new

  case options[:transport]
  when "stdio"
    @ui.info("Starting MCP server with STDIO transport...")
    mcp_server.run_stdio
  when "http"
    @ui.info("Starting MCP server on port #{options[:port]}...")
    mcp_server.run_http(port: options[:port])
  end
end

#statusObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/sxn/commands/mcp.rb', line 47

def status
  @ui.section("MCP Server Status")

  claude_installed = check_claude_installation
  project_installed = check_project_installation

  @ui.newline
  @ui.key_value("Claude Code (user)", claude_installed ? "Installed" : "Not installed")
  @ui.key_value("Project (.mcp.json)", project_installed ? "Installed" : "Not installed")

  sxn_mcp_path = find_sxn_mcp_executable
  @ui.newline
  if sxn_mcp_path
    @ui.key_value("Executable", sxn_mcp_path)
  else
    @ui.warning("sxn-mcp executable not found in PATH")
  end

  @ui.newline
  display_install_commands unless claude_installed || project_installed
end

#uninstallObject



38
39
40
41
42
43
44
# File 'lib/sxn/commands/mcp.rb', line 38

def uninstall
  if options[:project]
    uninstall_from_project
  else
    uninstall_from_claude_code
  end
end