test_skulabs_client.pyā¢3.72 kB
"""
Test script for Skulabs MCP Server
Run this to test the API connection and basic functionality
"""
import asyncio
import os
import json
from dotenv import load_dotenv
from skulabs_client import SkulabsClient, SkulabsAPIError
# Load environment variables
load_dotenv()
async def test_skulabs_connection():
"""Test basic connection to Skulabs API"""
api_key = os.getenv("SKULABS_API_KEY")
if not api_key:
print("ā SKULABS_API_KEY not found in environment variables")
print("Please set your Skulabs API key in .env file")
return False
print("š Testing Skulabs API connection...")
try:
async with SkulabsClient(api_key) as client:
# Test basic API connectivity
print("š¦ Testing inventory retrieval...")
inventory = await client.get_inventory(limit=5)
print(f"ā
Successfully retrieved {len(inventory.get('items', []))} inventory items")
print("š Testing products retrieval...")
products = await client.get_products(limit=5)
print(f"ā
Successfully retrieved {len(products.get('items', []))} products")
print("š Testing inventory summary...")
summary = await client.get_inventory_summary()
print("ā
Successfully retrieved inventory summary")
print("\nš All tests passed! Your Skulabs MCP server is ready to deploy.")
return True
except SkulabsAPIError as e:
print(f"ā Skulabs API Error: {e}")
print("Please check your API key and ensure it has proper permissions")
return False
except Exception as e:
print(f"ā Unexpected error: {e}")
return False
async def test_mcp_tools():
"""Test MCP tool definitions"""
print("\nš§ Testing MCP tool definitions...")
try:
from skulabs_mcp_server import server
import asyncio
# Test listing tools
tools = await server.list_tools()
print(f"ā
Successfully defined {len(tools)} MCP tools:")
for tool in tools:
print(f" - {tool.name}: {tool.description}")
return True
except Exception as e:
print(f"ā Error testing MCP tools: {e}")
return False
def check_environment():
"""Check if environment is properly configured"""
print("š Checking environment configuration...")
required_vars = ["SKULABS_API_KEY"]
missing_vars = []
for var in required_vars:
if not os.getenv(var):
missing_vars.append(var)
if missing_vars:
print(f"ā Missing required environment variables: {', '.join(missing_vars)}")
print("Please set these in your .env file")
return False
print("ā
Environment variables configured")
return True
async def main():
"""Run all tests"""
print("š Skulabs MCP Server Test Suite")
print("=" * 40)
# Check environment
if not check_environment():
return
# Test API connection
api_ok = await test_skulabs_connection()
# Test MCP tools
mcp_ok = await test_mcp_tools()
print("\n" + "=" * 40)
if api_ok and mcp_ok:
print("š All tests passed! Your MCP server is ready.")
print("\nNext steps:")
print("1. Deploy to Railway: git push")
print("2. Set environment variables in Railway dashboard")
print("3. Connect your AI agent to the Railway URL")
else:
print("ā Some tests failed. Please fix the issues above.")
if __name__ == "__main__":
asyncio.run(main())