Fortran Companion MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Fortran Companion MCP Serverlint and compile my Fortran project"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/enkiEng/fortran-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server