Find Definition
find_definitionLocate 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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Symbol to find, e.g. 'UserService', 'parseConfig', or a qualified method name 'UserService.create'. | |
| kinds | No | Only return these definition kinds: class, function, method, interface, type_alias, enum. Omit for all. | |
| limit | No | Maximum results to return (1-200, default 50). | |
| offset | No | Results to skip, for pagination (default 0). | |
| directory | No | Directory searched recursively. Absolute path recommended. Defaults to the server's first allowed root. | |
| matchMode | No | 'exact' (default), 'prefix' (name starts with) or 'contains' (substring). | exact |
| caseSensitive | No | Case-sensitive matching (default true). | |
| responseFormat | No | 'markdown' (default): compact outline for reading. 'json': full structured data. | markdown |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | Yes | Matches in this page | |
| query | Yes | ||
| total | Yes | Total matches found | |
| offset | Yes | ||
| hasMore | Yes | ||
| results | Yes | ||
| directory | Yes | Absolute directory that was searched | |
| matchMode | Yes | ||
| nextOffset | No | Offset for the next page, when hasMore | |
| filesParsed | Yes | Files that mentioned the name and were parsed | |
| filesScanned | Yes | Candidate source files found under the directory | |
| skippedFiles | Yes | Files skipped because they were unreadable or too large | |
| scanTruncated | Yes | True if the scan stopped at the file limit; search a narrower directory |