Analyze Dependencies (local imports)
analyze_dependenciesList a JavaScript/TypeScript file's local dependencies by parsing its imports, re-exports, require calls, and dynamic imports.
Instructions
List the local files one JavaScript/TypeScript file depends on, from its Tree-sitter syntax tree: ES imports (including side-effect and import type), re-exports (export ... from), require() (also TypeScript import x = require()) and dynamic import(), anywhere in the file. Packages (node_modules), node: built-ins and path aliases are counted but not listed.
Use it to follow a module's dependency graph one file at a time, or to see what a file pulls in before changing it. It lists what a file imports, not which files import it.
Resolution mirrors TypeScript/Node.js for local specifiers: exact file, the .ts source behind a .js specifier, extension probing (.ts .tsx .d.ts .mts .cts .js .jsx .mjs .cjs .json) and directory index files. tsconfig 'paths' and package.json 'exports' are not read.
Args:
filePath (string): file to analyse (.js .mjs .cjs .jsx .ts .mts .cts .tsx). Absolute path recommended.
includeTypeOnly (boolean): include type-only references, erased at compile time (default true).
responseFormat ('markdown' | 'json'): 'markdown' (default) is a compact list; 'json' returns the full object.
Returns (structuredContent): { filePath, language, hasSyntaxErrors, dependencies[{ path, specifiers[], kinds[import|re-export|require|dynamic-import], typeOnly, lines[] }], unresolved[{ specifier, reason: not_found|outside_roots|invalid, kinds[], lines[] }], externalCount, nonLiteralCount, truncated } Dependencies are listed in order of first reference; several specifiers naming the same file are merged.
Examples:
"What does src/server.ts import from this repo?" -> { filePath: "/repo/src/server.ts" }
Runtime dependencies only -> add includeTypeOnly: false
Errors (isError=true, text starts with 'Error [CODE]'): FILE_NOT_FOUND, PERMISSION_DENIED, NOT_A_FILE, FILE_TOO_LARGE (> 2 MiB), PATH_OUTSIDE_ROOTS, INVALID_PATH. A dependency pointing outside the allowed roots is reported as unresolved with reason 'outside_roots'; its target is never revealed.
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": {
"filePath": "<filePath>"
},
"name": "analyze_dependencies"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Source file whose local dependencies to list. Absolute path recommended. Relative paths resolve against the server's first allowed root. | |
| responseFormat | No | 'markdown' (default): compact outline for reading. 'json': full structured data. | markdown |
| includeTypeOnly | No | Include `import type` / `export type ... from` references, which are erased at compile time (default true). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absolute path of the analysed file | |
| language | Yes | Grammar used to parse the file | |
| truncated | Yes | True if the file has more distinct local specifiers than are resolved per call | |
| unresolved | Yes | Local specifiers that do not resolve to a file inside the allowed roots | |
| dependencies | Yes | Local files this file loads, in order of first reference | |
| externalCount | Yes | Distinct non-local specifiers ignored: packages (node_modules), node: built-ins, path aliases | |
| hasSyntaxErrors | Yes | True if the file has syntax errors; references inside broken code may be missed | |
| nonLiteralCount | Yes | require()/import() calls with a computed argument, which cannot be followed statically |