Skip to main content
Glama
README.md
# Farol

> A lighthouse for AI agents in .NET codebases, from .NET Framework to .NET 11.

Farol is an open-source [Model Context Protocol](https://modelcontextprotocol.io) server that gives AI coding agents (Claude Code, GitHub Copilot, Cursor, Codex) compiler-accurate understanding of C# and VB.NET solutions, including the legacy ones other tools skip: classic `.csproj`/`.vbproj`, `packages.config`, WebForms, WCF, ASMX, WinForms and WPF.

**Status:** [`Farol.Mcp` 0.2.0](https://www.nuget.org/packages/Farol.Mcp/0.2.0) on NuGet. Phase 2 is done: 23 tools, with refactorings (rename, change signature, move type, extract method), project conversion (SDK-style, PackageReference), the projects' analyzers in `dotnet_check`, loads without Visual Studio (heuristic on Linux or with the .NET SDK alone, and from a binary log), a persistent index that answers navigation while a solution loads, structured output and an MCP Registry listing. The benchmarks meet every target of both phases on a 4-core CI machine ([benchmarks](benchmarks/README.md)); the Phase 2 eval round with Claude Haiku 5.5 succeeded in every run of both arms, with 20% fewer tokens for Farol ([results](evals/results/2026-11-25-phase2-haiku.md)); the package is smoke-tested on Linux with the legacy fixture loaded heuristically. Phase 1, the MVP, met both its exit criteria ([eval results](evals/results/2026-10-07-haiku.md), [real use](docs/real-use/2026-10-23.md)). Scope: [spec 001](docs/specs/001-mvp.md), [spec 002](docs/specs/002-phase-2.md) · progress: [Phase 1 plan](docs/plans/phase-1.md), [Phase 2 plan](docs/plans/phase-2.md).

## Tools

| Tool | What it does |
|---|---|
| `dotnet_overview` | One-call map of a solution: languages, SDK-style vs classic projects, target frameworks, app models, test frameworks and the build command that works. |
| `dotnet_workspace` | Loads a solution and reports load state, failed projects and the MSBuild/Visual Studio toolchain in use, and whether the background warm-up that makes searches fast is done. File and project edits are picked up automatically. |
| `dotnet_find_symbols` | Finds declarations by name: exact, prefix, substring or camel-case humps (`OrdCalc` → `OrderCalculator`). |
| `dotnet_symbol` | Signature, documentation and optionally the source of one symbol; a skeleton for types. External symbols name the package and version (or framework) they come from, and their source is decompiled from the implementation assembly. Ambiguous names return candidates. |
| `dotnet_find_references` | Compiler-accurate references across C#, VB and every target framework, classified as call, new, read, write… (a type's include where it is created), plus markup references the compiler never sees (WebForms, .asmx/.svc/.ashx/.asax, XAML). |
| `dotnet_hierarchy` | Base types, interfaces, derived types, implementations and overrides. |
| `dotnet_call_hierarchy` | Callers or callees as a tree (depth 1–3) with call sites. |
| `dotnet_outline` | Types and members of a file or type with signatures and lines, no bodies. |
| `dotnet_check` | The errors and warnings your edits introduced since the workspace loaded, never the pre-existing ones, including in the projects that depend on the edited code (a C# signature change shows up as the VB error it causes). Edits inside member bodies re-check only the edited files, so it answers in about a second. With `analyzers=true` (or `Farol:CheckAnalyzers`), it also runs the projects' analyzers (CA/IDE rules, NuGet analyzers) on the edited files (the file or the project's files with `scope=file`/`project`) and says how long they took. |
| `dotnet_code_actions` | Visual Studio's lightbulb for one line: compiler fixes (add a missing `using`/`Imports`, generate a member, implement an interface…) and refactorings (extract method…). Previews a unified diff without touching files; `apply=true` writes the change atomically and returns a fresh check. |
| `dotnet_rename` | Renames a type, member, parameter or local in every C# and VB file and in WebForms and XAML markup, and renames the file named after a type (with its `.xaml` or `.resx` and the project file items, classic projects included). Refuses a name that clashes with an existing declaration or would make a reference bind to something else. Previews a unified diff; `apply=true` writes it and returns a fresh check. |
| `dotnet_change_signature` | Reorders, removes or adds a method's or constructor's parameters (a new one with the value callers pass), in the declaration, its overrides and implementations, and the arguments of every call site in C# and VB, named and omitted arguments included. Previews a unified diff; `apply=true` writes it and returns a fresh check. |
| `dotnet_move_type` | Moves a top-level type to another namespace and/or file of its project: the `using`/`Imports` its users need are added, names written with the old namespace are rewritten, and new, moved or emptied files update the project file of classic projects. Previews a unified diff; `apply=true` writes it and returns a fresh check. |
| `dotnet_extract_method` | Moves a range of whole statements into a new method with the parameters and return value they need, and calls it in their place (Roslyn's extract method), in C# and VB. Previews a unified diff; `apply=true` writes it and returns a fresh check. |
| `dotnet_convert_project` | Changes a project file's format, not what it builds: `kind=sdk_style` turns a classic .csproj/.vbproj into an SDK-style one with the same .NET Framework target, files, references and settings; `kind=package_reference` moves packages.config into PackageReference items. Refuses projects the SDK-style format cannot build the same way (web application projects, for instance). Previews the diff; `apply=true` writes it, restores, reloads the workspace and compares the project's files, references, packages and errors with before. |
| `dotnet_build` | Builds with the toolchain that works: `dotnet build` for SDK-style projects, Visual Studio's MSBuild (restoring `packages.config`) for classic .NET Framework ones. Errors and warnings come from the binary log, deduplicated across target frameworks and grouped by project. |
| `dotnet_test` | Runs all tests, tests matching a name, or only those that reach a symbol or your edits (`affectedBy`). Reports failures only: the assertion message and the stack frames in your code. `vstest.console` for classic test projects, `dotnet test` (VSTest or Microsoft.Testing.Platform, per `global.json`) for SDK-style ones. |
| `dotnet_packages` | NuGet packages per project with the versions restore resolved: direct, and transitive with the chain that brings each one in. PackageReference (central package management included) and `packages.config`. Flags vulnerable packages (advisories), deprecated ones (with the replacement) and newer versions, from the solution's feeds. |
| `dotnet_package_api` | The public API of an exact package version: signatures and XML documentation summaries read from the package's assemblies, never guessed. Local NuGet caches first, then the solution's feeds. |
| `dotnet_legacy_inventory` | What is legacy and where, with counts: classic projects, .NET Framework targets, packages.config; WebForms pages, ASMX and WCF services, WinForms forms, WPF XAML; config settings and binding redirects; code uses of BinaryFormatter, System.Configuration, System.Web… with their lines and the files where they concentrate. |
| `dotnet_portability` | Every .NET Framework API the code uses, looked up in the target framework's reference assemblies: the missing and obsolete ones, grouped by technology, with their locations and the replacement. WinForms/WPF projects are checked against `-windows`. |
| `dotnet_config_inspect` | A web.config or app.config with secrets masked — app settings, connection strings, WCF services, system.web, binding redirects — and its appsettings.json mapping. |
| `dotnet_migration_plan` | An ordered plan, bottom-up by project dependency: one step per project with its approach (multi-target, retarget to `-windows`, or rebuild on ASP.NET Core), a size and tasks citing file:line. `write=true` saves `assessment.md`, `plan.md` and `tasks.md` to `docs/modernization/`; it never writes code. |

Symbols can be passed as names, dotted names, documentation comment IDs from earlier results, or `path:line`.

## Requirements

- .NET 10 SDK (it provides `dnx`, which runs Farol from NuGet without installing it).
- Classic .NET Framework projects: Windows with Visual Studio 2022+ or Build Tools (full fidelity comes from Visual Studio's MSBuild); running their tests also needs Visual Studio's testing tools (`vstest.console.exe`).
- Without that MSBuild (on Linux or macOS, or on Windows without Visual Studio or Build Tools), Farol loads classic projects heuristically: it reads the project files directly and compiles against the .NET Framework reference assemblies (the `Microsoft.NETFramework.ReferenceAssemblies` packages, downloaded into the NuGet cache on the first load). Navigation and `dotnet_check` work; code MSBuild targets generate (XAML code-behind parts) is missing, and `dotnet_build` and `dotnet_test` need MSBuild. Answers say when a load is heuristic.

## Install

Farol ships on NuGet as [`Farol.Mcp`](https://www.nuget.org/packages/Farol.Mcp), an MCP server package that `dnx` runs on demand. It discovers the solution in the client's working directory; pass `--workspace <path>` to pick one.

### Claude Code

Install the plugin, which runs the server and adds a hook that checks every `.cs`/`.vb` edit and puts new compiler errors in front of Claude, plus a skill with the steps of a .NET Framework modernization:

```
/plugin marketplace add yuriafp/Farol
/plugin install farol@farol
```

The server's prompts appear as slash commands: `explore`, `verify_changes`, `upgrade_package` and `modernize`.

To add only the server, without the skill and the hook, put this in the `.mcp.json` of the repository:

```json
{
  "mcpServers": {
    "farol": {
      "command": "dotnet",
      "args": ["dnx", "Farol.Mcp@0.2.0", "--yes"]
    }
  }
}
```

### Visual Studio 2026

Add the server to a `.mcp.json` next to the solution (or to `%USERPROFILE%\.mcp.json` for every solution), then use it from GitHub Copilot Chat in agent mode:

```json
{
  "servers": {
    "farol": {
      "type": "stdio",
      "command": "dotnet",
      "args": ["dnx", "Farol.Mcp@0.2.0", "--yes"]
    }
  }
}
```

Agents that keep their own MCP configuration ignore `.mcp.json`: add Farol to theirs, in the `mcpServers` form shown for Claude Code. Google Antigravity, for example, reads `%USERPROFILE%\.gemini\config\mcp_config.json`, and starts Farol in the open solution's folder or elsewhere, such as its own installation folder. Trust the folder that holds your repositories with `--Farol:TrustedPaths:0 <folder>` rather than making it the root: a solution in the folder Farol starts in still loads on its own, and any solution under the trusted folder loads once a call names it.

### VS Code

Not yet validated for the MVP (Claude Code and Visual Studio 2026 are). The same configuration goes in `.vscode/mcp.json`.

### Options

Farol's own options go after `--`, so `dnx` doesn't read them as its own: `"args": ["dnx", "Farol.Mcp@0.2.0", "--yes", "--", "--read-only"]`. The [Configuration](#configuration) table lists them.

### As a .NET tool

To install Farol once instead of running it through `dnx`, use `dotnet tool install --global Farol.Mcp` (and `dotnet tool update --global Farol.Mcp` later). The client's command is then `farol`, and Farol's options are its arguments, without the `--`: `"args": ["--read-only"]`. On Windows, a running server keeps its files locked and the update fails with "access denied": close the clients that run it, then stop any `farol` process still running (Google Antigravity's outlived Visual Studio).

### From source

To run a local build instead, point the client at the host assembly:

```json
{
  "mcpServers": {
    "farol": {
      "command": "dotnet",
      "args": ["C:/path/to/Farol/src/Farol.Host/bin/Debug/net10.0/Farol.Host.dll"]
    }
  }
}
```

## Configuration

| Setting | Command line | Default | Meaning |
|---|---|---|---|
| `Farol:RootDirectory` | `--root <dir>` | working directory | Where the default workspace is discovered. Farol trusts this directory. |
| `Farol:DefaultWorkspace` | `--workspace <path>` | discovered | The solution or project used when a tool call names none. Without it, Farol uses the one it discovers in the root; in a root with several, a call about a file uses the workspace in use whose folder holds the file, else the solution nearest above it, and other calls use the one an earlier call named. |
| `Farol:AutoLoad` | `--autoload false` | `true` | Start loading the default workspace at startup. |
| `Farol:ReadOnly` | `--read-only` | `false` | Refuse writing files, building and running tests; tools explain the refusal. |
| `Farol:Offline` | `--offline` | `false` | Never touch the network: `dotnet_packages` reports the vulnerabilities the last restore recorded, and `dotnet_package_api` reads only packages already in the local NuGet caches. |
| `Farol:UsageLog` | `--usage-log` | `false` | Keep a usage log on this machine: one JSON line per session, workspace load and tool call, with durations and error codes but no code, arguments, paths or names (a solution appears as a hash of its file name). |
| `Farol:UsageLogDirectory` | `--Farol:UsageLogDirectory <dir>` | `Farol/usage` in the local application data folder | Where the usage log goes. Files older than 30 days are deleted. |
| `Farol:TrustedPaths` | `--Farol:TrustedPaths:0 <dir>` | none | More directories whose solutions may be loaded and whose files may be read or written. |
| `Farol:BuildTimeoutMinutes` | `--Farol:BuildTimeoutMinutes 30` | `15` | A longer build is stopped with its whole process tree. |
| `Farol:TestTimeoutMinutes` | `--Farol:TestTimeoutMinutes 30` | `20` | The same, per test project run. |
| `Farol:HookLoadWaitSeconds` | `--Farol:HookLoadWaitSeconds 0` | `20` | How long, from the start of a workspace load, the plugin's edit hook waits for the load before it answers that the edit is checked once the load is done. At most 30; `0` never waits. |
| `Farol:Loader` | `--Farol:Loader heuristic` | `auto` | Which loader opens workspaces: `auto` uses MSBuild when it can evaluate every project and the heuristic loader otherwise; `msbuild` or `heuristic` forces one. |
| `Farol:Binlog` | `--Farol:Binlog build.binlog` | none | A binary log (`-bl`) to load the workspace from when a call names none: the projects, files, references and compiler options as that build compiled them, without MSBuild (any OS where the files it names exist). A call can also pass a `.binlog` as its `workspace`. Analyzers are not loaded; a log older than the sources says so. Build with a rebuild (`-t:Rebuild`): an up-to-date build records no compiler call. |
| `Farol:Index` | `--Farol:Index false` | `true` | Keep a persistent index of each workspace (SQLite, under `Farol/index` in the local application data folder), written after the load and its warm-up and kept up to date in the background. At the next start, `dotnet_find_symbols`, `dotnet_find_references`, `dotnet_symbol`, `dotnet_outline`, `dotnet_hierarchy`, `dotnet_call_hierarchy` and `dotnet_overview` answer from it while the load runs, saying so, when it was written and which files changed since (results in them are marked); `dotnet_check`, code actions, build and test wait for the load. It holds declarations with their documentation summaries, references with the one line of code shown with each, the hierarchy and calls. An index that cannot be read is not used (and deleted when corrupt), and the load answers; files added since it was written are not in its answers. An index unused for 30 days is deleted; `false` reads and writes none. |
| `Farol:IndexDirectory` | `--Farol:IndexDirectory <dir>` | `Farol/index` in the local application data folder | Where indexes go, one folder per workspace (named after a hash of its path). Only those folders, and only the files Farol writes in them, are ever deleted. |
| `Farol:CheckAnalyzers` | `--Farol:CheckAnalyzers true` | `false` | Run the projects' analyzers in every `dotnet_check` that does not pass `analyzers`, the plugin's edit hook included. |
| `Farol:AnalyzerTimeoutSeconds` | `--Farol:AnalyzerTimeoutSeconds 30` | `10` | How long one check's analyzers may run; the answer names the analyzer assemblies that did not finish. |

Settings can also come from `appsettings.json` next to the executable and from environment variables such as `Farol__TrustedPaths__0`. Farol gets the environment of the client that starts it: a variable set while the client is open, with `setx` for example, reaches Farol only after the client restarts, while an option in the server's `args` does not depend on that. `--help` prints these options and how a client starts Farol, then exits without starting the server; through `dnx`, it goes after `--` like the others. `--usage-report` (`--days N`, default 14) sums the usage log up the same way: the days with use, each tool's calls, errors and p50/p95 durations, the errors by code and the loads per solution. Nothing leaves the machine unless you share the report.

**Trust:** loading a solution runs its build logic (MSBuild evaluation, analyzers, source generators), including the code generators a design-time build runs, as Visual Studio does when it opens the solution: one that writes into the source tree, such as a gRPC client with its `OutputDir` there, rewrites those files. Analyzers and source generators load from copies under the temp directory (`farol/analyzers`), so a solution can rebuild its own generators while Farol runs; a later server removes the copies once the process that made them has exited. Farol only loads solutions, reads paths and writes files inside the root it was started in and `Farol:TrustedPaths`, after resolving `..` and symbolic links; anything else is refused with an error that says how to allow it.

**NuGet:** the package tools use the NuGet configuration restore uses (the `nuget.config` files from the solution up, package source mapping, `auditSources`), the HTTP cache, and credential providers such as Azure Artifacts' in non-interactive mode: if a private feed needs a sign-in, run `dotnet restore --interactive` once. A package `dotnet_package_api` downloads goes into the global packages folder, as restore would put it.

## Build and test

```bash
dotnet build Farol.slnx
dotnet test --solution Farol.slnx
```

To work on Farol in an IDE, use one that supports .NET 10: Visual Studio 2026 (18.0+), VS Code with C# Dev Kit, or a recent Rider. **Visual Studio 2022 cannot open the solution:** the .NET 10 SDK requires MSBuild 18.0, and Visual Studio 2022 ships MSBuild 17.14. Farol can still analyze your solutions with Visual Studio 2022 installed; this only concerns building Farol itself.

CI builds and tests every push, and once a week, on Windows with Visual Studio 2026. Another workflow installs the published package from nuget.org every week and after each release, and checks it on the fixtures. Performance is measured against the spec's targets on Umbraco CMS and DNN Platform: [benchmarks/README.md](benchmarks/README.md). Whether Farol makes Claude Code better at .NET work is measured by an eval suite of 30 tasks run with and without it: [evals/README.md](evals/README.md).

Changes by version: [CHANGELOG.md](CHANGELOG.md). Releasing: [docs/release.md](docs/release.md). Smoke tests in Claude Code and Visual Studio 2026: [docs/smoke-tests.md](docs/smoke-tests.md).

## Architecture

```
Farol.Host    stdio today, HTTP later · configuration · server instructions
  └─ Farol.Tools    one vertical slice per tool, grouped by toolset
       └─ Farol.Engine    Roslyn/MSBuild workspaces, discovery, analysis
            └─ Farol.Core    no Roslyn: token budgets, paths, errors, process execution
```

Every tool takes the workspace as a parameter (mirrored into the `Mcp-Param-Workspace` header) and keeps nothing in the protocol session; tools return edits as diffs and paths relative to the root. The same code can later run behind a self-hosted gateway that names the workspace on every call.

## License

MIT