CleanClean
MCP Tools

get_source

Read source code directly from an indexed repository, by line range or by exact function name.

get_source reads source straight from an indexed repo and returns it with line numbers. Use it after search_code to read a file you identified, after get_file_tree to open a specific file, or to read config and non-code files.

Inputs

NameTypeRequiredDefaultDescription
filestringRelative file path within the repository (e.g. src/auth/login.py).
repostringautoRepository in owner/repo format. Omit to auto-select when only one repo is indexed.
branchstringdefaultGit branch to read from. Omit to use the repo's default branch.
start_lineinteger1First line to return (1-indexed, inclusive).
end_lineintegerLast line to return (1-indexed, inclusive). Omit to read up to 500 lines from start_line.
functionstringFunction or class name to read. Looks the entity up in the index and reads its exact line range — overrides start_line/end_line.

Line limits

  • Line numbers are 1-indexed and inclusive.
  • A plain file read returns at most 500 lines per call. For larger files, pass start_line/end_line to window into a section.
  • When you pass function=, the cap is raised to 2000 lines so even large entities come back whole.

The response header shows File, the line range, the total line count, and a truncation note when the file is longer than what was returned.

Examples

Read a specific window of a file:

{ "name": "get_source", "arguments": { "file": "src/auth/login.py", "start_line": 40, "end_line": 90 } }

Read an exact function by name:

{ "name": "get_source", "arguments": { "file": "app/dashboard/usage.tsx", "function": "TokenSavingsCard" } }

Notes

  • This isn't a first step — call search_code or get_file_tree first to identify which files matter, then read them with get_source.
  • For full source of a result you just searched, expand_result is more direct.

On this page