> ## Documentation Index
> Fetch the complete documentation index at: https://gluals.arnux.net/llms.txt
> Use this file to discover all available pages before exploring further.

# AI and Copilot integration

> Let AI tools search GLua documentation and work with a connected Garry's Mod session.

## Overview

The VS Code extension provides tools for GitHub Copilot and a local MCP server for other compatible AI clients.

AI tools can search GLua API documentation without a running game. Runtime tools can also execute Lua, run commands, and inspect recent output when the debugger is connected.

<Note>
  Runtime commands can change game state. Review tool requests before allowing them to run.
</Note>

***

## GitHub Copilot tools

The extension registers these tools directly with VS Code:

| Tool                | Description                                              |
| ------------------- | -------------------------------------------------------- |
| `gluaDocs`          | Search Garry's Mod API definitions and workspace symbols |
| `gmodRunLua`        | Execute Lua in the selected realm                        |
| `gmodRunCommand`    | Run a Garry's Mod console command                        |
| `gmodRunFile`       | Run a Lua file in the selected realm                     |
| `gmodGetOutput`     | Read recent debugger output                              |
| `gmodGetErrors`     | Read recent debugger errors                              |
| `gmodGetDebugState` | Check the debugger, realm, and language server state     |

***

The runtime tools require the [debugger](/debugger/setup). Documentation search does not.

## MCP tools

The local MCP server provides these tool names for compatible clients:

| Tool              | Description                                            |
| ----------------- | ------------------------------------------------------ |
| `run_lua`         | Execute Lua in the active debug session                |
| `run_command`     | Run a Garry's Mod console command                      |
| `run_file`        | Run a Lua file                                         |
| `get_output`      | Read recent debugger output                            |
| `get_errors`      | Read recent debugger errors                            |
| `get_debug_state` | Read the current debugger state                        |
| `list_realms`     | List available realms and the currently selected realm |

The MCP server listens only on your computer and uses an authentication token. It is enabled by default.

## Set up Copilot

<Steps>
  <Step title="Enable the GLuaLS tools">
    Open Copilot Chat's tool picker and enable the GLuaLS tools you want to use.
  </Step>

  <Step title="Connect the debugger for runtime tools">
    Start a Garry's Mod debug session before asking Copilot to run Lua, run files, or send commands.
  </Step>

  <Step title="Use Copilot Chat">
    Ask a direct question, such as "What arguments does `Entity:TakeDamageInfo` accept?" or "Show the recent Lua errors."
  </Step>
</Steps>

## Settings

| Setting                              | Default | Description                                                |
| ------------------------------------ | ------- | ---------------------------------------------------------- |
| `gluals.gmod.mcp.enabled`            | `true`  | Start the local MCP server                                 |
| `gluals.gmod.mcp.port`               | `0`     | Local port. `0` chooses an available port                  |
| `gluals.gmod.mcp.authToken`          | `""`    | Authentication token. An empty value creates a local token |
| `gluals.gmod.mcp.rateLimitPerMinute` | `60`    | Maximum MCP requests per minute for each client            |
