Skip to main content
← MCP Tools

get_dependencies

Return the files and modules that a given file imports. Set transitive: true to follow depends edges recursively up to depth hops.

Availability: single-repo stdio (travsr mcp), global stdio (travsr mcp --global), and SSE (travsr serve).

Input schema​

{
"type": "object",
"required": ["file"],
"properties": {
"file": {
"type": "string",
"description": "Repo-relative file path to look up dependencies for"
},
"transitive": {
"type": "boolean",
"description": "Follow dependency edges recursively. Default: false (direct imports only)."
},
"depth": {
"type": "integer",
"minimum": 1,
"maximum": 10,
"description": "Max hops when transitive=true. Default: 3."
},
"repo": {
"type": "string",
"description": "Repo name (run repos_list to discover). Only present in global (multi-repo) sessions and on SSE."
}
},
"additionalProperties": false
}

In a global (travsr mcp --global) session and over SSE the tool takes only file and repo: transitive and depth are single-repo stdio parameters, and the global form lists direct dependencies.

There is no kind (import/require/use/include) or external field on a result: an edge is either a direct dependency or it isn't, and the response does not distinguish a local module from a third-party package.

Output format​

Plain text, one dependency per line, not a direct/transitive object split. Each line is the destination node's own stored label, not a resolved file path: for every indexed language, the depends edge from a file goes straight to an unresolved import node (the file never gets a direct depends edge to the file it imports; that hop is a separate resolves-to edge this tool does not follow). So a line normally shows the raw specifier as written in the source, not a clean repo-relative path. The prefix depends on the language's import node: a TypeScript file shows lines like import:./PaymentService or import:express, while a Rust file shows use: lines, for example use:unicode_segmentation::UnicodeSegmentation.

Direct mode (the default) lists each immediate import node's label with no prefix, capped at 25; past the cap the list ends with a [showing 25 of N; ...] note pointing at get_context or transitive=true for full coverage. Transitive mode does one BFS over depends edges, hop by hop: a direct dependency has no prefix, and each deeper hop is indented with one more ↳ than the last (so a hop-2 result reads ↳ ↳ some/file.ts, not just extra spaces before a single arrow). In practice depth beyond 1 rarely adds anything for most languages, since an import node has no outgoing depends edge of its own to keep the BFS going; Go is the notable exception, where files in the same package carry direct file-to-file depends edges that do chain further.

If the argument does not resolve to a file at all (a symbol name passed by mistake, or an unknown path), the tool returns a one-line hint instead of an empty result, since an empty result for a bad argument would read as "this file has no dependencies".

Example​

Request:

{
"file": "src/controllers/PaymentController.ts",
"transitive": true,
"depth": 3
}

Response:

import:./PaymentService
import:./Order
import:express

No further hops appear here: import:./PaymentService and the other two are unresolved import nodes with no depends edge of their own, so transitive: true and depth: 3 change nothing for this file. A repo where hops do chain (for example Go co-package siblings) would show deeper entries indented ↳ ↳ some/file.go per additional hop.

Response, argument is not a file:

'PaymentController' resolved to class 'PaymentController', not a file; get_dependencies takes a repo-relative file path. For a symbol, use get_callers or find_references.

When to use​

  • Before touching a file: understand what you're about to affect.
  • Circular dependency detection: in a repo where hops actually chain (see above), look for the file's own import specifier reappearing deeper in its dependency tree.
  • Bundle analysis: find which packages a module pulls in, direct or transitive.