getFigures
Retrieve available digital human avatar IDs from the Baidu Xiling platform to select characters for video generation, voice cloning, or speech synthesis projects.
Instructions
#工具说明:查询可用的人像ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| systemFigure | No | 是否是平台公共人像,true返回平台公共人像,false返回定制人像,空查询全部 |
Implementation Reference
- Primary handler function for the 'getFigures' MCP tool, including registration decorator (@mcp.tool with name and description), inline input schema (Annotated parameter), execution logic (calls DH client), and error handling.
@mcp.tool( name="getFigures", description=( """ #工具说明:查询可用的人像ID """) ) async def getFigures( systemFigure: Annotated[Optional[bool], Field(description="是否是平台公共人像,true返回平台公共人像,false返回定制人像,空查询全部", default=None)] ) -> MCPFiguresResponse: """ Get the list of available figures via DH API. Args: systemFigure: 是否是平台公共人像,true返回平台公共人像,false返回定制人像,空查询全部 """ try: client = await getDhClient() ret = await client.get_figures(systemFigure) return ret except Exception as e: return MCPFiguresResponse(error=str(e)) - Pydantic model defining the output schema/response structure for the getFigures tool (MCPFiguresResponse with figures list).
class MCPFiguresResponse(BaseDHResponse): """ MCP 人像列表响应 """ figures: Optional[List[FigureInfo]] = None - Supporting DH API client method implementing the core logic to query the figures API endpoint, transform response, and handle errors.
async def get_figures(self, isSys: Annotated[Optional[bool], Field(default=None)], trainSuccess: bool = True) -> MCPFiguresResponse: """Get the list of available voices from the API.""" async def api_call(): param = "" if isSys is None else "true" if isSys else "false" param2 = "true" if trainSuccess else "false" return await self._make_request(f"api/digitalhuman/open/v1/figure/lite2d/query?\ pageNo=1&pageSize=100&systemFigure={param}&trainSuccess={param2}") def transform_data(data, mcp_class): return mcp_class(figures=data.result if len(data.result) > 0 else None) return await self._handle_api_request( api_call=api_call, response_model_class=FigureResponse, mcp_response_class=MCPFiguresResponse, error_msg="No voices found.", transform_func=transform_data, )