X4Mcp — Control X4 from AI Assistants via MCP

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

eg3r
Posts: 11
Joined: Mon, 16. Mar 26, 12:45

X4Mcp — Control X4 from AI Assistants via MCP

Post by eg3r »

Hey everyone,

I'd like to share X4Mcp, a new extension that brings MCP support to X4: Foundations. It runs a lightweight local server inside the game, allowing AI assistants (like Claude, ChatGPT, or any MCP-compatible tool) to interact with your running game instance.

What can it do?
  • Load and list savegames
  • Execute debug/chat commands
  • Check game state
  • Write log messages
  • Store and retrieve persistent key-value data
Why?
If you've ever wanted to ask an AI assistant to "load my latest save" or "run this debug command" and have it actually happen in-game — that's what this enables. It bridges the gap between external tools and a live X4 session. It's also a foundation for building more advanced automation and tooling on top of.

Requirements Links
Feedback and contributions welcome! Let me know if you run into any issues or have ideas for additional tools to expose.
Vovadrik
Posts: 86
Joined: Thu, 8. Apr 21, 05:25
x4

Re: X4Mcp — Control X4 from AI Assistants via MCP

Post by Vovadrik »

X4 in five years: hey chatgpt can you build trade empire for me? :P
eg3r
Posts: 11
Joined: Mon, 16. Mar 26, 12:45

Re: X4Mcp — Control X4 from AI Assistants via MCP

Post by eg3r »

What do you mean 5 years? It can do it already :D :D :D

:lol:
Mitroll
Posts: 5
Joined: Wed, 19. Dec 18, 05:31
x4

Re: X4Mcp — Control X4 from AI Assistants via MCP

Post by Mitroll »

I've always wanted the factions to have a "face" that you can do diplomacy with, like how the borons have a queen. Could this be used as a framework for a mod that has AI control the other factions? It would be really cool if AI could come up with strategies for them, make them declare war and peace, decide where to try to expand, etc, and speak to the player.

idk random thought.
eg3r
Posts: 11
Joined: Mon, 16. Mar 26, 12:45

Re: X4Mcp — Control X4 from AI Assistants via MCP

Post by eg3r »

Mitroll wrote: Sat, 4. Apr 26, 00:52 I've always wanted the factions to have a "face" that you can do diplomacy with, like how the borons have a queen. Could this be used as a framework for a mod that has AI control the other factions? It would be really cool if AI could come up with strategies for them, make them declare war and peace, decide where to try to expand, etc, and speak to the player.

idk random thought.
This project is really useful for developing, I fully automate my tests using this.

But for what you describing is a bit different. Currently X4 is using a "complex" system for so called "faction ai" - basically a set of rules that are hierarchical in nature and run (mostly) periodical to evaluate decisions to take for this particular faction.

I actually develop right now a LLM controlled "brain" of exactly this. I can't promise to to release it soon or at all, first tests show it is running OK.
You'll need some kind of LLM for it, be it remote (like Gemini, ChatGPT or Claude) or local running some kind of ollama-model (or similar).
I use for developing the free tier gemini flash (light) and it produces good results driving all strategic decisions, I will also test local run LLM models (probably also from google) and see how it goes before releasing the extension to the public.

o/

Return to “X4: Foundations - Scripts and Modding”