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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
file | string | ✓ | — | Relative file path within the repository (e.g. src/auth/login.py). |
repo | string | auto | Repository in owner/repo format. Omit to auto-select when only one repo is indexed. | |
branch | string | default | Git branch to read from. Omit to use the repo's default branch. | |
start_line | integer | 1 | First line to return (1-indexed, inclusive). | |
end_line | integer | — | Last line to return (1-indexed, inclusive). Omit to read up to 500 lines from start_line. | |
function | string | — | Function 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_lineto 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:
Read an exact function by name:
Notes
- This isn't a first step — call
search_codeorget_file_treefirst to identify which files matter, then read them withget_source. - For full source of a result you just searched,
expand_resultis more direct.