diff --git a/src/dolibarr_mcp/dolibarr_mcp_server.py b/src/dolibarr_mcp/dolibarr_mcp_server.py index 9aa176d..9a4050f 100644 --- a/src/dolibarr_mcp/dolibarr_mcp_server.py +++ b/src/dolibarr_mcp/dolibarr_mcp_server.py @@ -653,6 +653,22 @@ async def test_api_connection(): config = None try: config = Config() + + # Check if environment variables are set + if not config.dolibarr_url or config.dolibarr_url == "https://your-dolibarr-instance.com/api/index.php": + print("โš ๏ธ Warning: DOLIBARR_URL not configured in .env file", file=sys.stderr) + print("โš ๏ธ Using placeholder URL - API calls will fail", file=sys.stderr) + print("๐Ÿ“ Please configure your .env file with valid Dolibarr credentials", file=sys.stderr) + yield True # Allow server to start anyway + return + + if not config.api_key or config.api_key == "your_dolibarr_api_key_here": + print("โš ๏ธ Warning: DOLIBARR_API_KEY not configured in .env file", file=sys.stderr) + print("โš ๏ธ API authentication will fail", file=sys.stderr) + print("๐Ÿ“ Please configure your .env file with valid Dolibarr credentials", file=sys.stderr) + yield True # Allow server to start anyway + return + async with DolibarrClient(config) as client: print("๐Ÿงช Testing Dolibarr API connection...", file=sys.stderr) result = await client.get_status() @@ -661,27 +677,32 @@ async def test_api_connection(): print("๐ŸŽฏ Full CRUD operations available for all Dolibarr modules", file=sys.stderr) yield True else: - print(f"โŒ API test failed: {result.get('error', 'Unknown error')}", file=sys.stderr) - yield False + print(f"โš ๏ธ API test returned unexpected result: {result}", file=sys.stderr) + print("โš ๏ธ Server will start but API calls may fail", file=sys.stderr) + yield True # Allow server to start anyway except Exception as e: - print(f"โŒ API test error: {e}", file=sys.stderr) + print(f"โš ๏ธ API test error: {e}", file=sys.stderr) if config is None: print("๐Ÿ’ก Check your .env file configuration", file=sys.stderr) - yield False + print("โš ๏ธ Server will start but API calls may fail", file=sys.stderr) + yield True # Allow server to start anyway async def main(): """Run the Dolibarr MCP server.""" - # Quick API test using the proper client + # Test API connection but don't fail if it's not working async with test_api_connection() as api_ok: if not api_ok: - print("๐Ÿšจ Cannot start server without valid API connection", file=sys.stderr) - sys.exit(1) + print("โš ๏ธ Starting server without valid API connection", file=sys.stderr) + print("๐Ÿ“ Configure your .env file to enable API functionality", file=sys.stderr) + else: + print("โœ… API connection validated", file=sys.stderr) - # Run server + # Run server regardless of API status print("๐Ÿš€ Starting Professional Dolibarr MCP server...", file=sys.stderr) print("โœ… Server ready with comprehensive ERP management capabilities", file=sys.stderr) + print("๐Ÿ“ Tools will attempt to connect when called", file=sys.stderr) try: async with stdio_server() as (read_stream, write_stream):