Skip to main content

Overview

GLuaLS includes a built-in MCP (Model Context Protocol) server. It exposes your connected SRCDS instance as tools for AI agents. When the debugger is connected, GitHub Copilot Chat (and other MCP-capable tools) can run Lua code, fetch console output, read errors, and check debug state without leaving chat.
The GLuaLS team tests AI features with GitHub Copilot Chat. Other MCP AI providers may work, but GLuaLS does not support them.

Available MCP tools

When the debugger is connected, AI agents can use these tools:
ToolDescription
run_luaExecute a Lua string on the server and return the output
run_commandSend a console command and return the result
run_fileRun a specific Lua file on the server
get_outputFetch recent console output from the server
get_errorsGet recent Lua errors from the error tracking panel
get_debug_stateGet the current debugger state (paused, running, realm, etc.)

Setting up

The extension starts the MCP server when it loads. It also registers tools with GitHub Copilot. To connect Copilot:
1

Connect the debugger

Code execution tools (run_lua, run_command, run_file) require an active debug session. get_output, get_errors, and get_debug_state can work whenever the MCP server is running.
2

Configure Copilot to use the MCP server

The VS Code extension usually handles this step. Check that the “Garry’s Mod Language Server” toolset is enabled.
3

Use Copilot Chat

Once connected, Copilot can do things like:
  • “Investigate all recent lua errors on the server.”
  • “Run print("hello world") on the server”
  • “What does the current console output show?”

Example interactions

You: What recent Lua errors have occurred?

Copilot: [calls get_errors] I found 2 errors:
1. addons/my-addon/lua/init.lua:42 - attempt to index nil value 'ply'
   (occurred 3 times, last seen 2 minutes ago)
2. addons/my-addon/lua/cl_hud.lua:18 - attempt to call nil value
   (occurred 1 time, last seen 5 minutes ago)
You: Run print(game.GetMap()) on the server

Copilot: [calls run_lua] Output: gm_flatgrass