Skip to content
context-engine
Tools

extract

Read a selected view from registered Context Engine handles.

Use extract after another Context Engine tool returns handles and its API or context is insufficient. Each handle advertises its available views with their line counts — ["1000t00b" full 124L | code 48L | docs 76L] — so the cost of a view is known before requesting it.

Use when

  • You need implementation, documentation, imports, or a complete selected item.
  • You want resolved inline type annotations for a handle.

Do not use when

  • You need an exact physical line range; use smart_read.
  • You have only a file path or symbol name and no handle.

Request

{"handles":["0004r00o"],"view":"code","output_mode":"type_annotated"}

Parameters

FieldRequiredDefault / bounds
handlesno[]; handles come from Context Engine results.
viewnofull; union: full, code, docs, module-docs, imports.
output_modenotype_annotated; union: type_annotated, plain_text, both.

What it returns

The selected source view for each handle. code reads declarations and implementations; docs reads documentation; full combines the complete item or file; imports reads imports/directives; module-docs reads module-level documentation. Type-annotated output falls back to plain text with a note when LSP inlay hints are unavailable.

Example

Real output, condensed — one method extracted by handle with view: "code", with the language server's knowledge inlined:

# context-engine-server/src/connector/handler.rs

66|    async fn list_tools(
67|        &self,
68|        request: Option<PaginatedRequestParams>,
69|        context: RequestContext<RoleServer>,
70|    ) -> Result<ListToolsResult, McpError> {
71|        let mut result/*: ListToolsResult*/ = self/*: &ConnectorHandler*/
72|            .upstream/*: UpstreamClient*/
73|            .list_tools(/*params: */request, /*request_meta: */context.meta.clone(), /*cancellation: */&context.ct)
74|            .await/*: Result<ListToolsResult, UpstreamError>*/
75|            .map_err(UpstreamError::into_mcp_error)?;

One method instead of the whole file — and every binding carries its resolved type, every call site its real parameter names, woven in as /*: Type*/ annotations.

Common mistakes

  • Guessing handles instead of copying registered handles from a result.
  • Asking for full when code or docs is sufficient and costly output is unnecessary.
  • Reusing a handle after a rename, move, parent-chain, or signature change; obtain a fresh handle.
  • outline produces handles for a known file.
  • grep_definition produces handles from a name search.
  • jump produces handles from a visible source occurrence.
  • smart_read reads exact physical line ranges instead of symbol views.