FG-MCP Server

From FlightGear wiki
Jump to navigation Jump to search
WIP.png Work in progress
This article or section will be worked on in the upcoming hours or days.
See history for the latest developments.
FG-MCP Server
FG-MCP Server logo
Developed by Michat
Initial release 22.02.2026
Latest release (rolling releases)
Written in MD to Python 3.10+
OS Windows, GNU/Linux, MacOS
Development status Active
Type MCP Server
License GNU General Public License v2


General Description

The FlightGear MCP Server is an MCP (Model Context Protocol) server that provides remote control capabilities for the FlightGear flight simulator through a standardized interface.

It allows external applications (such as opencode, or any MCP-compatible client) to interact with FlightGear via HTTP properties.

Main Features

- Reading flight data (position, velocity, attitude) - Aircraft surface controls (throttle, ailerons, elevator, rudder) - Autopilot management - Radio and navigation equipment control - Lighting system management - Camera and view controls - Helicopter-specific controls (MI-6PS) - Multiplayer chat - Environment/time controls

Requirements

- Python 3.10+ - FlightGear with HTTP server enabled - An MCP-compatible client (opencode, Windsurf, Claude Desktop, etc.)

Installation

1. Clone or download the repository 2. Create virtual environment:

  python -m venv venv
  source venv/bin/activate

3. Install dependencies:

  pip install -e .

Flightgear Configuration

Start FlightGear with HTTP server enabled:

  fgfs --http=8080

Or add to launcher settings:

  --http=8080

Available tools

Reading Flight Data

get_position() - Latitude, longitude, altitude get_velocity() - Ground speed, airspeed, vertical speed get_attitude() - Pitch, roll, heading get_engine() - Throttle, thrust get_rotor() - Helicopter rotor status get_flight_data() - All combined data

Surface Controls

set_throttle(value) - Engine throttle (0.0 - 1.0) set_aileron(value) - Ailerons (-1.0 - 1.0) set_elevator(value) - Elevator (-1.0 - 1.0) set_rudder(value) - Rudder (-1.0 - 1.0)

Autopilot

get_autopilot() - Autopilot status set_autopilot(engage) - Engage/disengage autopilot set_heading_bug(value) - Heading (0-360 degrees) set_altitude_target(value) - Target altitude (feet) set_autopilot_altitude(mode) - Altitude mode (e.g., "altitude-hold") set_target_altitude(value) - Alternative target altitude

Radio and Navigation

get_radios() - All frequencies set_com1(freq) - COM1 frequency (MHz) set_com2(freq) - COM2 frequency (MHz) set_nav1(freq) - NAV1 frequency (MHz) set_transponder(code) - Transponder code (4 digits)

Lighting

get_lights() - Light system status set_landing_light(on) - Landing light on/off

Camera and Views

get_views() - Current view information set_view(view) - Change camera view get_zoom() - Current field of view set_zoom(value) - Set field of view (20-120) view_reset() - Reset view to center view_look(direction, degrees) - Look around view_overhead() - Look at overhead panel view_console() - Look at console view_left_window() - Look at left window view_right_window() - Look at right window view_behind() - Look behind

Available views: pilot, copilot, engineer, navigator, left, right,

                 tower, chase, flyby

MI-6PS Helicopter

start_engine() - Start engines stop_engine() - Stop engines set_throttle_mi6(value) - Engine throttle (0.0 - 1.0) set_collective(value) - Collective pitch (-1.0 to 1.0) toggle_rotor_brake(on) - Rotor brake on/off toggle_cargo_door() - Toggle cargo door

Brakes

release_parking_brake() - Release parking brake set_parking_brake(value)- Set brake (0=released, 1=applied)

Multiplayer

set_chat(message) - Send chat message

Utilities

send_key(key) - Send key to FlightGear

Tested keys: v, x, X, s, S, r, R, l, L, f, F, e, E, d, D, a, w,

              F1, F10, Escape

Properties used

The server interacts with FlightGear's property tree via HTTP.

Views

/sim/current-view/view-number /sim/current-view/field-of-view /sim/current-view/pitch-offset-deg /sim/current-view/heading-offset-deg

Controls

/controls/engine/throttle /controls/flight/aileron /controls/flight/elevator /controls/flight/rudder /controls/gear/brake-parking

Position

/position/latitude-deg /position/longitude-deg /position/altitude-ft

Autopilot

/autopilot/locks/heading /autopilot/locks/altitude /autopilot/settings/heading-bug-deg /autopilot/settings/altitude-ft

Radio

/instrumentation/comm[0]/frequencies/selected-mhz /instrumentation/nav[0]/frequencies/selected-mhz /instrumentation/transponder/id-code

Helicopter

/controls/engines/engine/cutoff /controls/engines/engine/magnetos /controls/engines/engine/starter /rotors/main/rpm /rotors/main/blade-pitch-deg

Architecture

The server consists of two main files:

- flightgear.py: Contains the FlightGearClient class that handles HTTP

                communication with FlightGear

- server.py: Defines MCP tools using the FastMCP framework

Communication is via stdio with the MCP client, while FlightGear communication uses the HTTP JSON API.

Know limitations

send_key() requires the FlightGear window to be focused

- Nasal execution via telnet requires proper configuration - Some properties may vary between aircraft

Usage examples

Get all flight data

get_flight_data()

Set up approach

set_com1(118.7) set_nav1(109.5) set_transponder("4500") set_altitude_target(3000)

Helicopter control

start_engine() set_throttle_mi6(0.5) set_collective(0.3)

Camera control

set_view("tower") set_zoom(40)

Version

v0.1.0 - Initial version with basic functions v0.1.1 - Parking brake control, multiplayer chat, day/night environment

        control, extended autopilot properties

License

This project is licensed under the GNU General Public License v2. See the LICENSE file for details..