Fortran Companion MCP Server
Enables AI models to write, format, compile, lint, and structure modern Fortran code using best practices and industry design patterns.
README
Fortran Companion MCP Server
A Model Context Protocol (MCP) server designed to enable AI models to write, format, compile, lint, and structure modern Fortran code (F2003/F2018/F2023) using best practices and industry design patterns.
š Why This Project?
AI models are trained on large volumes of legacy Fortran code (e.g., Fortran 66, 77, 90). When generating Fortran today, they regularly produce "AI Slop":
- Implicit variable typing (omitting
implicit none). - Non-standard vendor-specific types (like
real*8orinteger*4instead of standardkindparameters). - Obsolescent control structures (numbered loops like
do 10 i = 1, Nandgotostatements). - Global state blocks (
commonandequivalence) which violate modern scoping rules. - Lack of explicit interfaces (omitting module containers and dummy argument
intentattributes).
This MCP server equips AI agents (in Cursor, Claude Desktop, or Antigravity CLI) with tools to statically check, auto-format, compile, and structure Fortran code. This creates a self-correcting feedback loop where the AI compiles and lints its own work, ensuring only high-quality, modern Fortran is delivered.
š ļø Features
- Legacy Linter: Scans code for obsolete type notations, missing intents, missing
implicit noneunits, fixed-format layouts, and deprecated statements. - Auto-Formatter: Connects directly to
fprettifyto cleanly indent and format Fortran code. - Strict Compiler Verification: Triggers compilation checks using
gfortranorfpmwith strict diagnostic flags (-Wall -Wextra -Wimplicit-interface -fcheck=all -std=f2018). - Boilerplate Initializer: Sets up standard modular layouts (supporting both
fpmor standard Makefiles) with modern syntax, intents, and testing templates. - Design Patterns Database: Serves architectural blueprints and code templates for:
- OOP: Classes, inheritance, polymorphism, and deferred bindings.
- Generics: Function/operator overloading using generic interfaces.
- RAII: Automated resource cleanups using
allocatable. - Callbacks: Strategy pattern using abstract interfaces and procedure pointers.
- C-Interop: Interfacing standard C and Python bindings using
iso_c_binding.
š Project Structure
fortran-mcp/
āāā pyproject.toml # Python project configuration & dependencies
āāā README.md # Project overview & documentation
āāā session_handoff.md # Context handoff for AI agents
āāā src/
ā āāā fortran_mcp/
ā āāā __init__.py
ā āāā linter.py # Custom Fortran Linter engine
ā āāā server.py # FastMCP tools definitions and entrypoint
āāā test/ # Demonstration and verification test suite
ā āāā unformatted_legacy.f90 # Non-compliant Fortran demonstration file
ā āāā modern_compliant.f90 # Formatted, best-practice compliant Fortran file
ā āāā illustrate_mcp_tools.py # Python script orchestrating the MCP tool calls
ā āāā README.md # Test runner documentation
āāā dist/ # Packaged python distributions (tar/wheel)
āļø Setup & Connection
This server uses the standard Python MCP SDK (fastmcp) and requires Python 3.14+ (or 3.10+ compatible environments) with uv or pip.
1. Add to Antigravity CLI
Add the server configuration to your local Antigravity config file at ~/.gemini/antigravity-cli/mcp_config.json:
{
"mcpServers": {
"fortran-companion": {
"command": "uv",
"args": [
"--directory",
"/path/to/fortran-mcp",
"run",
"fortran-mcp"
]
}
}
}
2. Add to Claude Desktop
To use this with Claude Desktop, insert the block below into your claude_desktop_config.json (typically under ~/Library/Application Support/Claude/ on macOS or %APPDATA%/Claude/ on Windows):
{
"mcpServers": {
"fortran-companion": {
"command": "uv",
"args": [
"--directory",
"/path/to/fortran-mcp",
"run",
"fortran-mcp"
]
}
}
}
š How to Test
Start a new conversation session with any MCP-capable host (like Claude or Antigravity) in this workspace. Try prompts like:
"Design a modules-based modern Fortran project that integrates a user-defined function using midpoint integration. Make sure you use modern intents, explicit kinds, and test it."
The agent will use the MCP tools to bootstrap the structure, write, lint, format, and compile the code successfully, correcting its errors on the fly.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.