diff --git a/test_connection.py b/test_connection.py new file mode 100644 index 0000000..4ed167c --- /dev/null +++ b/test_connection.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +"""Quick test script for Dolibarr MCP connection""" + +import asyncio +import sys +import os + +# Add src to path for development +sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) + +from dolibarr_mcp.config import Config +from dolibarr_mcp.dolibarr_client import DolibarrClient, DolibarrAPIError + + +async def test_connection(): + """Test the Dolibarr API connection""" + print("๐Ÿงช Testing Dolibarr MCP Connection...") + print() + + try: + # Load config + config = Config() + print(f"๐Ÿ“ URL: {config.dolibarr_url}") + print(f"๐Ÿ”‘ API Key: {'*' * (len(config.api_key) - 4) + config.api_key[-4:] if config.api_key else 'NOT SET'}") + print() + + # Test connection + async with DolibarrClient(config) as client: + print("๐Ÿ“ก Testing API connection...") + status = await client.get_status() + + print("โœ… Connection successful!") + print(f"๐Ÿ“Š Status: {status}") + print() + + # Test a simple query + print("๐Ÿ‘ฅ Testing customer query...") + customers = await client.get_customers(limit=1) + print(f"โœ… Found {len(customers)} customers") + + print() + print("๐ŸŽฏ Dolibarr MCP server is ready!") + print("๐Ÿš€ Run the MCP server with: python -m dolibarr_mcp.dolibarr_mcp_server") + + except DolibarrAPIError as e: + print(f"โŒ Dolibarr API Error: {e.message}") + if e.status_code: + print(f"๐Ÿ“Š Status Code: {e.status_code}") + if e.response_data: + print(f"๐Ÿ“„ Response: {e.response_data}") + return False + + except Exception as e: + print(f"โŒ Unexpected error: {e}") + return False + + return True + + +if __name__ == "__main__": + success = asyncio.run(test_connection()) + sys.exit(0 if success else 1)