Skip to main content
Glama

githubGetFileContent

Idempotent

Read file contents or download directories from GitHub repositories to analyze code patterns, configs, or full source context.

Instructions

Read GitHub file or download directory [EXTERNAL: GitHub API]

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queriesYesResearch queries for githubGetFileContent (1-3 queries per call for optimal resource management). Review schema before use for optimal results
responseCharOffsetNoCharacter offset for top-level bulk response pagination across results[]. Use when a multi-query response was auto-paginated.
responseCharLengthNoCharacter budget for top-level bulk response pagination across results[]. Overrides the shared default for this call.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultsYesArray of results, one per input query, discriminated by status
responsePaginationNoPagination metadata for top-level bulk response pagination across results[]

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed26 schema fields changedv9.1.1
    • removedInput schema / properties / queries / items / additionalProperties
      Removed value: -false
    • addedInput schema / properties / queries / items / properties / branch / description
      Added value: +"Branch/tag/SHA (optional, defaults to default branch)"
    • addedInput schema / properties / queries / items / properties / charLength / description
      Added value: +"Max chars per page. Default: 20000"
    • addedInput schema / properties / queries / items / properties / charOffset / description
      Added value: +"Pagination offset. Default: 0"
    • addedInput schema / properties / queries / items / properties / charOffset / maximum
      Added value: +9007199254740991
    • addedInput schema / properties / queries / items / properties / endLine / description
      Added value: +"End line (with startLine). File mode only"
    • addedInput schema / properties / queries / items / properties / endLine / maximum
      Added value: +9007199254740991
    • addedInput schema / properties / queries / items / properties / forceRefresh
      Added value: +{
      +  "default": false,
      +  "description": "When true, bypass the cache and force a fresh fetch even if a valid cached copy exists. Only relevant for type \"directory\".",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / queries / items / properties / fullContent / description
      Added value: +"Return entire file (default: false). File mode only"
    • addedInput schema / properties / queries / items / properties / id
      Added value: +{
      +  "description": "Stable query identifier used to match each result to its input query. Required for every query. Use a short meaningful string like \"react_hooks_search\" or \"router_prs\".",
      +  "maxLength": 120,
      +  "minLength": 1,
      +  "pattern": "^[A-Za-z0-9._:-]+$",
      +  "type": "string"
      +}
    • addedInput schema / properties / queries / items / properties / mainResearchGoal / description
      Added value: +"Main research objective (multiple queries can share the same main goal for semantic grouping and session tracking)"
    • addedInput schema / properties / queries / items / properties / matchString / description
      Added value: +"Search pattern to extract. File mode only"
    • addedInput schema / properties / queries / items / properties / matchString / maxLength
      Added value: +2000
    • addedInput schema / properties / queries / items / properties / matchStringContextLines / description
      Added value: +"Context around matches (1-50). Default: 5"
    • addedInput schema / properties / queries / items / properties / owner / description
      Added value: +"Repo owner"
    • addedInput schema / properties / queries / items / properties / path / description
      Added value: +"File or directory path from root, no leading slash, exact case"
    • addedInput schema / properties / queries / items / properties / reasoning / description
      Added value: +"Why this query helps achieve the goal"
    • addedInput schema / properties / queries / items / properties / repo / description
      Added value: +"Repo name"
    • addedInput schema / properties / queries / items / properties / researchGoal / description
      Added value: +"Specific information this query seeks"
    • addedInput schema / properties / queries / items / properties / startLine / description
      Added value: +"Start line (with endLine). File mode only"
    • addedInput schema / properties / queries / items / properties / startLine / maximum
      Added value: +9007199254740991
    • addedInput schema / properties / queries / items / properties / type
      Added value: +{
      +  "default": "file",
      +  "description": "Choose ONE: \"file\" (default) returns content inline; \"directory\" saves all files to disk and returns localPath. Directory mode requires ENABLE_LOCAL=true and ENABLE_CLONE=true, and is only available with the GitHub provider (not GitLab).",
      +  "enum": [
      +    "file",
      +    "directory"
      +  ],
      +  "type": "string"
      +}
    • changedInput schema / properties / queries / items / required
      Previous value: -[
      -  "mainResearchGoal",
      -  "researchGoal",
      -  "reasoning",
      -  "owner",
      -  "repo",
      -  "path"
      -]New value: +[
      +  "id",
      +  "mainResearchGoal",
      +  "researchGoal",
      +  "reasoning",
      +  "owner",
      +  "repo",
      +  "path"
      +]
    • addedInput schema / properties / responseCharLength
      Added value: +{
      +  "description": "Character budget for top-level bulk response pagination across results[]. Overrides the shared default for this call.",
      +  "maximum": 50000,
      +  "minimum": 1,
      +  "type": "integer"
      +}
    • addedInput schema / properties / responseCharOffset
      Added value: +{
      +  "description": "Character offset for top-level bulk response pagination across results[]. Use when a multi-query response was auto-paginated.",
      +  "maximum": 9007199254740991,
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": false,
      +  "properties": {
      +    "responsePagination": {
      +      "additionalProperties": false,
      +      "description": "Pagination metadata for top-level bulk response pagination across results[]",
      +      "properties": {
      +        "charLength": {
      +          "description": "Character length of the current page",
      +          "maximum": 9007199254740991,
      +          "minimum": 0,
      +          "type": "integer"
      +        },
      +        "charOffset": {
      +          "description": "Character offset of the current page",
      +          "maximum": 9007199254740991,
      +          "minimum": 0,
      +          "type": "integer"
      +        },
      +        "currentPage": {
      +          "description": "Current page number (1-indexed)",
      +          "exclusiveMinimum": 0,
      +          "maximum": 9007199254740991,
      +          "type": "integer"
      +        },
      +        "hasMore": {
      +          "description": "Whether more pages are available after the current page",
      +          "type": "boolean"
      +        },
      +        "totalChars": {
      +          "description": "Total number of characters in the full output",
      +          "maximum": 9007199254740991,
      +          "minimum": 0,
      +          "type": "integer"
      +        },
      +        "totalPages": {
      +          "description": "Total number of pages available",
      +          "exclusiveMinimum": 0,
      +          "maximum": 9007199254740991,
      +          "type": "integer"
      +        }
      +      },
      +      "required": [
      +        "currentPage",
      +        "totalPages",
      +        "hasMore",
      +        "charOffset",
      +        "charLength",
      +        "totalChars"
      +      ],
      +      "type": "object"
      +    },
      +    "results": {
      +      "description": "Array of results, one per input query, discriminated by status",
      +      "items": {
      +        "anyOf": [
      +          {
      +            "additionalProperties": false,
      +            "properties": {
      +              "data": {
      +                "additionalProperties": false,
      +                "description": "The tool-specific result data",
      +                "properties": {
      +                  "cached": {
      +                    "description": "Whether a cached fetch was reused",
      +                    "type": "boolean"
      +                  },
      +                  "content": {
      +                    "description": "File content as text for single-file requests",
      +                    "type": "string"
      +                  },
      +                  "endLine": {
      +                    "description": "Ending line number of the returned content",
      +                    "exclusiveMinimum": 0,
      +                    "maximum": 9007199254740991,
      +                    "type": "integer"
      +                  },
      +                  "fileCount": {
      +                    "description": "Number of files fetched in directory mode",
      +                    "maximum": 9007199254740991,
      +                    "minimum": 0,
      +                    "type": "integer"
      +                  },
      +                  "files": {
      +                    "description": "Files fetched in directory mode",
      +                    "items": {
      +                      "additionalProperties": false,
      +                      "properties": {
      +                        "path": {
      +                          "description": "Relative path within the fetched directory",
      +                          "type": "string"
      +                        },
      +                        "size": {
      +                          "description": "File size in bytes",
      +                          "maximum": 9007199254740991,
      +                          "minimum": 0,
      +                          "type": "integer"
      +                        },
      +                        "type": {
      +                          "const": "file",
      +                          "description": "Directory fetch only returns files",
      +                          "type": "string"
      +                        }
      +                      },
      +                      "required": [
      +                        "path",
      +                        "size",
      +                        "type"
      +                      ],
      +                      "type": "object"
      +                    },
      +                    "type": "array"
      +                  },
      +                  "hints": {
      +                    "description": "Contextual hints and suggestions for next steps or better queries",
      +                    "items": {
      +                      "type": "string"
      +                    },
      +                    "type": "array"
      +                  },
      +                  "isPartial": {
      +                    "description": "Whether the returned file content is partial",
      +                    "type": "boolean"
      +                  },
      +                  "lastModified": {
      +                    "description": "Last modified timestamp for the file",
      +                    "type": "string"
      +                  },
      +                  "lastModifiedBy": {
      +                    "description": "Author of the last file modification",
      +                    "type": "string"
      +                  },
      +                  "localPath": {
      +                    "description": "Local filesystem path for directory fetch mode",
      +                    "type": "string"
      +                  },
      +                  "pagination": {
      +                    "additionalProperties": false,
      +                    "description": "Pagination metadata for partial file content",
      +                    "properties": {
      +                      "byteLength": {
      +                        "description": "Byte length of the current page",
      +                        "maximum": 9007199254740991,
      +                        "minimum": 0,
      +                        "type": "integer"
      +                      },
      +                      "byteOffset": {
      +                        "description": "Byte offset of the current page",
      +                        "maximum": 9007199254740991,
      +                        "minimum": 0,
      +                        "type": "integer"
      +                      },
      +                      "charLength": {
      +                        "description": "Character length of the current page",
      +                        "maximum": 9007199254740991,
      +                        "minimum": 0,
      +                        "type": "integer"
      +                      },
      +                      "charOffset": {
      +                        "description": "Character offset of the current page",
      +                        "maximum": 9007199254740991,
      +                        "minimum": 0,
      +                        "type": "integer"
      +                      },
      +                      "currentPage": {
      +                        "description": "Current page number (1-indexed)",
      +                        "exclusiveMinimum": 0,
      +                        "maximum": 9007199254740991,
      +                        "type": "integer"
      +                      },
      +                      "hasMore": {
      +                        "description": "Whether more pages are available after the current page",
      +                        "type": "boolean"
      +                      },
      +                      "totalBytes": {
      +                        "description": "Total number of bytes in the full output",
      +                        "maximum": 9007199254740991,
      +                        "minimum": 0,
      +                        "type": "integer"
      +                      },
      +                      "totalChars": {
      +                        "description": "Total number of characters in the full output",
      +                        "maximum": 9007199254740991,
      +                        "minimum": 0,
      +                        "type": "integer"
      +                      },
      +                      "totalPages": {
      +                        "description": "Total number of pages available",
      +                        "exclusiveMinimum": 0,
      +                        "maximum": 9007199254740991,
      +                        "type": "integer"
      +                      }
      +                    },
      +                    "required": [
      +                      "currentPage",
      +                      "totalPages",
      +                      "hasMore"
      +                    ],
      +                    "type": "object"
      +                  },
      +                  "resolvedBranch": {
      +                    "description": "Resolved branch used to fetch the content when it adds new information beyond the input query",
      +                    "type": "string"
      +                  },
      +                  "startLine": {
      +                    "description": "Starting line number of the returned content",
      +                    "exclusiveMinimum": 0,
      +                    "maximum": 9007199254740991,
      +                    "type": "integer"
      +                  },
      +                  "totalSize": {
      +                    "description": "Total fetched size in bytes",
      +                    "maximum": 9007199254740991,
      +                    "minimum": 0,
      +                    "type": "integer"
      +                  }
      +                },
      +                "type": "object"
      +              },
      +              "id": {
      +                "description": "Stable query identifier matching the input query id",
      +                "minLength": 1,
      +                "type": "string"
      +              },
      +              "status": {
      +                "const": "hasResults",
      +                "description": "Indicates the query returned results successfully",
      +                "type": "string"
      +              }
      +            },
      +            "required": [
      +              "id",
      +              "status",
      +              "data"
      +            ],
      +            "type": "object"
      +          },
      +          {
      +            "additionalProperties": false,
      +            "properties": {
      +              "data": {
      +                "additionalProperties": {},
      +                "description": "Empty result metadata (may contain hints or paging details)",
      +                "properties": {},
      +                "type": "object"
      +              },
      +              "id": {
      +                "description": "Stable query identifier matching the input query id",
      +                "minLength": 1,
      +                "type": "string"
      +              },
      +              "status": {
      +                "const": "empty",
      +                "description": "Indicates the query returned no matching results",
      +                "type": "string"
      +              }
      +            },
      +            "required": [
      +              "id",
      +              "status",
      +              "data"
      +            ],
      +            "type": "object"
      +          },
      +          {
      +            "additionalProperties": false,
      +            "properties": {
      +              "data": {
      +                "additionalProperties": false,
      +                "description": "Error details including message, type, and recovery hints",
      +                "properties": {
      +                  "cwd": {
      +                    "description": "Working directory relevant to the error",
      +                    "type": "string"
      +                  },
      +                  "error": {
      +                    "anyOf": [
      +                      {
      +                        "type": "string"
      +                      },
      +                      {
      +                        "additionalProperties": false,
      +                        "properties": {
      +                          "error": {
      +                            "description": "GitHub API error message",
      +                            "type": "string"
      +                          },
      +                          "hints": {
      +                            "description": "Provider-specific hints",
      +                            "items": {
      +                              "type": "string"
      +                            },
      +                            "type": "array"
      +                          },
      +                          "rateLimitRemaining": {
      +                            "description": "Remaining API requests in the current rate limit window",
      +                            "type": "number"
      +                          },
      +                          "rateLimitReset": {
      +                            "description": "Rate limit reset time in milliseconds since epoch",
      +                            "type": "number"
      +                          },
      +                          "retryAfter": {
      +                            "description": "Retry-after delay in seconds",
      +                            "type": "number"
      +                          },
      +                          "scopesSuggestion": {
      +                            "description": "Suggested scopes needed to resolve the error",
      +                            "type": "string"
      +                          },
      +                          "status": {
      +                            "description": "HTTP status code",
      +                            "maximum": 9007199254740991,
      +                            "minimum": -9007199254740991,
      +                            "type": "integer"
      +                          },
      +                          "type": {
      +                            "description": "GitHub API error category",
      +                            "enum": [
      +                              "http",
      +                              "graphql",
      +                              "network",
      +                              "unknown"
      +                            ],
      +                            "type": "string"
      +                          }
      +                        },
      +                        "required": [
      +                          "error",
      +                          "type"
      +                        ],
      +                        "type": "object"
      +                      }
      +                    ],
      +                    "description": "Error message or API error object"
      +                  },
      +                  "errorCode": {
      +                    "description": "Tool error code",
      +                    "type": "string"
      +                  },
      +                  "errorType": {
      +                    "description": "Tool-specific error type (e.g. symbol_not_found, size_limit)",
      +                    "type": "string"
      +                  },
      +                  "hints": {
      +                    "description": "Recovery hints",
      +                    "items": {
      +                      "type": "string"
      +                    },
      +                    "type": "array"
      +                  },
      +                  "resolvedPath": {
      +                    "description": "Resolved filesystem path involved in the error",
      +                    "type": "string"
      +                  },
      +                  "searchRadius": {
      +                    "description": "LSP search radius when symbol not found",
      +                    "type": "number"
      +                  }
      +                },
      +                "required": [
      +                  "error"
      +                ],
      +                "type": "object"
      +              },
      +              "id": {
      +                "description": "Stable query identifier matching the input query id",
      +                "minLength": 1,
      +                "type": "string"
      +              },
      +              "status": {
      +                "const": "error",
      +                "description": "Indicates the query encountered an error",
      +                "type": "string"
      +              }
      +            },
      +            "required": [
      +              "id",
      +              "status",
      +              "data"
      +            ],
      +            "type": "object"
      +          }
      +        ]
      +      },
      +      "type": "array"
      +    }
      +  },
      +  "required": [
      +    "results"
      +  ],
      +  "type": "object"
      +}
  2. Changed27 schema fields changedv1.0.0
    • changedInput schema / properties / queries / description
      Previous value: -"Array of up to 5 different file fetch queries for parallel execution"New value: +"Research queries for githubGetFileContent (1-3 queries per call for optimal resource management). Review schema before use for optimal results"
    • removedInput schema / properties / queries / items / properties / branch / description
      Removed value: -"Branch name, tag name, OR commit SHA. Tool will automatically try 'main' and 'master' if specified branch is not found."
    • removedInput schema / properties / queries / items / properties / branch / pattern
      Removed value: -"^[^\\s]+$"
    • addedInput schema / properties / queries / items / properties / charLength
      Added value: +{
      +  "maximum": 50000,
      +  "minimum": 50,
      +  "type": "integer"
      +}
    • addedInput schema / properties / queries / items / properties / charOffset
      Added value: +{
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • removedInput schema / properties / queries / items / properties / contextLines
      Removed value: -{
      -  "default": 5,
      -  "description": "Context lines around target range. Default: 5.",
      -  "maximum": 50,
      -  "minimum": 0,
      -  "type": "integer"
      -}
    • removedInput schema / properties / queries / items / properties / endLine / description
      Removed value: -"Ending line number (1-based) for partial file access. Use with startLine to fetch only specific sections and save tokens."
    • removedInput schema / properties / queries / items / properties / fallbackParams
      Removed value: -{
      -  "additionalProperties": false,
      -  "description": "Fallback parameters if original query returns no results",
      -  "properties": {
      -    "branch": {
      -      "type": "string"
      -    },
      -    "contextLines": {
      -      "maximum": 50,
      -      "minimum": 0,
      -      "type": "integer"
      -    },
      -    "endLine": {
      -      "minimum": 1,
      -      "type": "integer"
      -    },
      -    "filePath": {
      -      "type": "string"
      -    },
      -    "minified": {
      -      "type": "boolean"
      -    },
      -    "startLine": {
      -      "minimum": 1,
      -      "type": "integer"
      -    }
      -  },
      -  "type": "object"
      -}
    • removedInput schema / properties / queries / items / properties / filePath
      Removed value: -{
      -  "description": "File path from repository root (e.g., 'src/index.js', 'README.md', 'docs/api.md'). Do NOT start with slash.",
      -  "minLength": 1,
      -  "type": "string"
      -}
    • addedInput schema / properties / queries / items / properties / fullContent
      Added value: +{
      +  "default": false,
      +  "type": "boolean"
      +}
    • removedInput schema / properties / queries / items / properties / id
      Removed value: -{
      -  "description": "Optional identifier for the query",
      -  "type": "string"
      -}
    • addedInput schema / properties / queries / items / properties / mainResearchGoal
      Added value: +{
      +  "type": "string"
      +}
    • addedInput schema / properties / queries / items / properties / matchString
      Added value: +{
      +  "type": "string"
      +}
    • addedInput schema / properties / queries / items / properties / matchStringContextLines
      Added value: +{
      +  "default": 5,
      +  "maximum": 50,
      +  "minimum": 1,
      +  "type": "integer"
      +}
    • removedInput schema / properties / queries / items / properties / minified
      Removed value: -{
      -  "default": true,
      -  "description": "Optimize content for token efficiency (enabled by default). Removes excessive whitespace and comments. Set to false only when exact formatting is required.",
      -  "type": "boolean"
      -}
    • removedInput schema / properties / queries / items / properties / owner / description
      Removed value: -"Repository owner/organization name (e.g., 'facebook', 'microsoft'). Do NOT include repository name here."
    • changedInput schema / properties / queries / items / properties / owner / maxLength
      Previous value: -100New value: +200
    • removedInput schema / properties / queries / items / properties / owner / pattern
      Removed value: -"^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?$"
    • addedInput schema / properties / queries / items / properties / path
      Added value: +{
      +  "type": "string"
      +}
    • addedInput schema / properties / queries / items / properties / reasoning
      Added value: +{
      +  "type": "string"
      +}
    • removedInput schema / properties / queries / items / properties / repo / description
      Removed value: -"Repository name only (e.g., 'react', 'vscode'). Do NOT include owner/org prefix."
    • changedInput schema / properties / queries / items / properties / repo / maxLength
      Previous value: -100New value: +150
    • removedInput schema / properties / queries / items / properties / repo / pattern
      Removed value: -"^[a-zA-Z0-9._-]+$"
    • addedInput schema / properties / queries / items / properties / researchGoal
      Added value: +{
      +  "type": "string"
      +}
    • removedInput schema / properties / queries / items / properties / startLine / description
      Removed value: -"Starting line number (1-based) for partial file access. STRONGLY RECOMMENDED to save tokens instead of fetching full file content."
    • changedInput schema / properties / queries / items / required
      Previous value: -[
      -  "owner",
      -  "repo",
      -  "branch",
      -  "filePath"
      -]New value: +[
      +  "mainResearchGoal",
      +  "researchGoal",
      +  "reasoning",
      +  "owner",
      +  "repo",
      +  "path"
      +]
    • changedInput schema / properties / queries / maxItems
      Previous value: -5New value: +3
  3. First observed

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds significant behavioral details beyond annotations: file returns content inline, directory saves to disk and returns localPath. It discloses limits (300KB max, branch naming), input constraints (mutually exclusive params), and mode-specific behaviors. No contradiction with annotations (idempotentHint=true, destructiveHint=false).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description uses a well-organized structure with headings (<when>, <fromTool>, etc.) that front-load the main purpose and allow quick scanning. While lengthy due to necessary detail (gotchas, examples), every section adds value and the conciseness is appropriate for the complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers all aspects for effective use: when to use, how to use (modes, params), pitfalls (gotchas), examples, and integration with siblings. It mentions prerequisites for directory mode (ENABLE_LOCAL, ENABLE_CLONE) and the file size limit. The output schema exists separately, so return values are omitted by design.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already has 100% description coverage, but the description adds value by explaining the three mutually exclusive file modes (matchString, startLine+endLine, fullContent) and the pagination parameters (charOffset, charLength) in the <gotchas> and <modes> sections, enhancing practical usage understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool reads a GitHub file or downloads a directory, with specific verbs ('read', 'download') and resource ('GitHub file or directory'). It distinguishes from siblings like githubSearchCode (search) and githubViewRepoStructure (structure), and the title 'GitHub File Content Fetch' reinforces the purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The <when> section provides clear contexts (e.g., read from known path, download directory). The <fromTool> and <toTool> sections guide use in conjunction with other tools. However, it lacks explicit 'when not to use' guidance, though the modes and gotchas imply exclusions (e.g., directory mode requires specific flags).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/bgauryy/octocode'

If you have feedback or need assistance with the MCP directory API, please join our Discord server