Skip to content
context-engine
Tools

grep_definition

Find semantic definitions by symbol name.

Use grep_definition when you know a symbol name but not its location. It searches semantic definitions in the workspace, rather than arbitrary text or references.

Use when

  • You need to discover an unknown symbol or file outline.
  • You want language- and kind-aware results before navigating further.

Do not use when

  • You have a visible source occurrence; use jump instead.
  • You need arbitrary text, comments, or usages; use text search or show_usage.

Request

{"requests":[{"queries":["UserService"],"language_id":"rust","kinds":["type"],"filter_params":{"include_paths":["src/**/*.rs"],"exclude_paths":[],"limit":20}}],"workspace_root":"/workspace/project"}

Parameters

FieldRequiredDefault / bounds
requestsyesOne or more query groups, with at most 32 queries across all groups.
requests[].queriesyesOne or more non-empty names; matching is case-insensitive and * enables glob matching.
requests[].language_idyesLSP language identifier.
requests[].kindsno[] (all); union of type, interface, function, module, member, event, constant.
requests[].filter_paramsnoInclude/exclude globs and optional limit; excludes win.
workspace_rootnoOnly needed when multiple workspaces are active.

kinds uses language-agnostic categories:

CategoryDefinitions included
typeClasses, structs, interfaces, and enums
interfaceInterfaces and objects
functionFunctions, methods, and constructors
moduleFiles, modules, namespaces, and packages
memberFields, properties, and enum members—not methods
eventEvents
constantConstants

What it returns

Definitions grouped by matching query, with paths, symbol kind, hierarchy, signatures, and handles when available. Multiple matches are valid; choose by path, parent hierarchy, and kind. A * query can return matching file outlines. Pass a relevant handle to extract for more detail.

Example

Real output — a glob search for *Upstream*, filtered to types:

## *Upstream* (rust, kinds: type)

## context-engine-server/src/connector/client.rs (2 matches)
- #[derive(Debug)] pub(crate) enum UpstreamError { ... } ["10001004" full 13L | code 7L | docs 6L] (line 46)
- #[derive(Clone)] pub(crate) struct UpstreamClient { ... } ["1000100l" full 14L | code 10L | docs 4L] (line 91)

Two definitions, and nothing else — no imports, no strings, no comments, no call sites that merely mention the name.

Common mistakes

  • Grouping queries with different languages, kinds, or filters in one request group.
  • Assuming the first match is the intended definition.
  • Using grep_definition for a dependency occurrence that jump can resolve precisely.
  • jump resolves a visible occurrence more precisely than a name search.
  • outline shows a matched file's complete structure.
  • extract reads a matched definition through its handle.
  • show_usage finds references instead of definitions.