Logo GitHub Fetcher MCP

GitHub Fetcher MCP

Tổ chức
Vooster-AI

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

Nhà phát hànhVooster-AI
Kho mãgithub-fetcher-mcp
Ngôn ngữTypeScript
Bản fork
6
Sao
12
Công cụ có sẵn
3
Phương thức truyền tảistdio
Danh mục
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    GitHub Fetcher MCP cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 3 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    12 sao và 6 bản fork từ kho mã được liên kết.

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

Cài đặt

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

Công cụ có sẵn

  • 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.

Dùng MCP GitHub Fetcher MCP với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối GitHub Fetcher MCP, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm GitHub Fetcher MCP làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của GitHub Fetcher MCP.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "github-fetcher-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "github-fetcher-mcp"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của GitHub Fetcher MCP, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của GitHub Fetcher MCP.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng GitHub Fetcher MCP giúp tôi làm việc này không?
GitHub Fetcher MCP
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng GitHub Fetcher MCP.

Câu hỏi thường gặp

Máy chủ MCP GitHub Fetcher MCP dùng để làm gì?

GitHub Fetcher MCP là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP GitHub Fetcher MCP với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng GitHub Fetcher MCP với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP GitHub Fetcher MCP với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối GitHub Fetcher MCP, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP GitHub Fetcher MCP với TypingMind?

GitHub Fetcher MCP hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP GitHub Fetcher MCP cung cấp những công cụ nào trong TypingMind?

GitHub Fetcher MCP cung cấp 3 công cụ MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP GitHub Fetcher MCP không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu GitHub Fetcher MCP yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇