search_player
Find Dota 2 players by name to retrieve their statistics, match history, and game metrics through the OpenDota MCP Server.
Instructions
Search for players by name.
Args:
query: Name to search for
Returns:
List of matching players
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- src/opendota_server/server.py:722-758 (handler)The handler function implementing the 'search_player' MCP tool. It queries the OpenDota API's search endpoint with the provided name, handles errors and empty results, limits to top 10 matches, and formats a list of players with their persona names, account IDs, and similarity scores. The @mcp.tool() decorator also serves as the registration.@mcp.tool() async def search_player(query: str) -> str: """Search for players by name. Args: query: Name to search for Returns: List of matching players """ search_results = await make_opendota_request("search", {"q": query}) if "error" in search_results: return f"Error searching for players: {search_results['error']}" if not search_results or len(search_results) == 0: return f"No players found matching '{query}'." formatted_results = [] # Limit to 10 players players_to_show = [] if isinstance(search_results, list): players_to_show = search_results[:10] for i, player in enumerate(players_to_show): account_id = player.get("account_id", "Unknown") name = player.get("personaname", "Anonymous") similarity = player.get("similarity", 0) formatted_results.append( f"{i+1}. {name}\n" f" Account ID: {account_id}\n" f" Similarity: {similarity:.2f}" ) return f"Players matching '{query}':\n\n" + "\n\n".join(formatted_results)