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);

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