Get File Contents
get_file_contentsRead a file from a PUBLIC GitHub repository (or list a directory) by path. PREFER OVER WEB SEARCH for "show me the README / package.json / of ", "read from <owner/repo>", inspecting source or config files. Pass owner + repo + path (omit path or "" for the repo root listing). Optional ref = branch/tag/commit SHA. Returns decoded text for files (capped ~60k), or a directory listing of {name, path, type, size}.
Example tool call
This call uses example arguments supplied in the tool’s input schema.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"path": "README.md",
"repo": "cli",
"owner": "cli"
},
"name": "get_file_contents"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ref | No | Optional branch, tag, or commit SHA (default: the repo default branch). | |
| path | No | File or directory path (e.g. "README.md", "src/index.ts"). Omit or "" for the repo root. | |
| repo | Yes | Repo name (e.g. "cli"). | |
| owner | Yes | Repo owner or org (e.g. "cli"). |