Refactor Mcp — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Refactor Mcp (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
A Model Context Protocol (MCP) server for automated refactoring of Java and TypeScript/JavaScript codebases. Uses OpenRewrite for Java refactoring and ts-morph for TypeScript.
null to call sites)# Clone the repository
git clone https://github.com/YOUR_USERNAME/refactor-mcp.git
cd refactor-mcp
# Install dependencies
npm install
# Build
npm run buildAdd to your Claude configuration file:
Claude Code (~/.claude/settings.json):
{
"mcpServers": {
"refactor": {
"command": "node",
"args": ["/path/to/refactor-mcp/build/index.js"]
}
}
}Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"refactor": {
"command": "node",
"args": ["/path/to/refactor-mcp/build/index.js"]
}
}
}For Java refactoring to work, your project needs the OpenRewrite Maven plugin in pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>5.44.0</version>
</plugin>
</plugins>
</build>Or for Gradle, add to build.gradle:
plugins {
id 'org.openrewrite.rewrite' version '6.25.0'
}All tools support a dryRun parameter (default: true) that previews changes without applying them.
Rename a class:
Rename com.example.UserService to com.example.CustomerServiceRename a method:
Rename method getUser to fetchUser in com.example.UserServiceMove classes to a new package:
Move all classes from com.example.old to com.example.newRename a symbol:
Rename UserService to CustomerService in the TypeScript projectMove a symbol to a different file:
Move the UserService class from user-service.ts to services/customer-service.tsExtract a function:
Extract lines 10-20 from utils.ts into a new function called processData| Tool | Description |
|---|---|
detect_project_type | Detect project type and build system |
java_rename_class | Rename a Java class |
java_rename_method | Rename a Java method |
java_rename_field | Rename a Java field |
java_move_class | Move Java class(es) to a different package |
java_add_parameter | Add a parameter to a Java method |
java_remove_parameter | Remove a parameter from a Java method |
java_reorder_parameters | Reorder parameters in a Java method |
typescript_rename_symbol | Rename any TypeScript symbol |
typescript_move_symbol | Move a symbol to a different file |
typescript_rename_file | Rename/move a TypeScript file |
typescript_extract_function | Extract code into a new function |
typescript_add_parameter | Add a parameter to a function |
typescript_remove_parameter | Remove a parameter from a function |
# Run in development mode
npm run dev
# Build
npm run build
# Run tests
npm testThe server generates OpenRewrite recipe YAML files dynamically and executes them via the Maven/Gradle plugin. This ensures type-safe refactoring with proper handling of imports, references, and edge cases.
Uses ts-morph to parse and manipulate the TypeScript AST directly. Changes are tracked and can be previewed as diffs before applying.
Java records require special handling because they have implicit canonical constructors. When you modify a record's components, both the record declaration AND all call sites (new RecordName(...)) must be updated.
When you use java_add_parameter, java_remove_parameter, or java_change_method_signature on a Java record (with methodName: "<init>" or the class name), the tool:
AddNullMethodArgument recipe to add null to all new RecordName(...) expressions// Before: public record Person(String name, int age) {}
// After: public record Person(String name, int age, String email) {}
// All call sites are updated:
// Before: new Person("John", 30)
// After: new Person("John", 30, null)null as the new argument value. You may need to update these manually if a different default is required.dryRun: true to preview changes before applyingUnderstanding which OpenRewrite recipes are used helps when troubleshooting or extending the tool.
OpenRewrite has different recipes for modifying declarations (where methods/constructors are defined) vs call sites (where they are invoked):
| What to Modify | Recipe | Handles |
|---|---|---|
| Method declaration (add param to signature) | AddMethodParameter | Declarations only |
| Method/constructor calls (add argument) | AddNullMethodArgument | Call sites (including new) |
| Method/constructor calls (add literal) | AddLiteralMethodArgument | Call sites (including new) |
| Method/constructor calls (remove argument) | DeleteMethodArgument | Call sites (including new) |
| Method/constructor calls (reorder args) | ReorderMethodArguments | Call sites (including new) |
| Tool Operation | Regular Methods | Java Records |
|---|---|---|
| Add parameter | AddMethodParameter | Record utils + AddNullMethodArgument |
| Remove parameter | DeleteMethodArgument | Record utils + DeleteMethodArgument |
| Reorder parameters | ReorderMethodArguments | Record utils + ReorderMethodArguments |
| Batch changes | ChangeMethodSignature composite | Record utils + UpdateCallSites composite |
To target constructors in method patterns, use either:
com.example.MyClass <constructor>(..) - Recommendedcom.example.MyClass <init>(..) - Also worksBoth patterns match new MyClass(...) expressions when used with call-site recipes.
MIT
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.