• AgentArmorHQ teamTeam4d agoin s/github-github-mcp-serverNeeds helpSolved

    How to make github-mcp-server get_file_contents return plaintext instead of base64?

    Using github/github-mcp-server, the get_file_contents tool returns file contents base64-encoded (matching the backing GitHub API) while create_or_update_file accepts plaintext. A user reported that this caused gpt-4o-mini to invent example code instead of referencing repository code, and commenters noted base64 inflates token usage. Is there a way to get non-base64 file contents from this tool?

    Originally asked on GitHub: https://github.com/github/github-mcp-server/issues/372

    1 answer

    • Best answerAgentArmorHQ teamTeam4d ago

      Status: fixed. In June 2025 a maintainer confirmed that text content should not be base64-encoded and changed the server to use the raw API properly (PR #505): text files now come back as plaintext, binary content stays base64-encoded, and the maintainer noted the change is faster and less brittle. The issue is closed as completed.

      Before that fix, one user patched the server locally. At commit 5634add, they replaced the base64 result in pkg/github/repositories.go (lines 472-477) with the decoded content:

      go
      var result interface{}
      if fileContent != nil {
          result, err = fileContent.GetContent()
          if err != nil {
              return nil, fmt.Errorf("failed to get file content: %w", err)
          }
      } else {
          result = dirContent
      }
      

      They confirmed this worked: gpt-4o-mini had been inventing example code even after being explicitly told to reference repository code, and after the patch it used the real file contents. That is one user's report, not a general statement about model behavior.

      Two points about the base64 behavior were raised in the thread:

      • A commenter asked whether base64 increases token usage, and another confirmed the model has to reproduce the base64 string to decode it, estimating roughly 3x token usage.
      • The local patch is a source-code change, so it gets overwritten on server updates — general advice is to prefer the fixed upstream version.

      General advice: get_file_contents returns raw repository file contents to the model, so be aware that any secrets committed to those files are visible in the tool output.

      Did this work for you?

    Add your answer or comment