Skip to main content
Glama
SiroSuzume

MCP ts-morph Refactoring Tools

by SiroSuzume

remove_path_alias_by_tsmorph

Converts TypeScript path alias imports and exports to relative paths using tsconfig.json path mappings, enabling standardization on relative paths for a codebase subset.

Instructions

[ts-morph] Convert path-alias imports/exports (e.g., @/components/Button) to relative paths (../../components/Button) within a target file or directory.

When to use

  • Standardizing on relative paths for a subset of the codebase.

  • Preparing for a large rename_filesystem_entry_by_tsmorph run when you want to control alias rewriting explicitly (note: rename_filesystem_entry_by_tsmorph already rewrites aliases to relative paths automatically; run this tool first only if you want the conversion to be a separate, reviewable commit).

  • Prefer this over manual find/replace -- relative path computation is error-prone across nested directories.

When NOT to use

  • The project has no paths mapping in tsconfig.json (this tool has nothing to do).

  • You want to ADD aliases or change one alias to another (not supported).

Critical constraints

  • Aliases are read from the paths option of the project's tsconfig.json. Only those aliases are resolved.

  • targetPath may be a single file OR a directory. Directory targets process every .ts/.tsx file under it.

  • All paths (tsconfigPath, targetPath) MUST be absolute.

Tips

  • Run with dryRun: true first when applying to a directory, to confirm the scope.

Result

Returns the list of modified (or to-be-modified, in dryRun) file paths, plus status and processing time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tsconfigPathYesAbsolute path to the project's tsconfig.json file.
targetPathYesAbsolute path to the target file or directory.
dryRunNoIf true, only show intended changes without modifying files.
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description fully discloses behavior: reads aliases from tsconfig.json, processes .ts/.tsx files, requires absolute paths, supports dry run, and returns result list. It also notes that renaming tool automatically converts aliases, setting expectations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Description is well-structured with sections and bullet points, making it easy to scan. Front-loaded with main action. Slightly verbose but every part earns its place. Could be slightly more concise, but still effective.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description covers all necessary context: explains the conversion, constraints, result format, and usage tips. Adequate for the tool's complexity (3 params, no output schema). No gaps identified.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, but the description adds context beyond schema: explains that aliases are resolved from tsconfig.json, that targetPath can be file or directory, and the meaning of dryRun. This adds value beyond the parameter descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Convert') and resource ('path-alias imports/exports'), and distinguishes from sibling tool `rename_filesystem_entry_by_tsmorph` by noting that tool already rewrites aliases automatically. Clearly states what the tool does.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit 'When to use' and 'When NOT to use' sections provide clear guidance, including alternatives like `rename_filesystem_entry_by_tsmorph` and conditions like no `paths` mapping. Tips for dry run add practical usage advice.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SiroSuzume/mcp-ts-morph'

If you have feedback or need assistance with the MCP directory API, please join our Discord server