find_references_by_tsmorph
Analyze a TypeScript project to locate the definition and all references of a symbol by specifying its position in a file. Essential for understanding the impact of refactoring changes.
Instructions
[Uses ts-morph] Finds the definition and all references to a symbol at a given position throughout the project.
Analyzes the project based on tsconfig.json
to locate the definition and all usages of the symbol (function, variable, class, etc.) specified by its position.
Usage
Use this tool before refactoring to understand the impact of changing a specific symbol. It helps identify where a function is called, where a variable is used, etc.
- Specify the absolute path to the project's
tsconfig.json
. - Specify the absolute path to the file containing the symbol you want to investigate.
- Specify the exact position (line and column) of the symbol within the file.
Parameters
- tsconfigPath (string, required): Absolute path to the project's root
tsconfig.json
file. Essential for ts-morph to parse the project. Must be an absolute path. - targetFilePath (string, required): The absolute path to the file containing the symbol to find references for. Must be an absolute path.
- position (object, required): The exact position of the symbol to find references for.
- line (number, required): 1-based line number.
- column (number, required): 1-based column number.
Result
- On success: Returns a message containing the definition location (if found) and a list of reference locations (file path, line number, column number, and line text).
- On failure: Returns a message indicating the error.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
position | Yes | The exact position of the symbol. | |
targetFilePath | Yes | Absolute path to the file containing the symbol. | |
tsconfigPath | Yes | Absolute path to the project's tsconfig.json file. |
Input Schema (JSON Schema)
You must be authenticated.
Other Tools from MCP ts-morph Refactoring Tools
Related Tools
- @SiroSuzume/mcp-ts-morph
- @SiroSuzume/mcp-ts-morph
- @SiroSuzume/mcp-ts-morph
- @bsmi021/mcp-node-omnibus-server
- @bsmi021/mcp-node-omnibus-server