From ff12b9450f165073817b688b6b7b3f889e603573 Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Fri, 30 Jan 2026 11:05:15 -0700 Subject: [PATCH] Fix MCP server startup: remove pre-run library init Native library calls during startup interfered with FastMCP's stdio transport initialization. Library is now loaded lazily on first tool call instead. --- src/cp210x_mcp/server.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/cp210x_mcp/server.py b/src/cp210x_mcp/server.py index aa3d58b..c47b386 100644 --- a/src/cp210x_mcp/server.py +++ b/src/cp210x_mcp/server.py @@ -265,26 +265,6 @@ def lock_device(device_index: int = 0, confirm: bool = False) -> dict: def main(): """Entry point for the MCP server.""" - import sys - - try: - from importlib.metadata import version - package_version = version("cp210x-mcp") - except Exception: - package_version = "0.1.0" - - # Print to stderr only — stdout is reserved for JSON-RPC (MCP stdio transport) - print(f"CP210x MCP Server v{package_version}", file=sys.stderr) - - try: - lib = get_lib() - num_devices = lib.get_num_devices() - print(f" Found {num_devices} CP210x device(s)", file=sys.stderr) - except FileNotFoundError as e: - print(f" Library not found: {e}", file=sys.stderr) - except Exception as e: - print(f" Error initializing: {e}", file=sys.stderr) - mcp.run()