This page covers the local Codemod MCP for building and testing codemods. To connect an AI assistant to your Codemod account so it can search your code and manage migrations, see the hosted MCP.
Quick setup
Run the bootstrap command from anywhere:Manual MCP setup
Manual MCP setup
If you prefer to configure MCP yourself:
- Open your IDE MCP settings.
- Add the following MCP server entry:
npx codemod@next ai writes this entry for you, pinned to the version that ran it.For Cursor IDE:- Open Cursor Settings
- Navigate to MCP & Integrations
- Click New MCP Server under MCP Tools
Available tools
The Codemod MCP server provides these operational tools for AI assistants:dump_ast- Dump AST nodes in an AI-friendly format for given source code and languageget_node_types- Get compressed tree-sitter node types for specific programming languagesrun_jssg_tests- Run tests for JSSG codemods with test casesvalidate_codemod_package- Validate whether a codemod package is still a starter scaffold or incomplete
Available resources
The Codemod MCP server provides these guidance resources for AI assistants:jssg-instructions- Docs-backed JSSG guidance for creating and testing transformation scriptsjssg-gotchas- Highest-priority JSSG gotchas before implementing transforms, including returned data and Performant codemodsast-grep-gotchas- Highest-priority ast-grep gotchas before implementing transformsjssg-utils-instructions- Docs-backed JSSG utility guidance, including JavaScript imports, Java helpers, and XML helpersjssg-runtime-capabilities-instructions- Runtime and capability guidance for LLRT/Node APIs and multi-file JSSG workcodemod-cli-instructions- Docs-backed CLI, package, and workflow guidancecodemod-creation-workflow-instructions- Docs-backed codemod authoring workflow guidance with a small local supplementcodemod-troubleshooting-instructions- Troubleshooting guidance for common Codemod CLI failurescodemod-maintainer-monorepo-instructions- Maintainer guidance for codemod monorepos and version-hop workspacessharding-instructions- Docs-backed sharding guidance
codemod-creation-workflow-instructions, then read jssg-gotchas and ast-grep-gotchas before writing source-transform code. For JavaScript, TypeScript, or Java transforms, also read jssg-utils-instructions and prefer @jssg/utils over hand-written import gates, style helpers, or renames. Decide whether each step needs semantic analysis when matching generic method names, renaming symbols, or following aliases. Set semanticAnalysis in workflow.ts or semantic_analysis in legacy YAML.
Follow the Performant codemods section inside jssg-gotchas: avoid per-file full-repo walks and time a no-op against the real package on the same entry path. To count edits, return { edit, data } with an entry per real edit and a field such as kind so the workflow can group by variant. Snapshot data.json for standalone JSSG fixtures that produce data. For read-only mining, return { edit: null, data }.
If registry discovery does not find an appropriate package, scaffold one with npx codemod@next init. For a non-interactive workflow package, supply the project type and metadata explicitly; the CLI does not infer the author from your login:
^(@[A-Za-z0-9\-_.]+/)?[A-Za-z0-9\-_]+$: optional @scope/, then no dots in the name (hyphenate versions like lib-1-2-to-1-3).
Why use Codemod MCP?
Codemod MCP democratizes code transformation by integrating robust deterministic engines into AI-powered development workflows:- Individual Developers: Take care of repetitive refactors without manual effort
- Accessibility: Makes tackling tech debt more approachable for developers of all skill levels
- AI Integration: Seamlessly integrates deterministic code transformation engines into AI IDE workflows
Best practices
When working with AI assistants through Codemod MCP, follow these guidelines for better results:1
Be specific about output format
Tell the AI exactly what type of codemod you want:
- jssg: TypeScript-based transformation scripts (codemods) that operate on ASTs generated by ast-grep, allowing you to transform code in any supported language.
- ast-grep YAML rule: general-purpose transformations
- shell workflow: complex multi-step migrations
2
Provide clear requirements
Describe your transformation in plain language with concrete examples:
- Show before/after code snippets
- Specify edge cases to handle or avoid
- Include any constraints or special conditions
3
Break down complex changes
Instead of one large transformation, create focused codemods for specific patterns:
- One codemod per logical change
- Simpler codemods are more maintainable
- Easier to test and debug individual transformations
Anonymous platform feedback
Codemod AI and MCP can submit short anonymous platform feedback when the user has explicitly consented. Agents must ask before enabling or submitting feedback. After the user consents, submit categorized feedback with:jssg: JSSG feature requests, runtime gaps, or transform-authoring frictionworkflow: workflow feature requests or workflow authoring frictionai-docs: AI docs resources that should be added, clarified, or reorganizedmcp: MCP tool, resource, or server behavior feedbackcli: CLI command or setup feedbackregistry: registry discovery or package metadata feedbackpackage-validation: package validation checks that should be added or refinedother: feedback that does not fit the categories above
Troubleshooting
Server won't start
Server won't start
If the MCP server fails to start:
- Ensure you have Node.js 16.0.0 or higher installed
- Try running
npx codemod@next mcpmanually to test
Tools not available
Tools not available
If MCP tools aren’t showing up:
- Restart your AI client after adding the MCP server
- Check the MCP server logs for error messages
- Verify the JSON configuration syntax is correct
- Ensure your AI client supports Model Context Protocol
Performance issues
Performance issues
For slow performance:
- More complex transformations may take longer to build
- Consider using specific file patterns to limit analysis scope
- Check system resources and network connectivity
- Use faster models if available