Skip to content

Add --log-level CLI flag for debug logging #12

@Bortlesboat

Description

@Bortlesboat

What

Add a --log-level CLI flag to control logging verbosity. Currently the log level is hardcoded to INFO on line 23 of server.py:

logging.basicConfig(level=logging.INFO, stream=sys.stderr)

Why

When troubleshooting connection issues or debugging tool behavior, users need DEBUG level logging to see:

  • Which RPC backend was selected (local node vs Satoshi API)
  • Individual RPC call details
  • Response timing

Currently there is no way to enable debug output without editing the source code.

Implementation

In the main() function (line ~1864 of server.py):

parser.add_argument(
    "--log-level",
    choices=["DEBUG", "INFO", "WARNING", "ERROR"],
    default="INFO",
    help="Logging verbosity (default: INFO)",
)
args = parser.parse_args()
logging.basicConfig(level=getattr(logging, args.log_level), stream=sys.stderr)

Move the logging.basicConfig call from the module level into main() so it respects the flag.

Where to look

  • src/bitcoin_mcp/server.py — line 23 (current logging.basicConfig) and main() function at the bottom
  • tests/test_server.pyTestCLI class for test patterns

Acceptance criteria

  • bitcoin-mcp --log-level DEBUG produces debug output on stderr
  • bitcoin-mcp with no flag defaults to INFO (no breaking change)
  • bitcoin-mcp --log-level WARNING suppresses info messages
  • Add a test verifying the flag is accepted by argparse
  • Module-level logging.basicConfig removed or guarded

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions