HexpmMcp.CLI (hexpm_mcp v0.3.6)

Copy Markdown View Source

Command-line interface for the server.

HexpmMcp.Application.start/2 is the real entry point in every mode. Burrito boots the BEAM and hands control to the OTP application callback; it never calls a main/1, and the main_module release key is metadata only. So this module turns argv into configuration and lets start/2 build the supervision tree from it.

Cheer.parse/3 is what makes that shape work. Unlike Cheer.run/3 it resolves and validates argv without invoking a command handler, which is the right fit when arguments configure a long-running process rather than driving a unit of work.

Summary

Functions

Turn parsed arguments into server configuration.

Resolve argv into the server configuration.

Functions

config(args)

@spec config(map()) :: keyword()

Turn parsed arguments into server configuration.

A nil transport resolves to the runtime's default, and a nil port defers to app config, which runtime.exs populates from HEXPM_MCP_PORT in prod.

parse()

@spec parse() :: {:serve, keyword()} | :handled | :usage_error

Resolve argv into the server configuration.

Returns {:serve, opts} to start, :handled when Cheer already printed help or version, and :usage_error when it already printed a usage error.

argv comes from Cheer.argv/0 because a Burrito-wrapped binary does not populate System.argv/0; its arguments arrive through Burrito.Util.Args.argv/0 instead. Reading the wrong one fails silently: every option falls through to its default and the server looks like it started fine while speaking the wrong protocol.