Skip to main content
Glama
freefish1218

MCP HuggingFetch

by freefish1218

explore_huggingface_repo

Explore and visualize the directory structure of HuggingFace repositories to understand file organization and locate specific model components.

Instructions

探索 HuggingFace 仓库的目录结构,返回层级化的文件树

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_idYesHuggingFace 仓库 ID(格式:owner/repo)
revisionNoGit 分支或标签main
max_depthNo最大扫描深度
tree_viewNo是否生成ASCII树形视图

Implementation Reference

  • Main handler function for 'explore_huggingface_repo' tool. Validates input, configures options with 'explore' mode, calls downloader.list(), and returns formatted result or error.
    async callExploreTool(args) {
      try {
        // 基础验证
        if (!args.repo_id) {
          return CallToolResult.error(
            ToolContent.text('缺少必需参数: repo_id')
          );
        }
    
        logger.info(`探索仓库: ${args.repo_id}`);
    
        // 构建选项
        const options = {
          revision: args.revision,
          maxDepth: args.max_depth,
          mode: 'explore', // 探索模式
          treeView: args.tree_view,
          token: args.token || process.env.HF_TOKEN
        };
    
        // 执行探索
        const result = await this.downloader.list(args.repo_id, options);
    
        if (result.success) {
          logger.info(`探索完成: 深度${result.stats?.depth || 0}`);
          return CallToolResult.success(
            ToolContent.text(JSON.stringify(result, 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}`)
        );
      }
    }
  • Schema definition for 'explore_huggingface_repo' tool, including name, description, input properties (repo_id required, others optional), and JSON schema.
    getExploreTool() {
      return new Tool(
        'explore_huggingface_repo',
        '探索 HuggingFace 仓库的目录结构,返回层级化的文件树',
        {
          type: 'object',
          properties: {
            repo_id: {
              type: 'string',
              description: 'HuggingFace 仓库 ID(格式:owner/repo)',
              examples: ['2Noise/ChatTTS', 'microsoft/DialoGPT-medium']
            },
            revision: {
              type: 'string',
              description: 'Git 分支或标签',
              default: 'main'
            },
            max_depth: {
              type: 'integer',
              description: '最大扫描深度',
              default: 3
            },
            tree_view: {
              type: 'boolean',
              description: '是否生成ASCII树形视图',
              default: false
            }
          },
          required: ['repo_id']
        }
      );
    }
  • src/mcp/tools.js:24-31 (registration)
    Tool registration in getTools() method, which returns the list of available tools including explore_huggingface_repo via getExploreTool().
    getTools() {
      return [
        this.getDownloadTool(),
        this.getListTool(),
        this.getExploreTool(),
        this.getSearchTool()
      ];
    }
  • Dispatch registration in the callTool switch statement, mapping 'explore_huggingface_repo' to the callExploreTool handler.
    case 'explore_huggingface_repo':
      return await this.callExploreTool(args);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool explores directory structure and returns a hierarchical file tree, but lacks details on permissions, rate limits, error handling, or what happens with large repositories. For a tool with 4 parameters and no annotation coverage, this is a significant gap.

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 a single, efficient sentence in Chinese that front-loads the core purpose. Every word earns its place, with no redundant or vague phrasing, making it highly concise and well-structured.

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

Completeness3/5

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

Given 4 parameters, no annotations, and no output schema, the description is minimally adequate but incomplete. It covers the basic purpose but lacks behavioral context (e.g., performance, limitations) and output details. For a tool with moderate complexity, it should do more to compensate for missing structured data.

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 the schema fully documents all 4 parameters. The description adds no additional parameter semantics beyond what the schema provides (e.g., it doesn't explain how 'max_depth' affects traversal or what 'tree_view' output looks like). Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the specific action ('探索' meaning explore), the resource ('HuggingFace 仓库的目录结构'), and the output format ('返回层级化的文件树'). It distinguishes from sibling tools like 'download_huggingface_model' (which downloads), 'list_huggingface_files' (which might list without hierarchy), and 'search_huggingface_files' (which searches).

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 its siblings. It doesn't mention alternatives like 'list_huggingface_files' for flat listings or 'search_huggingface_files' for filtered searches, nor does it specify prerequisites or exclusions. Usage is implied only by the action described.

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