Skip to main content
Glama
freefish1218

MCP HuggingFetch

by freefish1218

download_huggingface_model

Download Hugging Face models to your local machine with options for file filtering, revision selection, and custom directories.

Instructions

⚡ 高速下载 HuggingFace 模型到本地

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_idYesHuggingFace 仓库 ID(格式:owner/repo)
download_dirNo下载目录(默认:~/Downloads/huggingface_models)
revisionNoGit 分支或标签main
patternNo下载文件模式(例:*.safetensors)
excludeNo排除文件模式(例:*.bin)
filesNo指定下载的文件列表
max_filesNo最大下载文件数
forceNo强制重新下载
max_concurrentNo最大并发下载数

Implementation Reference

  • Primary execution logic for the download_huggingface_model tool. Validates arguments, prepares download options, invokes the downloader, and returns formatted success/error results.
    async callDownloadTool(args) {
      try {
        // 基础验证
        if (!args.repo_id) {
          return CallToolResult.error(
            ToolContent.text('缺少必需参数: repo_id')
          );
        }
    
        logger.info(`开始下载: ${args.repo_id}`);
    
        // 获取配置
        const config = getConfig();
        const downloadDir = args.download_dir || config.download_dir;
    
        // 构建目标目录
        const targetDir = require('path').join(
          downloadDir,
          args.repo_id.replace('/', '_')
        );
    
        // 构建选项
        const options = {
          revision: args.revision,
          pattern: args.pattern,
          exclude: args.exclude,
          files: args.files,
          maxFiles: args.max_files,
          force: args.force,
          maxConcurrent: args.max_concurrent,
          token: args.token || process.env.HF_TOKEN
        };
    
        // 执行下载
        const result = await this.downloader.download(
          args.repo_id,
          targetDir,
          options
        );
    
        if (result.success) {
          logger.info(`下载完成: ${result.files} 个文件`);
    
          const response = {
            success: true,
            repo_id: args.repo_id,
            path: result.path,
            files: result.files,
            size: result.size,
            duration: result.duration,
            suggestions: result.suggestions
          };
    
          return CallToolResult.success(
            ToolContent.text(JSON.stringify(response, null, 2))
          );
        } else {
          logger.error('下载失败:', result.error);
          return CallToolResult.error(
            ToolContent.text(JSON.stringify({
              success: false,
              error: result.error,
              suggestions: result.suggestions
            }, null, 2))
          );
        }
      } catch (error) {
        logger.error('工具调用失败:', error);
        return CallToolResult.error(
          ToolContent.text(`工具调用失败: ${error.message}`)
        );
      }
    }
  • Tool schema definition for 'download_huggingface_model', specifying input parameters, descriptions, defaults, and required fields.
    getDownloadTool() {
      return new Tool(
        'download_huggingface_model',
        '⚡ 高速下载 HuggingFace 模型到本地',
        {
          type: 'object',
          properties: {
            repo_id: {
              type: 'string',
              description: 'HuggingFace 仓库 ID(格式:owner/repo)',
              examples: ['2Noise/ChatTTS', 'microsoft/DialoGPT-medium']
            },
            download_dir: {
              type: 'string',
              description: '下载目录(默认:~/Downloads/huggingface_models)'
            },
            revision: {
              type: 'string',
              description: 'Git 分支或标签',
              default: 'main'
            },
            pattern: {
              type: 'string',
              description: '下载文件模式(例:*.safetensors)'
            },
            exclude: {
              type: 'string',
              description: '排除文件模式(例:*.bin)'
            },
            files: {
              type: 'array',
              items: { type: 'string' },
              description: '指定下载的文件列表'
            },
            max_files: {
              type: 'integer',
              description: '最大下载文件数',
              default: 100
            },
            force: {
              type: 'boolean',
              description: '强制重新下载',
              default: false
            },
            max_concurrent: {
              type: 'integer',
              description: '最大并发下载数',
              default: 5
            }
          },
          required: ['repo_id']
        }
      );
    }
  • Tool dispatch registration in callTool method, mapping 'download_huggingface_model' to its handler function.
    async callTool(name, args) {
      switch (name) {
      case 'download_huggingface_model':
        return await this.callDownloadTool(args);
      case 'list_huggingface_files':
        return await this.callListTool(args);
      case 'explore_huggingface_repo':
        return await this.callExploreTool(args);
      case 'search_huggingface_files':
        return await this.callSearchTool(args);
      default:
        return CallToolResult.error(
          ToolContent.text(`未知工具: ${name}`)
        );
      }
    }
  • src/mcp/tools.js:24-31 (registration)
    Registers the download tool by including getDownloadTool() in the list returned by getTools(), used by the MCP server.
    getTools() {
      return [
        this.getDownloadTool(),
        this.getListTool(),
        this.getExploreTool(),
        this.getSearchTool()
      ];
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions '高速下载' (high-speed download) which hints at performance, but doesn't cover critical aspects like: whether this requires authentication, network usage implications, disk space requirements, error handling, or what happens when files already exist (beyond the 'force' parameter). For a download operation with 9 parameters and no annotations, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single sentence with an emoji. It's front-loaded with the core action and contains no wasted words. Every element (emoji, action, resource, destination) serves a clear purpose in communicating the tool's function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 9 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what the tool returns, error conditions, performance characteristics beyond 'high-speed', or how it interacts with the HuggingFace ecosystem. The user must rely entirely on the input schema for operational details, which is insufficient for proper tool selection and usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so all parameters are documented in the schema. The description doesn't add any parameter-specific information beyond what's already in the schema descriptions. It only mentions the general action of downloading models to local storage, which doesn't provide additional semantic context for individual parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('高速下载' - high-speed download) and resource ('HuggingFace 模型' - HuggingFace models) with the destination ('到本地' - to local). It's specific about what the tool does, though it doesn't explicitly differentiate from sibling tools like explore_huggingface_repo or list_huggingface_files beyond the download action.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools, prerequisites, or specific scenarios where this download tool is preferred over other approaches. The user must infer usage from the action alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/freefish1218/mcp-huggingfetch'

If you have feedback or need assistance with the MCP directory API, please join our Discord server