FsLangMCP
F# MCP server with FsAutoComplete and FCS bridge
Ask AI about FsLangMCP
Powered by Claude Β· Grounded in docs
I know everything about FsLangMCP. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
FsLangMCP (F# + FsMcp + FsAutoComplete + FCS)
An MCP server written in F# that combines:
fsautocomplete(LSP bridge for editor-like features)FSharp.Compiler.Service(compiler-semantic features for AI workflows)
Work in progress: APIs and tool shapes may still change.
Changelog
See CHANGELOG.md for the full release history.
Response Shape
All tools return a consistent JSON envelope:
- Success:
{"status": "ok", "result": <payload>}(LSP tools) or{"status": "ok", ...fields}(FCS tools) - Not ready:
{"status": "not_ready", "message": "..."}β LSP workspace still loading - Error: MCP protocol error with
{"errorKind": "...", "message": "..."}payload
What You Get
LSP-proxy tools (via fsautocomplete)
textDocument_completiontextDocument_definitiontextDocument_referencestextDocument_formattingβ format F# file via Fantomas (via fsautocomplete)textDocument_codeActionβ available code actions / quick fixes at cursortextDocument_renameβ rename a symbol across the projectworkspace_symbolworkspace_diagnostics(cache of latestpublishDiagnostics)fsharp_signature_dataβ structured FSAC signature help at an exact positionset_project(switch active project/workspace for LSP context)
LSP positions (line, character) are 0-based.
The textDocument_* and workspace_* tools are raw LSP/IDE-shaped proxies. They are useful for exact-position editor operations and FSAC debugging. Prefer the FCS tools and project_health for agent-friendly project understanding.
FCS tools (compiler semantics)
fcs_parse_and_check_filefcs_file_outlineβ compact per-file API/navigation outline for agentsfcs_project_outlineβ compact project-wide outline over filtered compile filesfcs_find_symbolβ grouped definitions/references with source contextfcs_symbol_at_wordβ tolerant symbol lookup by line + word/occurrencefcs_file_symbolsfcs_project_symbol_usesfcs_type_at_positionβ inferred F# type and symbol info at cursor (works without LSP workspace)fcs_signature_helpβ method overloads and parameter info at cursorfcs_get_project_optionsβ getOtherOptionsfor a.fsprojviaproj-info; use the result asprojectOptionsin other FCS tools
Project preflight
fsharp_project_inspectβ read-only.fsprojinspection: compile order, references, source summary, and signature/implementation pairing.project_healthβ fast read-only project preflight. Reports project options availability, source file readability, analyzer setup, test project discovery, and current LSP readiness. It does not start/switch FSAC, run compile, or run tests.fsharp_compileβ FCS project validation. Loads.fsprojoptions throughIonide.ProjInfo, then runsFSharpChecker.ParseAndCheckProject. It does not requireset_project, rundotnet build, emit assemblies, or run tests.
Prerequisites
- .NET SDK 10+
fsautocompleteinstalledionide.projinfo.tool(required forfcs_get_project_options)
Install fsautocomplete:
dotnet tool install -g fsautocomplete
Install ionide.projinfo.tool:
dotnet tool install -g ionide.projinfo.tool
For local development of this repository, restore the local analyzer tool:
dotnet tool restore
Install As Dotnet Tool
From NuGet (recommended)
dotnet tool install -g FsLangMcp
fslangmcp --bootstrap-tools
Update later with dotnet tool update -g FsLangMcp.
From source (developing FsLangMCP itself)
dotnet pack -c Release
dotnet tool install -g --add-source ./nupkg FsLangMcp
fslangmcp --bootstrap-tools
After install, command is:
fslangmcp
Runtime Options
Pass paths as command args (recommended):
--project <path-to-fsproj>or-p <path-to-fsproj>--fsac-command <cmd>(optional override)--fsac-args "<args>"(optional override)--bootstrap-tools(install/updatefsautocompleteandionide.projinfo.tool)
Environment fallbacks still work:
FSAC_COMMANDFSAC_ARGSFSA_PROJECT_PATH
Garbage collector β tuned for stdio servers
FsLangMCP ships with Workstation GC + Concurrent GC baked in via runtimeconfig.template.json. This is the recommended profile for stdio MCP servers per FsMcp's runtime tuning guide: an FCS workload is bursty (load β idle β next request), and Server GC's "don't release until OS pressure" produces alarming RSS growth on dev laptops that won't trigger pressure events.
Operators can override at the env-var level if needed (env always wins over runtimeconfig):
DOTNET_gcServer=1β opt back into Server GC (higher throughput, holds memory longer)DOTNET_GCHeapHardLimitPercent=0xAβ cap heap at 10% of RAM (works with either GC mode)
MCP Stdio Config (Installed Tool)
{
"mcpServers": {
"fsharp": {
"command": "fslangmcp",
"args": ["--project", "/absolute/path/to/App.fsproj"],
"env": {
"FSAC_COMMAND": "fsautocomplete"
}
}
}
}
Parallel Agent Usage
For multiple agents sharing one FsLangMCP server, prefer the FCS tools and pass projectPath on every request:
{
"path": "/absolute/path/to/File.fs",
"projectPath": "/absolute/path/to/App.fsproj"
}
FCS tools resolve compiler options per project and cache project-wide results by the resolved .fsproj, so agents working on different projects do not share stale symbol caches. The server also limits expensive work by default:
FSLANGMCP_MAX_CONCURRENT_FCS=2FSLANGMCP_MAX_CONCURRENT_LSP=1
The LSP-proxy tools use one fsautocomplete workspace per server process. They are serialized to avoid corrupting the active document/workspace state, but they are not intended for independent parallel workspaces in the same MCP process.
Example Agent Session
Start by selecting a project:
{
"projectPath": "/absolute/path/to/App.fsproj",
"workspacePath": null,
"restartLsp": true
}
Then ask for a health report:
{
"projectPath": "/absolute/path/to/App.fsproj",
"workspacePath": null,
"scope": null,
"compileCheck": null
}
Typical next calls:
fcs_parse_and_check_filewithprojectPathfor one file.fcs_file_outlinefor a compact map of a file.fcs_find_symbolwhen you need definitions/references plus source context.fcs_symbol_at_wordwhen you know the line and word but not the exact cursor column.fcs_project_symbol_useswithsymbolQueryfor project-wide references.workspace_diagnosticsto inspect current FSAC/compiler/analyzer diagnostics.fsharp_compilefor project-wide FCS parse+typecheck validation.
For repeated multi-agent use, pass projectPath directly to FCS tools instead of relying on mutable LSP workspace state.
Development Commands
just restore
just check
just analyze
just checkruns build + tests.just analyzeruns F# analyzers throughFSharp.Analyzers.Build.
The repository currently wires:
Ionide.AnalyzersG-Research.FSharp.AnalyzersFSharp.Analyzers.Build- local
fsharp-analyzerstool
MCP Stdio Config (Local Dev Without Install)
{
"mcpServers": {
"fsharp": {
"command": "dotnet",
"args": [
"run",
"--project",
"/path/to/FsLangMcp.fsproj",
"--",
"--project",
"/absolute/path/to/App.fsproj"
],
"env": {
"FSAC_COMMAND": "fsautocomplete"
}
}
}
}
How To Get projectOptions For FCS Tools
For accurate .fsproj / .sln / .slnx context, use ionide/proj-info:
dotnet tool install -g ionide.projinfo.tool
proj-info --project /absolute/path/to/App.fsproj --fcs --serialize
Use OtherOptions from the emitted JSON as projectOptions in:
fcs_parse_and_check_filefcs_file_symbolsfcs_project_symbol_uses
If both projectPath and projectOptions are omitted, the server first tries to auto-discover the nearest .fsproj. If no project can be found, it falls back to script-style inference (GetProjectOptionsFromScript), which is less accurate for large multi-project solutions.
set_project Tool
Use this MCP tool to switch active project context without restarting the MCP process.
Input shape:
{
"projectPath": "/absolute/path/to/App.fsproj",
"workspacePath": null,
"restartLsp": true
}
restartLsp defaults to true so the new context is applied immediately.
project_health Tool
Use project_health before deeper semantic work when you need to know whether FsLangMCP can trust the project state.
Input shape:
{
"projectPath": "/absolute/path/to/App.fsproj",
"workspacePath": null,
"scope": null,
"compileCheck": null
}
Notes:
- v0.3 expects an explicit
.fsprojpath or a directory with exactly one.fsproj. - Missing analyzers are reported as capability information, not as a health failure.
- Compile status is separate from tooling readiness.
project_healthdoes not run build or tests.
fsharp_compile Tool
Use fsharp_compile when you want read-only project-wide FCS validation without running dotnet build.
Input shape:
{
"projectPath": "/absolute/path/to/App.fsproj",
"workspacePath": null,
"timeoutMs": 60000
}
fsharp_compile returns a compact status, diagnostic counts, and FCS diagnostics. It uses FSharpChecker.ParseAndCheckProject, so it checks parse/typecheck errors across the project, but it does not execute the full MSBuild build pipeline, emit an assembly, or run tests.
Known Issues
- LSP proxy tools return
{"status": "not_ready"}if called beforefsautocompletehas finished loading the project.set_projectwaits up to 30 seconds β if you still getnot_ready, the project may be too large orfsautocompletemay have failed to start. project_healthv0.3 is intentionally project-focused. It does not yet inspect whole solutions or resolve ambiguous directories.- FCS tools fall back to script-style inference (
GetProjectOptionsFromScript) only when neitherprojectPathnor an auto-discovered.fsprojis available. In that mode, diagnostics and symbol data can be incomplete for multi-project solutions. fcs_project_symbol_usesresults are cached per project. Callset_projectto flush the cache when source files change on disk.
About Tool Dependencies
dotnet tool packages cannot automatically install other global tools during installation.
This project provides:
fslangmcp --bootstrap-tools
It runs dotnet tool update -g ... (or install if missing) for:
fsautocompleteionide.projinfo.tool
