An experimental prototype of an F# development toolkit delivered via the Model Context Protocol (MCP). It provides F# Interactive (FSI) capabilities, code documentation, safe code manipulation, and analysis tools with language server features. Integration with the FAKE build system is under development.
The project is on hold for the moment since everything is moving very fast and it makes sense to wait for things to settle down a bit and see what makes sense then. Just this july update https://code.visualstudio.com/updates/v1_103 brought tons of new features that might change the workflow considerably.
This project has been developed with significant reliance on AI-driven tools. While it has proven to be surprisingly effectiveโlargely by leveraging robust libraries like F# Compiler Services and Fantomasโit will contain inaccuracies or incomplete features. Especially regarding Documentation, the agent tends to insert tons of industry buzzword BS whenever you look away for a second. This project has been developed with significant reliance on AI-driven tools. While it has proven to be surprisingly effectiveโlargely by leveraging robust libraries like F# Compiler Services and Fantomasโit will contain inaccuracies or incomplete features. Especially regarding Documentation, the agent tends to insert tons of industry buzzword BS whenever you look away for a second.
-
Code Verification: The entire codebase and its documentation have not been manually verified for correctness or completeness. However, the core features described should be functional (as in I have seen them work at least once).
-
Agent Stability: The AI agent's instructions are generally initially effective, but after it deviates, restarting the agent to reset its context is recommended.
-
DevEnvironment: This project has been developed in VSCode with GH Copilot, mostly using Claude Sonnet 4 and a bit of Gemini 2.5 Pro for planning and design. https://austen.info/blog/github-copilot-agent-mcp/
-
DevEnvironment: This project has been developed in VSCode with GH Copilot, mostly using Claude Sonnet 4 and a bit of Gemini 2.5 Pro for planning and design. https://austen.info/blog/github-copilot-agent-mcp/
-
Design: Documentation is written somewhat with REPL-driven development in mind, allowing for interactive code generation and testing. I am currently tending towards a more script-driven development approach, which allows for structured experimentation and reproducible testing. A new, more rigorous approach, Signature-Driven Development, is also being considered.
-
REPL works with hosted FSI sessions, which in this context are not easy to configure, a bit fragile with some Input, have no nice output (only MCP-Tools output terminal and agent chat window). Letting the agent start a standard fsi process in an agent observed terminal is of course possible but cumbersome in VSCode since terminal actions need approval. This project should be neutral to the chosen approach in the future. VsCode Insiders has microsoft/vscode#253103 which changes the ergonomics a lot. Needs consideration.
-
Get Started: There are no releases yet. For VSCode use this https://devblogs.microsoft.com/dotnet/build-a-model-context-protocol-mcp-server-in-csharp/ approach. Add the project to the mcp.json file. Later a dotnet tool might be the best way to distribute this project.
- Persistent FSI Session: Stateful F# Interactive session management
- Code Execution: Execute F# code with comprehensive error handling and validation
- Script Loading: Load and manage F# script files with dependency tracking
- Package Management: Reference .NET assemblies and NuGet packages seamlessly
- Expression Evaluation: Evaluate F# expressions with full type information
- ๐ฆ Package Documentation: Generate comprehensive API docs for NuGet packages
- ๐ Smart Search: Search through generated documentation with context-aware results
- ๐ API Reference: Create structured markdown documentation for modules and types
- ๐๏ธ Project Documentation: Bulk documentation generation for entire F# projects
- ๐พ Package Discovery: Browse and explore available NuGet packages in local cache
- โ๏ธ Configuration Management: Runtime configuration of documentation settings
- ๐ก๏ธ Safe Code Insertion: Insert F# code with AST validation and type checking
- ๐จ Code Formatting: Deep integration with Fantomas for consistent code formatting
- ๐ Structure Analysis: Analyze F# code structure, dependencies, and syntax
- ๐ Preview Capabilities: Preview code changes before applying them
- โก Atomic Operations: Atomic file operations with backup/rollback support
-
๐ Symbol Detection: Advanced symbol detection and resolution
- Powered by:
SmartSymbolDetectionService- Uses F# Compiler Services to identify and resolve symbols, functions, types, and modules within F# code - How it works: Parses source code into AST, performs semantic analysis to resolve symbol bindings, their scope, and provides position-sensitive symbol lookup
- MCP Tools:
GetAllSymbols,GetSymbolAtPosition,WhatIsAtPosition,GetSymbolSignatureAtPosition
- Powered by:
-
๐ Syntax Validation: Comprehensive F# syntax analysis and error reporting
- Powered by:
ParseAndCheckFSharpCode- Validates F# syntax and performs type checking with detailed diagnostics - How it works: Uses F# Compiler Services via IPC to parse source code, check for syntax errors, type mismatches, and compiler warnings with line-level error locations
- Powered by:
-
๐๏ธ Dependency Analysis: Track and analyze code dependencies and relationships
- Powered by:
AnalyzeCodeStructure- Provides basic file analysis including line count, character count, and diagnostic summaries - How it works: Performs F# Compiler Services parsing to identify errors, warnings, and structural issues in F# files
- Current scope: File-level analysis rather than deep dependency graph analysis
- Powered by:
-
๐ฏ Position-Sensitive Analysis: Context-aware code analysis based on cursor position
The FSharp.MCP.DevKit follows a modular, layered architecture with clear separation of concerns:
โโโ ๐ง FSharp.MCP.DevKit.Core/ # Foundation layer
โ โโโ FSI session management & execution
โ โโโ File system utilities & helpers
โ โโโ Core types & configurations
โ
โโโ ๐ FSharp.MCP.DevKit.Analysis/ # Code intelligence layer
โ โโโ F# syntax validation & analysis
โ โโโ Symbol detection & resolution
โ โโโ Code structure analysis
โ
โโโ ๐ก FSharp.MCP.DevKit.Communication/ # IPC infrastructure
โ โโโ High-performance named pipes
โ โโโ Persistent REPL server
โ
โโโ โ๏ธ FSharp.MCP.DevKit.CodeEditing/ # Code manipulation layer
โ โโโ Safe code insertion & editing
โ โโโ Fantomas formatting integration
โ โโโ Atomic file operations
โ
โโโ ๐ FSharp.MCP.DevKit.Documentation/ # Documentation generation
โ โโโ .NET assembly analysis
โ โโโ NuGet package documentation
โ โโโ Markdown API reference generation
โ
โโโ ๐ FSharp.MCP.DevKit.Server/ # MCP server & tools
โโโ MCP protocol implementation
โโโ 30+ specialized F# tools
โโโ Server runtime & hosting
graph TB
subgraph "๐ค AI Assistant Layer"
Assistant["`**AI Assistant**
(Claude, GPT, etc.)
โข F# Development Support
โข Code Generation
โข Interactive Analysis`"]
end
subgraph "๐ก MCP Protocol Layer"
MCPServer["`**MCP Server**
โข 30+ F# Tools
โข Stdio Transport
โข JSON-RPC Protocol`"]
end
subgraph "๐ Application Layer"
Server["`**FSharp.MCP.DevKit.Server**
โข Tool Implementation
โข Request Routing
โข Error Handling`"]
end
subgraph "๐ ๏ธ Service Layers"
Documentation["`**๐ Documentation**
โข Package Documentation
โข API Reference Generation
โข Smart Search & Discovery`"]
DocumentationTool["`**๐ง Documentation Tool**
โข CLI for Doc Generation`"]
CodeEditing["`**โ๏ธ Code Editing**
โข Safe Code Insertion
โข Fantomas Integration
โข Atomic Operations`"]
Communication["`**๐ก Communication**
โข Named Pipes IPC
โข Concurrent Processing
โข REPL Server`"]
Analysis["`**๐ Analysis**
โข Symbol Detection
โข Syntax Validation
โข Structure Analysis`"]
end
subgraph "๐ง Foundation Layer"
Core["`**FSharp.MCP.DevKit.Core**
โข FSI Session Management
โข File Operations
โข Configuration`"]
end
subgraph "๐ External Dependencies"
FCS["`**F# Compiler Services**
โข Code Compilation
โข Type Checking
โข AST Analysis`"]
Fantomas["`**Fantomas**
โข Code Formatting
โข Style Enforcement`"]
FSI["`**F# Interactive**
โข Code Execution
โข REPL Environment`"]
end
%% Connections
Assistant <--> MCPServer
MCPServer <--> Server
Server --> Documentation
Server --> CodeEditing
Server --> Communication
Server --> Analysis
Documentation --> Core
DocumentationTool --> Documentation
CodeEditing --> Core
Communication --> Core
Analysis --> Core
%% External integrations
Core --> FCS
Core --> FSI
CodeEditing --> Fantomas
Analysis --> FCS
Documentation --> FCS
%% Styling
classDef aiLayer fill:#4B0082,stroke:#ffffff,stroke-width:3px,color:#ffffff
classDef mcpLayer fill:#8B0000,stroke:#ffffff,stroke-width:2px,color:#ffffff
classDef appLayer fill:#000080,stroke:#ffffff,stroke-width:2px,color:#ffffff
classDef serviceLayer fill:#006400,stroke:#ffffff,stroke-width:2px,color:#ffffff
classDef foundationLayer fill:#2F4F4F,stroke:#ffffff,stroke-width:2px,color:#ffffff
classDef externalDep fill:#FF8C00,stroke:#000000,stroke-width:2px,color:#000000
class Assistant aiLayer
class MCPServer mcpLayer
class Server appLayer
class Documentation,CodeEditing,Communication,Analysis,DocumentationTool serviceLayer
class Core foundationLayer
class FCS,Fantomas,FSI externalDep
The server provides 30+ specialized MCP tools organized into categories:
GeneratePackageDocumentation- Generate comprehensive API docs for NuGet packagesGenerateProjectDocumentation- Bulk documentation for entire F# projectsSearchDocumentation- Search through generated documentation with contextListCachedPackages- Browse available NuGet packages in local cacheShowPackageInfo- Get detailed information about specific packagesSetDocumentationOutputDirectory- Configure documentation output settingsShowDocumentationConfig- Display current documentation configuration
CheckFSIServerStatus- Check FSI server status and availabilityResetFSISession- Reset the FSI session clearing all stateRestartFSISession- Restart FSI session (stop and start fresh)GetFSIState- Get current FSI state and bindings
ExecuteFSharpCode- Execute F# code with comprehensive error handlingExecuteFSharpCodeDetailed- Execute with detailed error informationEvaluateFSharpExpression- Evaluate expressions with type informationLoadFSharpScript- Load F# script files with dependency trackingReferenceAssembly- Reference .NET assembliesReferenceNuGetPackage- Reference NuGet packages dynamicallyAddSearchPath- Add directories to F# search path
InsertCode- Unified code insertion with validation and formattingPreviewCodeInjection- Preview code changes before applyingFormatFile- Format entire F# files using FantomasDeleteLines- Delete specific lines from filesReplaceTextRange- Replace text in specific line rangesSearchAndReplace- Search and replace with pattern matchingMoveCodeBlock- Move code blocks between locationsGetLines- Extract specific lines for inspectionCountLines- Count lines and characters in filesSearchInFile- Search for patterns with line numbers
AnalyzeCodeStructure- Analyze F# code structure and dependenciesParseAndCheckFSharpCode- Parse and validate F# syntax and typesParseSourceToAST- Parse code to Abstract Syntax Tree
KillAll- Kill all MCP server processes for clean restarts (temporary till FAKE integration)
# Generate documentation for a NuGet package
GeneratePackageDocumentation "System.Text.Json" "./docs" true
# Search through generated documentation
SearchDocumentation "./docs" "JsonSerializer"
# List available packages
ListCachedPackages "System"// Execute F# code
ExecuteFSharpCode "let x = 1 + 2; printfn \"Result: %d\" x"
// Evaluate expressions with type info
EvaluateFSharpExpression "List.map ((*) 2) [1..5]"
// Reference packages
ReferenceNuGetPackage "FSharp.Data"// Insert code with formatting, validation disabled by default for performance
InsertCode "let newFunction x = x * 2" "MyScript.fsx" 10 1 true false
// Enable validation for small, critical code pieces
InsertCode "let helper = x + 1" "MyScript.fsx" 5 1 true true
// Preview changes first
PreviewCodeInjection "let helper = ..." "MyScript.fsx" 15This project provides comprehensive strategies for AI agents to work effectively with F# development through different methodologies:
The toolkit supports multiple development philosophies, each optimized for different scenarios and agent capabilities:
Recommended for: Production workflows, complex validation, agent-driven development
- ๐ Design Philosophy - Comprehensive guide to script-based development methodology
- ๐ ๏ธ Copilot Instructions - Detailed agent instructions for script-driven workflows
- Key Characteristics: Reproducible execution, structured output, comprehensive validation, audit trails
Recommended for: Exploration, prototyping, interactive development
- ๐ Design Philosophy - Deep dive into REPL-based development patterns
- ๐ ๏ธ Copilot Instructions - Agent guidance for interactive REPL workflows
- Key Characteristics: Immediate feedback, live debugging, exploratory programming, state preservation
Recommended for: Contract-first development, rigorous validation, clear interfaces
- ๐ Design Philosophy - In-depth exploration of signature-driven development principles
- ๐ ๏ธ Copilot Instructions - Instructions for implementing signature-driven workflows
- Key Characteristics: Explicit contracts, enhanced validation, clear module boundaries, improved collaboration
Recommended for: Contract-first development, rigorous validation, clear interfaces
- ๐ Design Philosophy - In-depth exploration of signature-driven development principles
- ๐ ๏ธ Copilot Instructions - Instructions for implementing signature-driven workflows
- Key Characteristics: Explicit contracts, enhanced validation, clear module boundaries, improved collaboration
Comprehensive documentation organized by project:
- ๐ All Projects Documentation - Complete documentation index
- ๐ง Core - Foundation layer documentation
- ๐ Analysis - Code analysis and intelligence
- ๐ก Communication - IPC infrastructure
- โ๏ธ CodeEditing - Code manipulation capabilities
- ๐ Server - MCP server implementation
- ๐ Documentation - Documentation generation
- ๐๏ธ Architecture - System design and architecture
- โจ Features - Detailed feature documentation
- ๐ฏ Terminal Code Execution - Multi-terminal F# execution and session targeting
- ๐ฏ Terminal Code Execution - Proposal for Multi-terminal F# execution and session targeting
- ๐ Design & Analysis - Design decisions and analysis
- ๐ Implementation Summary - Implementation details
- ๐๏ธ Plans & Specifications - Development roadmaps
๐ Currently In Progress:
- ๐ Cross-reference linking - Automatic linking between types in documentation (maybe https://marketplace.visualstudio.com/items?itemName=foam.foam-vscode )
- Fake Integration
- Planning Tools - Adding some deterministic planning tools and Knowledge bases to help the AI agent generate more structured code.
- Increase performance and robustness of text, file handling and code insertion.
- F# Compiler Services - F# language analysis and compilation
- Fantomas - F# code formatting
- Model Context Protocol - AI assistant integration protocol
- Named Pipes - High-performance inter-process communication
- .NET 9.0 - Modern .NET runtime and libraries
For current development status and known issues, see:
- ๐ Known Issues - Current bugs and limitations
We welcome your feedback, questions, and contributions! Here's how to get in touch:
Join the F# community discussions:
- F# Discord - #tools-and-libraries - Get help, share ideas, and discuss F# tooling
Found a bug or have a feature request?
- GitHub Issues - Report bugs, request features, or ask questions
This project is licensed under the MIT License - see the LICENSE file for details.
- Build a Model Context Protocol Server in C# - Microsoft DevBlogs guide
- Model Context Protocol Documentation - Official MCP documentation
- F# Documentation - Official F# documentation
๐ Documentation โข ๐ ๏ธ Tools โข ๐๏ธ Architecture
Built with โค๏ธ using F# and the Model Context Protocol