#!/usr/bin/env ruby
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-FileCopyrightText: 2026 OpenVox MCP Server Contributors
# frozen_string_literal: true

require_relative '../lib/openvox_mcp'

# stdio entry point — local development convenience
# Usage: bin/openvox-mcp-stdio [--config PATH]

config_path = nil
plugins = []

ARGV.each_with_index do |arg, i|
  case arg
  when '--config', '-c'
    config_path = ARGV[i + 1]
  when '--plugin', '-p'
    plugins << ARGV[i + 1]
  when '--help', '-h'
    puts <<~HELP
      OpenVox MCP Server — stdio transport

      Usage: openvox-mcp-stdio [options]

      Options:
        -c, --config PATH    Path to .openvox-mcp.yml config file
        -p, --plugin NAME    Load a specific plugin (can be repeated)
        -h, --help           Show this help message

      The server reads JSON-RPC requests from stdin and writes responses to stdout.
      Governance policy is always loaded.

      Example:
        echo '{"jsonrpc":"2.0","id":1,"method":"ping"}' | bin/openvox-mcp-stdio

    HELP
    exit 0
  end
end

OpenvoxMCP::Server.run_stdio(config_path: config_path, plugins: plugins)
