MSFS-MCP-Server

alxspiker/MSFS-MCP-Server

3.2

If you are the rightful owner of MSFS-MCP-Server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The MSFS-MCP-Server is a Model Context Protocol Server that connects Large Language Models to Microsoft Flight Simulator via SimConnect, enabling AI-controlled aviation.

Tools
4
Resources
0
Prompts
0

MSFS-MCP-Server ✈️🤖

ChatGPT PLAYS MSFS - LLM SimConnect Tool

An experiment in AI-controlled aviation.

This tool is a Model Context Protocol (MCP) Server that bridges Large Language Models (like ChatGPT or Claude) directly to Microsoft Flight Simulator 2020/2024 via SimConnect.

It allows an AI to read flight instruments, control aircraft surfaces, and even execute full takeoff and landing sequences using custom Python-based PID controllers.

Note from the Creator: "Made by ChatGPT, not even kidding. The thing learnt how to make its own tool to control everything on an airplane and get an insane amount of data easily. The result is a somewhat working fully automated pilot."


📺 Demo

See the tool in action: Watch the Video

It almost completely works from takeoff, navigation, and landing... except for that one time I got rate-limited during descent. We can all imagine how that went.


✨ Features

  • Remote Copilot: Run the sim on your PC, control it via ChatGPT on your phone.
  • MCP Integration: Exposes MSFS data and controls as "Tools" that LLMs can use natively over HTTP/SSE.
  • Full Data Access: Reads any SimVar (Altitude, Heading, Speed, Engine data) via SimConnect.
  • AI Autopilot Logic:
    • Automated Takeoff: Handles runway heading hold, rotation at $V_r$, and initial climb.
    • Automated Landing: Tracks glideslope and runway heading, performing a flare at 20ft (Results may vary!).
  • Blackbox Logging: Automatically records flight telemetry to a CSV file (flight_data_log.csv).

🛠️ Prerequisites

  1. Microsoft Flight Simulator (2020 or 2024) running on Windows.
  2. Python 3.10+.
  3. ngrok (For remote/mobile access).

📦 Installation & Setup

  1. Clone this repository.
  2. Install the required Python packages:
    pip install "mcp[cli]" fastapi uvicorn SimConnect anyio
    
  3. Ensure MSFS is running and you are sitting on a runway.

🌐 Remote Ops: The "Mobile Copilot" Setup

You can control your simulator from your phone (or anywhere) by exposing your local server to the internet. This allows you to sit back in full screen and talk to the AI pilot via voice mode.

1. Start the Server

Run the python script locally. It listens on port 3000 by default.

python msfs_mcp_server.py

2. Start ngrok

Open a new terminal and expose port 3000 to the public web:

ngrok http 3000

Copy the forwarding URL provided by ngrok (e.g., https://your-id.ngrok-free.app).

3. Connect ChatGPT / AI

  1. Open your MCP-supported AI client (ChatGPT with Dev Mode/MCP enabled, or a compatible MCP client).
  2. Turn on Developer Mode in your settings.
  3. Paste your ngrok URL with /mcp at the end as the server endpoint.
    • Format: https://<your-ngrok-id>.ngrok-free.app/mcp
  4. Done! You can now switch to the mobile app, enter Voice Mode, and say:

    "Copilot, set flaps to takeoff and engage the autopilot."


🚀 Usage with Claude Desktop (Local)

If you prefer using Claude Desktop locally without ngrok:

  1. Locate your config file: %APPDATA%\Claude\claude_desktop_config.json
  2. Add the entry:
{
  "mcpServers": {
    "msfs": {
      "command": "python",
      "args": ["C:\\path\\to\\your\\msfs_mcp_server.py"]
    }
  }
}

🧠 How It Works

The script uses FastMCP to expose Python functions as tools.

The Autopilot Loops

Unlike standard autopilot that just sets "Heading Hold" in the game, this tool actually flies the plane using async Python loops.

  • Takeoff: The AI calls engage_takeoff_autopilot. The script spins up a loop that reads the Heading and Airspeed 20 times a second, calculating PID errors to physically move the Rudder and Elevator axes.
  • Landing: The AI calls engage_landing_autopilot. The script calculates a synthetic glideslope and manages pitch/throttle to touchdown.

Available Tools

  • get_simvar_group_state: Dump instrument data.
  • set_event_state: Push buttons/move levers.
  • engage_takeoff_autopilot: Hand over control for departure.
  • engage_landing_autopilot: Hand over control for arrival.

⚠️ Disclaimer

This software is a prototype generated by AI, for AI.

  • Landing logic is experimental. The developer notes that landing is the "hardest part."
  • Do not use this for real-world aviation.
  • If the LLM gets rate-limited or crashes, the plane will keep doing whatever the last command was (usually flying straight into the ground).

🤝 Credits

  • Concept & Code Generation: ChatGPT
  • Human Handler: alxspiker