smoke_test.py•2.64 kB
#!/usr/bin/env python3
"""
Smoke test for NFL Transactions MCP.
This test makes sure all tools can be called successfully.
"""
import sys
import os
import json
from pprint import pprint
# Add parent directory to path to import server module
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
# Import server module (which contains all tool methods)
import server
def run_smoke_test():
"""Run a basic smoke test for all tools"""
print("\n=== NFL Transactions MCP Smoke Test ===\n")
# Test 1: List available tools
print("Test 1: Listing all tools...")
tools_result = server.listTools()
print(f"Found {len(tools_result['tools'])} tools:")
for tool in tools_result['tools']:
print(f" - {tool['name']}: {tool['description']}")
# Test 2: List teams
print("\nTest 2: Listing all NFL teams...")
teams_result = server.list_teams()
if "status" in teams_result and teams_result["status"] == "success":
teams = teams_result.get("teams", [])
print(f"Found {len(teams)} teams. First few: {', '.join(teams[:5])}...")
else:
print(f"Error listing teams: {teams_result}")
# Test 3: List transaction types
print("\nTest 3: Listing all transaction types...")
types_result = server.list_transaction_types()
if "status" in types_result and types_result["status"] == "success":
types = types_result.get("transaction_types", [])
print(f"Found transaction types: {', '.join(types)}")
else:
print(f"Error listing transaction types: {types_result}")
# Test 4: Fetch some transactions
print("\nTest 4: Fetching sample transactions (minimal query)...")
# Use a small date range to avoid long-running tests
try:
sample_txn_result = server.fetch_transactions(
start_date="2023-01-01",
end_date="2023-01-31", # Only 1 month of data
transaction_type="Injury", # More specific type
output_format="json"
)
if "status" in sample_txn_result and sample_txn_result["status"] == "success":
data = sample_txn_result.get("data", [])
print(f"Fetched {len(data)} sample transactions.")
if data:
print("\nFirst transaction:")
pprint(data[0])
else:
print(f"Error fetching transactions: {sample_txn_result}")
except Exception as e:
print(f"Exception during transaction fetch: {e}")
print("\n=== Smoke Test Complete ===\n")
return True
if __name__ == "__main__":
run_smoke_test()