GitHub Fetcher MCP 标志

GitHub Fetcher MCP

组织
Vooster-AI

MCP (Model Context Protocol) server for fetching GitHub repository files and directory trees.

发布者Vooster-AI
代码仓库github-fetcher-mcp
语言TypeScript
复刻数
6
星标数
12
可用工具
3
传输类型stdio
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    GitHub Fetcher MCP 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 3 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 12 个 Star 和 6 个 Fork。

GitHub Fetcher MCP

npm version License: MIT Node.js Version TypeScript Tests

MCP (Model Context Protocol) server for fetching GitHub repository files and directory trees.

Features

  • fetch-file: Fetch raw file content from GitHub repositories
  • fetch-subdir-tree: Fetch directory tree structure in unix tree format
  • fetch-sub-tree ⭐ NEW: Enhanced directory tree with file sizes, depth limits, statistics, and filtering
  • Flexible configuration via CLI arguments or per-request parameters
  • Built with TypeScript for type safety
  • Comprehensive test coverage (79 tests)

Installation

NPM

bash
npm install -g github-fetcher-mcp

Smithery

To install GitHub Fetcher MCP Server for any client automatically via Smithery:

bash
npx -y @smithery/cli@latest install github-fetcher-mcp --client <CLIENT_NAME>

Available clients: cursor, claude, vscode, windsurf, cline, zed, etc.

Example for Cursor:

bash
npx -y @smithery/cli@latest install github-fetcher-mcp --client cursor

This will automatically configure the MCP server in your chosen client.

MCP Client Integration

GitHub Fetcher MCP can be integrated with various AI coding assistants and IDEs that support the Model Context Protocol (MCP).

Requirements

  • Node.js >= v18.0.0
  • An MCP-compatible client (Cursor, Claude Code, VS Code, Windsurf, etc.)

Go to: Settings -> Cursor Settings -> MCP -> Add new global MCP server

Add the following configuration to your ~/.cursor/mcp.json file:

json
{
  "mcpServers": {
    "github-fetcher": {
      "command": "npx",
      "args": ["-y", "github-fetcher-mcp", "--repoIdentifier", "facebook/react/main"]
    }
  }
}

Without repoIdentifier (specify repository per request):

json
{
  "mcpServers": {
    "github-fetcher": {
      "command": "npx",
      "args": ["-y", "github-fetcher-mcp"]
    }
  }
}

Run this command:

sh
claude mcp add github-fetcher -- npx -y github-fetcher-mcp --repoIdentifier facebook/react/main

Or without repoIdentifier:

sh
claude mcp add github-fetcher -- npx -y github-fetcher-mcp

Add this to your VS Code MCP config file. See VS Code MCP docs for more info.

json
"mcp": {
  "servers": {
    "github-fetcher": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "github-fetcher-mcp", "--repoIdentifier", "facebook/react/main"]
    }
  }
}

Add this to your Windsurf MCP config file:

json
{
  "mcpServers": {
    "github-fetcher": {
      "command": "npx",
      "args": ["-y", "github-fetcher-mcp", "--repoIdentifier", "facebook/react/main"]
    }
  }
}
  1. Open Cline
  2. Click the hamburger menu icon (☰) to enter the MCP Servers section
  3. Choose Remote Servers tab
  4. Click the Edit Configuration button
  5. Add github-fetcher to mcpServers:
json
{
  "mcpServers": {
    "github-fetcher": {
      "command": "npx",
      "args": ["-y", "github-fetcher-mcp", "--repoIdentifier", "facebook/react/main"]
    }
  }
}

Open Claude Desktop developer settings and edit your claude_desktop_config.json file:

json
{
  "mcpServers": {
    "github-fetcher": {
      "command": "npx",
      "args": ["-y", "github-fetcher-mcp", "--repoIdentifier", "facebook/react/main"]
    }
  }
}

Add this to your Zed settings.json:

json
{
  "context_servers": {
    "github-fetcher": {
      "source": "custom",
      "command": "npx",
      "args": ["-y", "github-fetcher-mcp", "--repoIdentifier", "facebook/react/main"]
    }
  }
}

Add this to your Roo Code MCP configuration file:

json
{
  "mcpServers": {
    "github-fetcher": {
      "command": "npx",
      "args": ["-y", "github-fetcher-mcp", "--repoIdentifier", "facebook/react/main"]
    }
  }
}
json
{
  "mcpServers": {
    "github-fetcher": {
      "command": "bunx",
      "args": ["-y", "github-fetcher-mcp", "--repoIdentifier", "facebook/react/main"]
    }
  }
}

Build the Docker Image:

Create a Dockerfile:

dockerfile
FROM node:18-alpine

WORKDIR /app

# Install the package globally
RUN npm install -g github-fetcher-mcp

# Expose the server port
EXPOSE 3000

# Default command to run the server
CMD ["github-fetcher-mcp"]

Build the image:

bash
docker build -t github-fetcher-mcp .

Configure Your MCP Client:

json
{
  "mcpServers": {
    "github-fetcher": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "-p", "3000:3000", "github-fetcher-mcp", "--repoIdentifier", "facebook/react/main"]
    }
  }
}

Usage

With Repository Identifier (CLI Argument)

When you provide a --repoIdentifier argument, all tools will use that repository by default:

bash
github-fetcher-mcp --repoIdentifier facebook/react/main

Tools available:

  • fetch-file: Requires only filePath
  • fetch-subdir-tree: Requires only dirPath
  • fetch-sub-tree: Requires only dirPath (+ optional: showSize, maxDepth, showStats, fileExtFilter)

Without Repository Identifier

When no repository identifier is provided, you can specify the repository for each request:

bash
github-fetcher-mcp

Tools available:

  • fetch-file: Requires ownerName, repoName, branchName (optional, default: 'main'), and filePath
  • fetch-subdir-tree: Requires ownerName, repoName, branchName (optional, default: 'main'), and dirPath
  • fetch-sub-tree: Requires ownerName, repoName, branchName (optional, default: 'main'), dirPath (+ optional: showSize, maxDepth, showStats, fileExtFilter)

Available Tools

GitHub Fetcher MCP provides the following tools that can be used by LLMs:

  • fetch-file: Fetches the raw content of a file from a GitHub repository

    • Required parameters vary based on whether --repoIdentifier is provided
    • Returns the complete file content as text
  • fetch-subdir-tree: Fetches directory tree structure in unix tree format

    • Required parameters vary based on whether --repoIdentifier is provided
    • Returns formatted directory tree showing files and subdirectories
  • fetch-sub-tree ⭐ NEW: Enhanced version with advanced options

    • Required parameters vary based on whether --repoIdentifier is provided
    • Optional parameters:
      • showSize (boolean): Show file and directory sizes
      • maxDepth (number): Limit tree depth (e.g., 1 for immediate children only)
      • showStats (boolean): Show statistics summary (default: true)
      • fileExtFilter (string[]): Filter files by extensions (e.g., [".ts", ".js"])
    • Returns enhanced directory tree with optional file sizes and statistics

Usage Examples

Example 1: Fetch a specific file

In Cursor/Claude Code:

Fetch the package.json file from the facebook/react repository on the main branch

In any MCP client (with repoIdentifier configured):

Show me the contents of src/index.ts

Example 2: Browse directory structure

In Cursor/Claude Code:

Show me the directory structure of the src folder in microsoft/vscode on the main branch

In any MCP client (with repoIdentifier configured):

What files are in the components directory?

Example 3: Analyze code structure

In Cursor/Claude Code:

I want to understand the structure of the Next.js repository.
Show me the directory tree of the packages folder from vercel/next.js on the canary branch.
Then fetch the package.json file to see the dependencies.

Tool Reference

fetch-file

Fetches the raw content of a file from a GitHub repository.

With repoIdentifier:

json
{
  "filePath": "src/index.ts"
}

Without repoIdentifier:

json
{
  "ownerName": "facebook",
  "repoName": "react",
  "branchName": "main",
  "filePath": "src/index.ts"
}

fetch-subdir-tree

Fetches directory tree structure in unix tree format.

With repoIdentifier:

json
{
  "dirPath": "src"
}

Without repoIdentifier:

json
{
  "ownerName": "microsoft",
  "repoName": "vscode",
  "branchName": "main",
  "dirPath": "src"
}

fetch-sub-tree ⭐ NEW

Enhanced directory tree with file sizes, depth limits, and filtering options.

With repoIdentifier - Basic usage:

json
{
  "dirPath": "src"
}

With repoIdentifier - Show file sizes:

json
{
  "dirPath": "src",
  "showSize": true
}

With repoIdentifier - Limit depth:

json
{
  "dirPath": "src",
  "maxDepth": 2
}

With repoIdentifier - Filter by file extensions:

json
{
  "dirPath": "src",
  "fileExtFilter": [".ts", ".tsx"]
}

With repoIdentifier - All options:

json
{
  "dirPath": "src",
  "showSize": true,
  "maxDepth": 3,
  "showStats": true,
  "fileExtFilter": [".ts", ".js"]
}

Example Output (with showSize and showStats):

src/
├── components/ (2 files, 15.3KB)
│   ├── Button.tsx (8.2KB)
│   └── Input.tsx (7.1KB)
└── utils/ (3 files, 5.8KB)
    ├── helpers.ts (2.1KB)
    ├── format.ts (1.9KB)
    └── validate.ts (1.8KB)

📊 Summary: 2 directories, 5 files, 21.1KB total

Without repoIdentifier:

json
{
  "ownerName": "microsoft",
  "repoName": "vscode",
  "branchName": "main",
  "dirPath": "src",
  "showSize": true,
  "maxDepth": 2
}

Docker Usage

Build Docker Image

bash
docker build -t github-fetcher-mcp .

Run with Docker

With repoIdentifier:

bash
docker run -d -p 3000:3000 \
  --name github-fetcher \
  github-fetcher-mcp \
  node dist/server.js --repoIdentifier facebook/react/main

Without repoIdentifier:

bash
docker run -d -p 3000:3000 \
  --name github-fetcher \
  github-fetcher-mcp

Docker Compose Example

Create a docker-compose.yml:

yaml
version: '3.8'

services:
  github-fetcher-mcp:
    build: .
    ports:
      - "3000:3000"
    environment:
      - PORT=3000
      - NODE_ENV=production
    command: ["node", "dist/server.js", "--repoIdentifier", "facebook/react/main"]
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/mcp', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
      interval: 30s
      timeout: 3s
      retries: 3
      start_period: 5s

Run with Docker Compose:

bash
docker-compose up -d

Use Docker Image in MCP Clients

Configure your MCP client to use the Docker container:

json
{
  "mcpServers": {
    "github-fetcher": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "github-fetcher-mcp",
        "node",
        "dist/server.js",
        "--repoIdentifier",
        "facebook/react/main"
      ]
    }
  }
}

Development

bash
# Install dependencies
npm install

# Run in development mode
npm run dev

# Run tests
npm test

# Build
npm run build

# Type check
npm run typecheck

# Lint
npm run lint

Architecture

The project follows a modular architecture:

  • config/: CLI argument parsing
  • services/: GitHub API integration and tree formatting
  • tools/: MCP tool implementations
  • types/: TypeScript type definitions
  • utils/: Utility functions

Testing

The project has comprehensive test coverage:

  • Unit tests for all services, tools, and utilities
  • Integration tests for tool creation
  • 79 total tests, all passing
bash
# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Generate coverage report
npm run test:coverage

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

choesumin

安装

TypingMind
{
  "mcpServers": {
    "github-fetcher-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "github-fetcher-mcp",
        "--repoIdentifier",
        "facebook/react/main"
      ],
      "env": {
        "repoIdentifier": "<repoIdentifier>"
      }
    }
  }
}

可用工具

  • fetch-file

    Fetches file content from GitHub repository facebook/react/main

  • fetch-subdir-tree

    Fetches directory tree from GitHub repository facebook/react/main

  • fetch-sub-tree

    Fetches enhanced directory tree with options from GitHub repository facebook/react/main. Supports file sizes, depth limits, statistics, and extension filtering.

将 GitHub Fetcher MCP MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 GitHub Fetcher MCP 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请保持终端窗口及其中的进程运行。
3

将 GitHub Fetcher MCP 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 GitHub Fetcher MCP MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "github-fetcher-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "github-fetcher-mcp"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 GitHub Fetcher MCP MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 GitHub Fetcher MCP MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 GitHub Fetcher MCP 帮我完成这项任务吗?
GitHub Fetcher MCP
当然。我已阅读。
以下是我使用 GitHub Fetcher MCP 得到的结果。

常见问题

GitHub Fetcher MCP MCP 服务器有什么用途?

GitHub Fetcher MCP 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 GitHub Fetcher MCP MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您可以让 Claude、ChatGPT、Gemini 等不同 AI 模型,或您在 TypingMind 中配置的其他模型使用 GitHub Fetcher MCP,而无需为每个模型单独配置 MCP 服务器。

为什么在 TypingMind 中使用 GitHub Fetcher MCP MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是优秀的大语言模型聊天前端之一。连接 GitHub Fetcher MCP 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 GitHub Fetcher MCP MCP 连接到 TypingMind?

GitHub Fetcher MCP 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

GitHub Fetcher MCP MCP 在 TypingMind 中提供哪些工具?

GitHub Fetcher MCP 提供 3 个 MCP 工具,您可以在 TypingMind 的插件页面启用这些工具,然后在聊天中使用,或将其分配给 AI 智能体。

使用 GitHub Fetcher MCP MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行掌控模型提供商、API 密钥、提示词和 MCP 配置。如果 GitHub Fetcher MCP 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇