Read a file or directory
forgejo_get_fileRead a file's contents or list a directory's entries from a Forgejo repository at a chosen branch, tag, or SHA.
Instructions
Reads a text file's contents, or lists a directory, at a given revision.
Parameters:
owner, repo (optional when defaults are configured)
path (string, required): path from the repository root, e.g. 'lib/filters.ts'; '' or '.' for the root
ref (string, optional): branch, tag or SHA. Defaults to the main branch
response_format
Returns, for a file: { type: 'file', path, size, sha, content, truncated, html_url } Returns, for a directory: { type: 'directory', path, entries: [{ name, type, size }] }
Binary files are not decoded: their size and SHA are returned with an explicit note. Contents are truncated past the context limit and the cut is reported.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ref | No | Branch, tag or SHA. Defaults to the main branch. | |
| path | No | File or directory path. Empty = root. | |
| repo | No | Repository name. Defaults to FORGEJO_DEFAULT_REPO. | |
| owner | No | Repository owner (user or organisation). Defaults to FORGEJO_DEFAULT_OWNER. | |
| response_format | No | 'markdown' for a readable rendering, 'json' for the full data. | markdown |