Tools
line_context
Read meaningful source context around exact file and line locations.
Use line_context for diagnostics, logs, search hits, stack traces, or user-provided file:line references when you need the containing source items and parent hierarchy.
Use when
- You know exact files and 1-based lines but not the containing symbol.
- You need context around up to 32 related locations.
Do not use when
- You already know an exact range; use
smart_read. - You need to resolve a visible identifier; use
jump.
Request
{"locations":[{"file":"/workspace/project/src/lib.rs","line":42}],"include_docs":false,"output_mode":"type_annotated","workspace_root":"/workspace/project"}Parameters
| Field | Required | Default / bounds |
|---|---|---|
locations | yes | 1–32 entries; each line is a 1-based integer ≥ 1. |
locations[].file | yes | Non-empty path (file_path is not the nested field name). |
include_docs | no | false. |
output_mode | no | type_annotated; union: type_annotated, plain_text, both. |
workspace_root | no | Active workspace routing. |
What it returns
Complete meaningful source items or document sections containing each location, including parent hierarchy. Type-annotated output falls back to plain text with a per-range note when inlay hints are unavailable.
Common mistakes
- Sending zero-based lines or quoting the line number.
- Sending more than 32 locations in one request.
- Enabling
include_docswhen documentation is not needed.
Related tools
smart_read, jump, hover, outline