Fsharp Refactor logo

Fsharp Refactor

Offline F# refactoring over MCP and CLI, with analyzer-backed suggestions, dry runs, selective rules, and verified file edits.

Install Fsharp Refactor

Run the project’s own setup commands, in order.

Setup steps from the project

fsharp-refactor installs with its own steps rather than a config we can generate, so these are copied as-is. Follow them in order and run the commands in a terminal. Source: github.com

  1. 1. Install
    dotnet tool install --global fsharp-refactor
    

Overview

fsharp-refactor MCP server brings offline F# refactoring into agentic workflows through the existing command-line tool. It can inspect projects, solutions, source files, scripts, directories, and file globs, then report or apply analyzer-backed fixes. Use it when you want automated cleanup and modernization without sending code to an AI service; dry-run reporting, rule filters, and compilation checks help control changes.

Use cases

  • Preview automated F# cleanup before changing files
  • Apply selected refactoring rules across a project or solution
  • Refactor individual F# files or scripts from an agent workflow
  • Report analyzer findings as SARIF in CI
  • Review light-bulb fixes while editing in VS Code or Visual Studio

Key features

  • Offline F# refactoring
  • Dry-run and verified file editing
  • Rule and category filtering
  • Project, solution, script, and glob inputs
  • Iterative fix application
  • Analyzer and editor integration

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

7/7 checks healthy over the last 26d

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars17Stargazers on the source repository.
Last commit11d agoMost recent push to the default branch.
Directory activity1 viewsConfig copies, upvotes, and views on AllMCPs.

How Fsharp Refactor works

What fsharp-refactor does

fsharp-refactor provides functional refactoring suggestions for F# code through a .NET command-line tool with MCP support for agentic scenarios. Its rules target correctness, performance, idiomatic style, redundancy, diagnostics, and cosmetic improvements. Examples include replacing an ordinary binding with a use binding for disposable resources, simplifying boolean matches into conditionals, removing unnecessary new syntax, and moving Seq.map before Seq.toList.

The suggestions have Hint severity. They identify opportunities rather than defects, do not block a build, and are intended to clarify code written by agents or older codebases. The implementation runs fully offline and does not use AI at runtime.

How it works

The tool accepts a range of F# inputs. A project file uses its project configuration, a solution processes the F# projects listed by that solution, and a source file is analyzed in the context of its project while edits are limited to that file. It can also process an .fsx script without invoking MSBuild, a directory containing a solution or projects, or a glob matching project files.

For project inputs, the tool obtains compiler arguments from MSBuild. Scripts are resolved through F# Compiler Services instead. It runs the analyzers, applies non-overlapping fixes from the bottom of each file upward, and repeats analysis until another pass produces no changes. A fix can therefore enable a later fix.

Use --dry-run to print proposed changes with their file locations without writing files. Without that flag, the tool applies the selected fixes. It refuses to start when the input already has compilation errors and verifies the result after applying changes; if the edit introduces an error, the run fails. Existing warning-as-error settings remain in control of verification.

Setup and configuration

Install the command-line tool as a global .NET tool:

bash
dotnet tool install --global fsharp-refactor

A preview run can then target a project with:

bash
fsharp-refactor Your.fsproj --dry-run --api-changes

Remove --dry-run to apply the changes. Omit --api-changes when public methods or other API changes should not be modified. Additional options can limit the run by rule code or category, control parallel jobs, and set the maximum number of passes.

The analyzer assemblies are also distributed in the FSharp.Refactor.Analyzers package. They can be hosted by fsharp-analyzers for reporting in local or CI workflows, including SARIF output, while the fsharp-refactor tool is responsible for editing files. Repository-specific rule settings can be placed in fsharprefactor.json.

For editor diagnostics and light-bulb fixes, the project provides VS Code/Ionide and Visual Studio extensions. Ionide can load the analyzer package through its analyzer settings, and the Visual Studio extension uses an FsAutoComplete sidecar.

Tools and capabilities

  • Analyze a project, solution, source file, script, directory, or glob.
  • Report every proposed fix with its file and position.
  • Apply fixes directly after an explicit non-dry-run invocation.
  • Restrict execution to selected rule codes or categories.
  • Repeat analysis until enabled fixes reach a stable result.
  • Validate the starting and resulting code through compilation checks.
  • Provide analyzer diagnostics and quick fixes through supported editor integrations.

Limitations and notes

The command-line tool does not silently rewrite files: editing requires leaving off --dry-run. API-affecting changes are opt-in through --api-changes. A project that does not already compile is rejected, and warning settings can cause a proposed change to be rolled back during verification.

The analyzer package is a development dependency and is not copied into compiled output. In CI, fsharp-analyzers reports findings but does not edit source files; applying changes requires the separate fsharp-refactor tool. Script analysis can begin without an MSBuild step, but unresolved script references are handled only by the syntactic rules that can run in that context.

The editor integrations depend on FsAutoComplete and matching analyzer SDK assemblies. Ionide and newer FsAutoComplete versions use different analyzer assemblies packaged side by side so the host can load the compatible one.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Fsharp Refactor

fsharp-refactor is an MCP server that connects agentic workflows to F# projects, solutions, source files, scripts, directories, and file globs. Its main capabilities are running offline refactoring analyzers, previewing proposed fixes, applying selected changes, and verifying the resulting code through compilation checks.

Install it as a global .NET tool with `dotnet tool install --global fsharp-refactor`. The tool can then target an F# project, solution, source file, script, directory, or glob. Agentic workflows can use its MCP support, while direct command-line runs use the same executable.

Yes, fsharp-refactor applies changes when run without `--dry-run`. Use `--dry-run` first to list proposed fixes with file and position, then remove the flag to edit. API-affecting changes additionally require `--api-changes`.

Use the command-line filters for rule codes or categories. `--codes FR0002,FR0031` selects particular rules, while `--categories` limits execution to categories such as correctness, performance, idiom, or cosmetic.

Yes, the project provides a VS Code extension for Ionide integration. It can bundle the analyzers and configure Ionide globally with consent, or a project can reference `FSharp.Refactor.Analyzers` and set the analyzer path manually.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewFsharp Refactor AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/fsharp-refactor?style=directory)](https://allmcps.com/mcp/fsharp-refactor)
HTML Embed
<a href="https://allmcps.com/mcp/fsharp-refactor"><img src="https://allmcps.com/api/badge/fsharp-refactor?style=directory" alt="Fsharp Refactor on AllMCPs" /></a>