Skip to main content
Glama
AST-Navigator-MCP

AST-Navigator-MCP

Find Definition

find_definition
Read-onlyIdempotent

Locate where any class, function, method, interface, type alias or enum is defined by name across JavaScript/TypeScript files. Searches parsed declarations, so call sites, comments and strings never match.

Instructions

Find where classes, functions, methods, interfaces, type aliases and enums are DEFINED, by name, across every JavaScript/TypeScript file under a directory (recursive). Matching runs on parsed declarations, not raw text, so call sites, comments and strings never match.

Use it to jump from a symbol name to its definition(s), then call get_file_structure on a returned filePath for surrounding context. Not for finding usages/references.

Args:

  • name (string): symbol to find, e.g. "UserService", "parseConfig", or a qualified method "UserService.create".

  • directory (string, optional): directory to search; required (no server root configured).

  • matchMode ('exact' | 'prefix' | 'contains'): default 'exact'.

  • caseSensitive (boolean): default true.

  • kinds (array, optional): any of class, function, method, interface, type_alias, enum.

  • limit (1-200, default 50) and offset (default 0): pagination.

  • responseFormat ('markdown' | 'json'): default 'markdown'.

Returns (structuredContent): { query, directory, matchMode, total, count, offset, hasMore, nextOffset?, filesScanned, filesParsed, skippedFiles, scanTruncated, results[{ name, qualifiedName, kind, container?, exported, signature?, filePath, startLine, endLine }] } Results are ordered by relevance (exact match first), then file path and line.

Examples:

  • "Where is UserService defined?" -> { name: "UserService", kinds: ["class"] }

  • "Which functions start with handle?" -> { name: "handle", matchMode: "prefix", kinds: ["function", "method"] }

Skipped while scanning: node_modules, bower_components, jspm_packages, dist, build, out, coverage, vendor, tmp, dot-directories (.git, .next, ...), symbolic links, minified bundles and files over 2 MiB. A scan stops after 20000 files (scanTruncated=true).

Errors (isError=true, text starts with 'Error [CODE]'): FILE_NOT_FOUND, NOT_A_DIRECTORY, MISSING_DIRECTORY, PERMISSION_DENIED, PATH_OUTSIDE_ROOTS, INVALID_PATH.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "name": "<name>"
    },
    "name": "find_definition"
  }
}

Input Schema

NameRequiredDescriptionDefault
nameYesSymbol to find, e.g. 'UserService', 'parseConfig', or a qualified method name 'UserService.create'.
kindsNoOnly return these definition kinds: class, function, method, interface, type_alias, enum. Omit for all.
limitNoMaximum results to return (1-200, default 50).
offsetNoResults to skip, for pagination (default 0).
directoryNoDirectory searched recursively. Absolute path recommended. Defaults to the server's first allowed root.
matchModeNo'exact' (default), 'prefix' (name starts with) or 'contains' (substring).exact
caseSensitiveNoCase-sensitive matching (default true).
responseFormatNo'markdown' (default): compact outline for reading. 'json': full structured data.markdown

Output Schema

NameRequiredDescriptionDefault
countYesMatches in this page
queryYes
totalYesTotal matches found
offsetYes
hasMoreYes
resultsYes
directoryYesAbsolute directory that was searched
matchModeYes
nextOffsetNoOffset for the next page, when hasMore
filesParsedYesFiles that mentioned the name and were parsed
filesScannedYesCandidate source files found under the directory
skippedFilesYesFiles skipped because they were unreadable or too large
scanTruncatedYesTrue if the scan stopped at the file limit; search a narrower directory

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, idempotentHint, and non-destructive, so the safety profile carries little weight. The description does add genuine behavioral context beyond that: a hard 20000-file scan ceiling with scanTruncated=true, directory exclusions (node_modules, dist, symlinks, >2 MiB files), a documented error code list, and result ordering by relevance then path/line. Those are real operational constraints an agent could not infer from annotations; the score reflects that annotations already cover most of the safety surface, leaving the description to add scanning semantics rather than core behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the purpose and exclusion in the first two paragraphs, then organized into Args/Returns/Examples/Skipped/Errors sections that scan cleanly. It is on the long side and the Args block duplicates schema text verbatim, which is wasted space against a 100%-covered schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For an 8-parameter search tool with an output schema, the description covers everything an agent needs: matching semantics, scanning limits and exclusions, result ordering, error codes, and the natural follow-on tool. The Returns block restates the output schema but also supplies ordering information the schema does not.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3; the description earns one above baseline by giving concrete symbol examples ('"UserService", "parseConfig", or a qualified method "UserService.create"') and by flagging that directory is effectively required when no server root is configured — a constraint the schema states only as a default. The remaining Args entries largely restate the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource with precise scope: 'Find where classes, functions, methods, interfaces, type aliases and enums are DEFINED, by name, across every JavaScript/TypeScript file under a directory (recursive).' It further narrows the semantics ('parsed declarations, not raw text') so an agent immediately understands this is AST-based, not grep-based.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly names the follow-on workflow ('call get_file_structure on a returned filePath for surrounding context') and an explicit exclusion ('Not for finding usages/references'). The two worked examples map natural-language intents to argument sets, which resolves ambiguity about when prefix mode or kinds filters are appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.