search_mlx_models
Search and list MLX-format LLM models available on Hugging Face using keywords like 'llama' or 'qwen'.
Instructions
Hugging Faceからダウンロード可能なMLXフォーマットのLLMモデルを検索・リストアップします。
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "search_mlx_models"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| search_query | No | 検索キーワード(例: 'llama', 'qwen')。未指定の場合は人気のMLXモデルを返します。 | |
| limit | No | 取得する最大件数。デフォルトは10。 |
Implementation Reference
- src/mcp_mlx_launcher/server.py:131-190 (handler)Main handler for the search_mlx_models tool. Extracts arguments (search_query, limit), validates them, then uses HfApi.list_models with tag 'mlx' and sort by downloads to fetch results. Runs the blocking HF API call via asyncio.to_thread. Returns a JSON list of model IDs, downloads, and likes.
@server.call_tool() async def handle_call_tool( name: str, arguments: dict[str, Any] | None ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: """AIエージェントから呼び出されたツールを実際に実行します""" if arguments is None and name not in ("list_running_servers", "search_mlx_models", "check_system_environment"): raise ValueError("Arguments are required") if name == "check_system_environment": info = process_manager.get_system_info() return [types.TextContent(type="text", text=json.dumps(info, indent=2))] elif name == "check_llm_status": port = arguments.get("port") if not isinstance(port, int): raise ValueError("Port must be an integer") is_running = process_manager.is_port_in_use(port) return [types.TextContent(type="text", text=str(is_running).lower())] elif name == "list_running_servers": servers = process_manager.get_running_servers() if not servers: return [types.TextContent(type="text", text="No running servers found.")] return [types.TextContent(type="text", text=json.dumps(servers, indent=2))] elif name == "search_mlx_models": query = arguments.get("search_query") if arguments else None limit = arguments.get("limit", 10) if arguments else 10 if limit is not None and not isinstance(limit, int): raise ValueError("limit must be an integer") if query is not None and not isinstance(query, str): raise ValueError("search_query must be a string") def _search(): api = HfApi() models = api.list_models( search=query if query else None, tags="mlx", sort="downloads", direction=-1, limit=limit ) results = [] for m in models: results.append({ "modelId": m.id, "downloads": getattr(m, 'downloads', 0), "likes": getattr(m, 'likes', 0) }) return results try: results = await asyncio.to_thread(_search) if not results: return [types.TextContent(type="text", text="No MLX models found.")] return [types.TextContent(type="text", text=json.dumps(results, indent=2))] except Exception as e: return [types.TextContent(type="text", text=f"Error searching models: {str(e)}")] - src/mcp_mlx_launcher/server.py:48-63 (schema)Registration and input schema for search_mlx_models. Defines the tool name, description, and inputSchema with optional 'search_query' (string) and 'limit' (integer, default 10) properties.
types.Tool( name="search_mlx_models", description="Hugging Faceからダウンロード可能なMLXフォーマットのLLMモデルを検索・リストアップします。", inputSchema={ "type": "object", "properties": { "search_query": { "type": "string", "description": "検索キーワード(例: 'llama', 'qwen')。未指定の場合は人気のMLXモデルを返します。" }, "limit": { "type": "integer", "description": "取得する最大件数。デフォルトは10。" } }, }, - src/mcp_mlx_launcher/server.py:48-64 (registration)Tool registration inside handle_list_tools(). The search_mlx_models tool is listed alongside 7 other tools in the MCP tool registry.
types.Tool( name="search_mlx_models", description="Hugging Faceからダウンロード可能なMLXフォーマットのLLMモデルを検索・リストアップします。", inputSchema={ "type": "object", "properties": { "search_query": { "type": "string", "description": "検索キーワード(例: 'llama', 'qwen')。未指定の場合は人気のMLXモデルを返します。" }, "limit": { "type": "integer", "description": "取得する最大件数。デフォルトは10。" } }, }, ), - src/mcp_mlx_launcher/server.py:136-137 (registration)Special registration: search_mlx_models is exempted from the 'arguments required' check, since both search_query and limit are optional.
if arguments is None and name not in ("list_running_servers", "search_mlx_models", "check_system_environment"): raise ValueError("Arguments are required")