from pathlib import Path
import sys
from mcp.server.fastmcp import FastMCP
mcp = FastMCP('Chess.com')
try:
from .chess_api import get_player_profile, get_player_stats
except ImportError:
# Fallback for direct execution where relative imports lack package context.
src_dir = Path(__file__).resolve().parent.parent
if str(src_dir) not in sys.path:
sys.path.append(str(src_dir))
from chess.chess_api import get_player_profile, get_player_stats
@mcp.tool()
def get_chess_player_profile(username: str):
"""Get the public profile for a Chess.com player by username."""
return get_player_profile(username)
@mcp.tool()
def get_chess_player_stats(username: str):
"""Get the stats for a Chess.com player by username."""
return get_player_stats(username)
def main():
mcp.run(transport="stdio")
if __name__ == "__main__":
main()