Skip to main content

Moderne MCP server

The Moderne CLI includes a Model Context Protocol (MCP) server that gives AI coding agents tools for semantic code search, navigation, and refactoring. While skills teach agents how to work with recipes, the MCP server gives agents direct access to these tools, backed by OpenRewrite's Lossless Semantic Tree (LST) and Moderne Trigrep.

Why use the Moderne MCP server

AI coding agents are limited to the tools bundled with them (typically just text search and file reading). These tools work at the text level and miss the semantic structure of code.

The Moderne MCP server gives agents:

  • Indexed code search that returns results in milliseconds regardless of repository size
  • Semantic navigation that understands types, methods, annotations, and inheritance hierarchies
  • Codebase-wide refactoring that updates all references atomically, like an IDE rename
  • Recipe execution that runs OpenRewrite recipes directly from the agent conversation
  • Structural matching that finds code patterns spanning multiple tokens or lines

Because these tools are backed by a semantic model of your code, they understand it the way a compiler does - rather than text like a traditional tool would.

How it works

When the MCP server starts, it builds two things in the background:

  1. Moderne Trigrep: a pre-computed trigram index that enables sub-second text search across the entire repository. This powers the search and structural_search tools.
  2. LSTs (Lossless Semantic Trees): a type-attributed tree representation of your source code that enables semantic tools like find_types, find_methods, change_type, and recipe execution.

Tools become available progressively as each build completes. You can check their progress with the build_status and lst_status tools.

Available tools

The MCP server exposes the following tools:

ToolDescription
searchSearches the codebase using a pre-built trigram index. Faster than grep/ripgrep because it uses indexed search, returning results in milliseconds regardless of repo size. Supports plain text, regex, and filters (lang:, file:).
structural_searchSearches using Comby structural matching over the trigram index. Use this when you need to find code patterns that span multiple tokens or lines, such as method signatures, call patterns, or control flow. Uses :[hole] placeholders that respect balanced delimiters.
ToolDescription
find_typesFinds all references to a type across the codebase, including imports, field types, method parameters, return types, type casts, instanceof checks, annotations, and generic type arguments.
find_methodsFinds all invocations of a method across the codebase. Uses AspectJ-style method patterns to match method calls.
find_annotationsFinds all usages of an annotation across the codebase, including on classes, methods, fields, parameters, and more.
find_implementationsFinds all classes that implement an interface or extend a class, including indirect implementations through the entire type hierarchy.
symbols_overviewLists all symbols (classes, interfaces, enums, methods, constructors, fields) in a specific file or across the entire codebase.

Editing code

ToolDescription
change_typeRenames or moves a type across the entire codebase. Updates all imports, references, declarations, and usages, equivalent to an IDE's "rename type" refactoring applied across the whole repository.
change_method_nameRenames a method across the entire codebase. Updates all call sites, declarations, and references, equivalent to an IDE's "rename method" refactoring applied across the whole repository.
pattern_replaceCompiles and runs a Refaster template to make mechanical code changes across the entire codebase. Provide a Java class with @BeforeTemplate and @AfterTemplate methods.

Working with recipes

ToolDescription
search_recipesSearches available OpenRewrite recipes by natural-language query. Returns a paginated list of matching recipe names ranked by relevance.
learn_recipeRetrieves full details for a specific recipe, including its description, configurable options, and data table schemas.
run_recipeRuns an OpenRewrite recipe on the repository. Recipes perform automated code analysis, refactoring, migration, and formatting.
query_datatableExecutes SQL against data table results from a recipe run. Lazily loads results into DuckDB for querying.

Checking status

ToolDescription
build_infoReports the build tool, compile command, and test command for the repository. Detects Gradle, Maven, Bazel, npm, and .NET projects.
build_statusReports the status of the trigram search index. Shows whether the search tools will return useful results.
lst_statusReports the status of the LST build. Shows build state, source file count, and pending incremental changes.

The Moderne Agent Tools browser showing all available MCP tools in a dropdown list
The tool browser showing all available MCP tools

Installation

The following command installs both skills and the MCP server configuration for all detected coding agents:

mod config agent-tools install

This registers the MCP server with each detected agent so it starts automatically when the agent opens your project. The CLI handles the configuration details for each agent. For example, it runs claude mcp add for Claude Code and writes to ~/.cursor/mcp.json for Cursor.

To remove the MCP server configuration along with skills:

mod config agent-tools uninstall

Supported agents

AgentMCP supportSkills supportMCP configuration
Claude CodeYesYesRegistered via claude mcp add
WindsurfYesYes~/.codeium/windsurf/mcp_config.json
CursorYesYes~/.cursor/mcp.json
GitHub CopilotYesYes.vscode/mcp.json
GitHub Copilot CLIYesNo~/.copilot/mcp-config.json
Sourcegraph AmpYesYesRegistered via amp mcp add
OpenAI CodexYesYesRegistered via codex mcp add

Tool browser

The Moderne CLI includes an optional tool browser, a browser-based dashboard for monitoring LST builds and exploring available tools. To enable it:

mod config features agent-tools tray --enabled

Once enabled, the MCP server launches a system tray icon when an agent starts. Click it to see the status of your projects, then click Tool Browser... to open the dashboard.

The Moderne system tray icon showing project build status
The system tray icon showing project status

The dashboard shows:

  • Project cards with build status, file counts, and tool call metrics
  • Build logs with parse timing details
  • Tool execution for testing tools directly from the browser

The Moderne Agent Tools dashboard showing project cards with build status, file counts, and tool call metrics
The tool browser dashboard with project status cards

The Moderne Agent Tools dashboard showing build logs and parse time scatter chart
Build logs and parse timing details for a selected project

Skills vs MCP

Skills and the MCP server are complementary:

SkillsMCP server
What they provideWorkflow guidance and domain knowledgeSemantic code search, navigation, and refactoring tools
How agents use themRead as instructions/promptsCall as tools during conversation
When they helpCreating recipes, analyzing impact, building working setsSearching, navigating, and refactoring code
Requires LST buildNoYes (for semantic tools)

For the best experience, install both. Skills teach agents the recipe development workflow, while the MCP server gives them the tools to execute that workflow effectively.

Next steps