Skip to content
context-engine
Tools

smart_read

Read exact inclusive line ranges from a known file.

Use smart_read when you know the exact 1-based inclusive ranges to inspect.

Use when

  • A diagnostic or review identifies precise lines.
  • You need a small set of ranges from one file.

Do not use when

  • You need to discover containing symbols; use line_context or outline.
  • You need a definition from a visible identifier; use jump.

Request

{"file":"/workspace/project/src/lib.rs","lines":[{"start":40,"end":58}],"output_mode":"type_annotated","workspace_root":"/workspace/project"}

Parameters

FieldRequiredDefault / bounds
fileyesPath (file_path is accepted as an alias).
linesno[] reads the complete file (reserve for small files); each start ≥ 1.
lines[].endnoOmitted means through end of file; ranges are 1-based and inclusive.
output_modenotype_annotated; union: type_annotated, plain_text, both.
workspace_rootnoOnly needed when multiple workspaces are active.

What it returns

The requested file ranges. Type-annotated output uses resolved LSP inlay hints and falls back to plain text with a short per-range note when hints are unavailable.

Example

Real output — a plain ranged read, still annotated:

53|impl UpstreamError {
54|    pub(crate) fn into_mcp_error(self) -> McpError {
55|        match self {
56|            Self::Mcp(error/*: ErrorData*/) => error,
57|            Self::Cancelled => McpError::internal_error(/*message: */"daemon request cancelled", /*data: */None),

Resolved types and call-site parameter names, even on the simplest read there is.

Common mistakes

  • Using zero-based or exclusive line numbers.
  • Omitting end unintentionally on a large file.
  • Reading an entire file when outline plus extract would be more targeted.
  • line_context finds the containing symbol when only a line is known.
  • outline maps a file before deciding what to read.
  • extract reads by symbol identity instead of line coordinates.