get_club_profile
Retrieve detailed information about a Chess.com club by providing its unique URL identifier. Access club data for analysis or integration using standardized MCP interfaces.
Instructions
Get information about a club on Chess.com
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url_id | Yes |
Input Schema (JSON Schema)
{
"properties": {
"url_id": {
"title": "Url Id",
"type": "string"
}
},
"required": [
"url_id"
],
"title": "get_club_profileArguments",
"type": "object"
}
Implementation Reference
- src/chess_mcp/server.py:209-221 (handler)The main handler function for the 'get_club_profile' tool. Decorated with @mcp.tool, which handles registration. It calls the helper make_api_request to fetch club data from the Chess.com API.@mcp.tool(description="Get information about a club on Chess.com") async def get_club_profile(url_id: str) -> Dict[str, Any]: """ Get information about a club on Chess.com. Args: url_id: The URL identifier of the club Returns: Club profile data """ logger.info("Fetching club profile", url_id=url_id) return await make_api_request(f"club/{url_id}")
- src/chess_mcp/server.py:26-81 (helper)Core helper function used by get_club_profile to make HTTP requests to the Chess.com API.async def make_api_request( endpoint: str, params: Optional[Dict[str, Any]] = None, accept_json: bool = True ) -> Union[Dict[str, Any], str]: """ Make a request to the Chess.com API. Args: endpoint: The API endpoint to request params: Optional query parameters accept_json: Whether to accept JSON response (True) or PGN (False) Returns: JSON response as dict or text response as string Raises: httpx.HTTPError: If the request fails """ url = f"{config.base_url}/{endpoint}" headers = { "accept": "application/json" if accept_json else "application/x-chess-pgn" } logger.debug( "Making API request", endpoint=endpoint, url=url, accept_json=accept_json, has_params=params is not None ) async with httpx.AsyncClient() as client: try: response = await client.get(url, headers=headers, params=params or {}) response.raise_for_status() if accept_json: result = response.json() logger.debug("API request successful", endpoint=endpoint, response_type="json") return result else: result = response.text logger.debug("API request successful", endpoint=endpoint, response_type="text") return result except httpx.HTTPError as e: logger.error( "API request failed", endpoint=endpoint, url=url, error=str(e), error_type=type(e).__name__ ) raise
- src/chess_mcp/server.py:392-410 (helper)MCP resource handler that invokes get_club_profile to provide club profile data as a JSON resource.@mcp.resource("chess://club/{url_id}") async def club_profile_resource(url_id: str) -> str: """ Resource that returns club profile data. Args: url_id: The URL identifier of the club Returns: JSON-formatted club profile """ try: import json logger.debug("Fetching club profile resource", url_id=url_id) profile = await get_club_profile(url_id=url_id) return json.dumps(profile, indent=2) except Exception as e: logger.error("Error retrieving club profile", url_id=url_id, error=str(e)) return f"Error retrieving club profile: {str(e)}"
- src/chess_mcp/server.py:12-13 (registration)Initialization of the FastMCP server instance where tools like get_club_profile are registered via decorators.logger = structlog.get_logger(__name__) mcp = FastMCP("Chess.com API MCP")