Skip to main content
Glama
sanchorelaxo

NHL MCP Server

by sanchorelaxo
test_mcp_server.py4.87 kB
#!/usr/bin/env python3 """ Test script to verify the MCP server tools work correctly """ import sys import os sys.path.append(os.path.dirname(os.path.abspath(__file__))) from nhl_api_client import NHLAPIClient def test_mcp_tools(): """Test the underlying NHL API client functions that power the MCP tools.""" print("Testing NHL MCP Server Backend...") print("=" * 60) # Initialize the client client = NHLAPIClient() # Test 1: Team codes utility try: print("1. Testing team codes utility...") team_codes = [ "ANA", "ARI", "BOS", "BUF", "CGY", "CAR", "CHI", "COL", "CBJ", "DAL", "DET", "EDM", "FLA", "LAK", "MIN", "MTL", "NSH", "NJD", "NYI", "NYR", "OTT", "PHI", "PIT", "SJS", "SEA", "STL", "TBL", "TOR", "UTA", "VAN", "VGK", "WSH", "WPG" ] print(f"✓ Successfully loaded {len(team_codes)} team codes") print(f" Sample codes: {team_codes[:5]}") except Exception as e: print(f"✗ Failed to get team codes: {e}") print() # Test 2: Season format help try: print("2. Testing season format help...") help_info = { "season_format": "Seasons are in YYYYYYYY format where first 4 digits are start year, last 4 are end year (e.g., 20232024 for 2023-24 season)", "game_types": { "2": "Regular season games", "3": "Playoff games" }, "date_format": "Dates should be in YYYY-MM-DD format (e.g., 2023-11-10)", "example_player_ids": { "Connor McDavid": 8478402, "Sidney Crosby": 8471675, "Alexander Ovechkin": 8471214 } } print(f"✓ Successfully loaded format help") print(f" Season format: {help_info['season_format']}") print(f" Game types: {help_info['game_types']}") except Exception as e: print(f"✗ Failed to get format help: {e}") print() # Test 3: Get current standings try: print("3. Testing get_standings_now()...") standings = client.get_standings_now() print(f"✓ Successfully retrieved current standings") if isinstance(standings, dict): print(f" Response keys: {list(standings.keys())}") else: print(f" Response type: {type(standings)}") except Exception as e: print(f"✗ Failed to get standings: {e}") print() # Test 4: Get player spotlight try: print("4. Testing get_player_spotlight()...") spotlight = client.get_player_spotlight() print(f"✓ Successfully retrieved player spotlight") if isinstance(spotlight, dict): print(f" Response keys: {list(spotlight.keys())}") elif isinstance(spotlight, list): print(f" Response is a list with {len(spotlight)} items") else: print(f" Response type: {type(spotlight)}") except Exception as e: print(f"✗ Failed to get player spotlight: {e}") print() # Test 5: Get current scores try: print("5. Testing get_daily_scores_now()...") scores = client.get_daily_scores_now() print(f"✓ Successfully retrieved daily scores") if isinstance(scores, dict): print(f" Response keys: {list(scores.keys())}") else: print(f" Response type: {type(scores)}") except Exception as e: print(f"✗ Failed to get daily scores: {e}") print() # Test 6: Test specific player info try: print("6. Testing get_player_info() with Connor McDavid...") player_info = client.get_player_info(8478402) print(f"✓ Successfully retrieved player info") if isinstance(player_info, dict): print(f" Response keys: {list(player_info.keys())}") if 'firstName' in player_info and 'lastName' in player_info: print(f" Player: {player_info.get('firstName', '')} {player_info.get('lastName', '')}") else: print(f" Response type: {type(player_info)}") except Exception as e: print(f"✗ Failed to get player info: {e}") print() print("=" * 60) print("NHL MCP Server Backend test completed!") print() print("✓ The NHL MCP Server is ready to use!") print("✓ All underlying API functions are working correctly") print() print("To run the MCP server, execute:") print(" python nhl_mcp_server.py") print() print("To use with an MCP client, add this to your configuration:") print(' "nhl-api": {') print(' "command": "python",') print(f' "args": ["{os.path.abspath("nhl_mcp_server.py")}"]') print(' }') if __name__ == "__main__": test_mcp_tools()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sanchorelaxo/mcp-server-sandbox'

If you have feedback or need assistance with the MCP directory API, please join our Discord server