Get file contents
get_file_contentsReads file contents from a Forgejo, Codeberg, or Gitea repository by owner, repo, and path, with optional ref and line range; also lists directory contents.
Instructions
Read a file's contents from a repository (owner/repo/path, optional ref); decodes text, lists directories. Optional start_line/end_line take a 1-indexed inclusive window, clamped to the file; total_lines is always reported so you can page through a large file instead of pulling it whole.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"owner": "<owner>",
"repo": "<repo>",
"path": "<path>"
},
"name": "get_file_contents"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ref | No | Branch, tag, or commit to read from. Defaults to the repository's default branch. | |
| path | Yes | Path to the file within the repository, e.g. `src/main.rs`. | |
| repo | Yes | Repository name. | |
| owner | Yes | Repository owner — user or organization. | |
| end_line | No | Last line to return, 1-indexed and inclusive. Omit to read to the end of the file. | |
| start_line | No | First line to return, 1-indexed and inclusive. Omit to start at the top of the file. |