get_character_profile
Retrieve character profile information from Wuthering Waves game in Markdown format by providing the character's Chinese name.
Instructions
获取库街区上的角色档案信息并以 Markdown 格式返回。
Args:
character_name: 要查询的角色的中文名称。
Returns:
包含角色档案信息的 Markdown 字符串,
或者在找不到角色或获取数据失败时返回错误消息。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| character_name | Yes |
Implementation Reference
- src/wuwa_mcp_server/server.py:84-102 (handler)Primary MCP tool handler for 'get_character_profile', registered via @mcp.tool() decorator. Delegates execution to CharacterService.@mcp.tool() async def get_character_profile(character_name: str) -> str: """获取库街区上的角色档案信息并以 Markdown 格式返回。 Args: character_name: 要查询的角色的中文名称。 Returns: 包含角色档案信息的 Markdown 字符串, 或者在找不到角色或获取数据失败时返回错误消息。 """ try: character_service, _ = get_services() return await character_service.get_character_profile(character_name) except (DataNotFoundException, ServiceException) as e: # These exceptions already have user-friendly messages return str(e) except Exception: return f"错误:处理 '{character_name}' 档案时发生意外错误。请检查服务器日志。"
- Core implementation logic in CharacterService: fetches raw data from repository, parses profile content, generates Markdown output.async def get_character_profile(self, character_name: str) -> str: """Get character profile information only. Args: character_name: Name of the character to query. Returns: Markdown formatted character profile. Raises: ServiceException: If character profile retrieval fails. """ try: self.logger.info(f"Getting character profile for: {character_name}") # Get character raw data character_raw_data = await self._get_character_data(character_name) # Parse profile content character_profile_data = await asyncio.to_thread( self.content_parser.parse_character_profile, character_raw_data ) # Generate markdown profile_markdown = self.markdown_service.generate_character_markdown( character_profile_data, include_strategy=False ) if not profile_markdown.strip(): self.logger.warning(f"Generated empty profile for: {character_name}") return f"成功获取 '{character_name}' 的档案数据,但解析后的内容无法生成有效的 Markdown。" self.logger.info(f"Successfully generated character profile for: {character_name}") return profile_markdown except DataNotFoundException: error_msg = f"Character '{character_name}' not found" self.logger.error(error_msg) return f"错误:未找到名为 '{character_name}' 的角色。" except Exception as e: self.logger.error(f"Failed to get character profile for {character_name}: {e}") raise ServiceException(f"Character profile retrieval failed: {e}")
- src/wuwa_mcp_server/server.py:184-198 (handler)Alternative tool dispatch handler for HTTP transport mode, directly calls character_service.get_character_profile.result = "" if tool_name == "get_character_info": result = await character_service.get_character_info(arguments.get("character_name")) elif tool_name == "get_artifact_info": result = await artifact_service.get_artifact_info(arguments.get("artifact_name")) elif tool_name == "get_character_profile": result = await character_service.get_character_profile(arguments.get("character_name")) else: return JSONResponse( { "jsonrpc": "2.0", "id": body.get("id"), "error": {"code": -32601, "message": "Method not found"}, } )
- Interface/protocol definition specifying the get_character_profile method signature.async def get_character_profile(self, character_name: str) -> str: """Get character profile information.""" ...