Class: Rigor::CLI::McpCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/cli/mcp_command.rb

Overview

Executes the ‘rigor mcp` command.

Starts a long-running MCP (Model Context Protocol) server over stdio. The server exposes Rigor’s analysis tools as MCP tool calls over a newline-delimited JSON-RPC 2.0 stream. See ADR-33.

Slice 1 ships the stdio transport with seven read-only tools: rigor_check, rigor_type_of, rigor_triage, rigor_annotate, rigor_sig_gen, rigor_explain, rigor_coverage.

Constant Summary collapse

USAGE =
"Usage: rigor mcp [options]"

Instance Method Summary collapse

Constructor Details

#initialize(argv:, out:, err:) ⇒ McpCommand

Returns a new instance of McpCommand.



19
20
21
22
23
# File 'lib/rigor/cli/mcp_command.rb', line 19

def initialize(argv:, out:, err:)
  @argv = argv
  @out = out
  @err = err
end

Instance Method Details

#runInteger

Returns CLI exit status.

Returns:

  • (Integer)

    CLI exit status.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rigor/cli/mcp_command.rb', line 26

def run
  options = parse_options
  return CLI::EXIT_USAGE if options == :usage_error

  transport = options.fetch(:transport)
  unless transport == "stdio"
    @err.puts("rigor mcp: unsupported transport: #{transport.inspect} (only `stdio` is supported in v1)")
    return CLI::EXIT_USAGE
  end

  require_relative "../mcp"
  require_relative "../version"

  server = MCP::Server.new(config_path: options.fetch(:config), err: $stderr)
  loop_runner = MCP::Loop.new(input: $stdin, output: $stdout, server: server)
  loop_runner.run
  0
end