Get File Structure (AST outline)
get_file_structureOutline a JavaScript/TypeScript file's imports, classes, functions, and types with line ranges and signatures to reveal its API and dependencies without reading the whole file.
Instructions
Outline one JavaScript/TypeScript source file from its Tree-sitter syntax tree: imports (ESM, CommonJS require, re-exports), classes with their properties and methods, top-level functions (declarations, arrow functions, function expressions, CommonJS exports) and TypeScript interfaces / type aliases / enums, each with 1-based line ranges and signatures exactly as written.
Use it to learn a file's API and dependencies without reading the whole file, and to find which lines to read next. It does not return function bodies or nested local helpers.
Args:
filePath (string): file to analyse (.js .mjs .cjs .jsx .ts .mts .cts .tsx). Absolute path recommended.
responseFormat ('markdown' | 'json'): 'markdown' (default) is a compact outline; 'json' returns the full object.
Returns (structuredContent, identical to the 'json' text): { filePath, language, lineCount, hasSyntaxErrors, syntaxErrorLines[], imports[{ source, kind: esm|commonjs|re-export, typeOnly, specifiers[{ kind, name, importedName? }], line }], classes[{ name, exported, defaultExport, abstract, extends?, implements[], properties[{ name, static, readonly, visibility?, type?, line }], methods[{ name, kind: constructor|method|getter|setter, static, async, abstract, visibility?, signature, startLine, endLine }], startLine, endLine }], functions[{ name, kind: function|generator|arrow|function_expression|signature, async, exported, defaultExport, signature, startLine, endLine }], types[{ name, kind: interface|type_alias|enum, exported, startLine, endLine }] }
Examples:
"What does src/server.ts export?" -> { filePath: "/repo/src/server.ts" }
Need exact field values for code generation -> add responseFormat: "json"
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. Unsupported extensions are rejected by input validation. If hasSyntaxErrors is true the outline is best-effort.
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": "get_file_structure"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Source file to outline. Absolute path recommended, e.g. 'C:\repo\src\index.ts' or '/home/me/repo/src/index.ts'. Relative paths resolve against the server's first allowed root. | |
| responseFormat | No | 'markdown' (default): compact outline for reading. 'json': full structured data. | markdown |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| types | Yes | TypeScript interfaces, type aliases and enums | |
| classes | Yes | ||
| imports | Yes | ||
| filePath | Yes | Absolute path of the analysed file | |
| language | Yes | Grammar used to parse the file | |
| functions | Yes | ||
| lineCount | Yes | ||
| hasSyntaxErrors | Yes | Tree-sitter recovered from syntax errors; the outline may be incomplete | |
| syntaxErrorLines | Yes | First lines where syntax errors were detected |