Skip to content

get_file_contents fails on every file over 1 MB with "unsupported content encoding: none" #3417

Description

@jayhemnani9910

Describe the bug

Since v1.10.0, get_file_contents returns an error for any file of 1 MB or more instead of the "too large to display" resource link it returned before. The Contents API sends these files with "content": "" and "encoding": "none", and repositoryContentBytes (pkg/github/repositories_helper.go:220) calls GetContent() on that, which go-github rejects. This happens before the large-file branch at pkg/github/repositories.go:1118 is reached.

The existing "large file returns ResourceLink" tests mock the Contents API response without content/encoding fields, so they don't hit this.

Affected version

GitHub MCP Server
Version: 1.14.0
Commit: f10e4e1f923d46b86f2e80e849aa74084c847184
Build Date: 2026-10-02T17:00:10Z

Also reproduced on main at 71ef826. v1.9.0 works.

Steps to reproduce the behavior

  1. Run github-mcp-server stdio --read-only with a token.
  2. Call:
    {"method":"tools/call","params":{"name":"get_file_contents","arguments":{"owner":"torvalds","repo":"linux","path":"drivers/gpu/drm/amd/include/asic_reg/nbio/nbio_7_4_sh_mask.h"}}}
    (5,179,756 bytes; any file of 1 MB or more fails the same way, text or binary.)

Expected vs actual behavior

Expected (what v1.9.0 returns):

File drivers/gpu/drm/amd/include/asic_reg/nbio/nbio_7_4_sh_mask.h is too large to display (5179756 bytes). Use the download URL to fetch the content: https://raw.githubusercontent.com/torvalds/linux/a90ee43.../nbio_7_4_sh_mask.h (SHA: 07f04b2b...)

plus a resource_link.

Actual (v1.14.0, isError: true):

failed to inspect repository file: failed to decode file content: unsupported content encoding: none, this may occur when file size > 1 MB, if that is the case consider using DownloadContents

Logs

Contents API response for that file: {"type":"file","size":5179756,"encoding":"none","content":""}.

I have a small fix with a regression test ready and can open a PR: treat encoding: "none" as "content not returned", so the existing large-file path runs again.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions