Skip to main content
Glama

mcp-garry-codes β€” The Principal Garry's Mod Protocol Server

npm version License: MIT TypeScript Model Context Protocol Author

mcp-garry-codes is a specialized, production-grade Model Context Protocol (MCP) server engineered specifically for the Garry's Mod (GLua) ecosystem. It bridges AI coding agents with deep Source Engine awareness, static verification, net-security vulnerability auditing, zero-GC performance profiling, and headless testing.

Created & Maintained by: M A R W A N


⚑ The Garry's Mod Engineering Dilemma

Garry's Mod development represents a notoriously hostile coding environment:

  • Three Rigid Execution Realms (SERVER, CLIENT, and MENU) with strict serialization and transmission rules.

  • Micro-Allocation Garbage Collection Traps inside high-frequency rendering and simulation hooks (RenderScreenspaceEffects, HUDPaint, Think, Move) triggering severe client FPS drops.

  • Pervasive Network Vulnerabilities stemming from unvalidated client-authoritative net messages, rate-limit exploitation, SQL injections, and command execution backdoors.

  • Source Engine VGUI & Prediction Peculiarities where standard desktop GUI mental models fail.

mcp-garry-codes equips LLMs and autonomous coding assistants with the deep domain knowledge and verification tools necessary to produce bulletproof GLua code.


Related MCP server: LLMMO Game Server

πŸ› οΈ Tool Suite (9 Core Tools)

Tool Name

Realm Mode

Primary Function

Side Effects

search_gmod_wiki

Read-only

Query Facepunch Garry's Mod Wiki and indexed documentation filtered by realm and category.

Cached disk/memory

get_gmod_symbol

Read-only

Retrieve exact parameter signatures, return values, caveats, and official examples.

Cached

web_search_glua

Read-only

Targeted search across GitHub GLua repositories, Facepunch archives, and developer discussions.

HTTPS query

lint_glua

Read-only / Pure

Static analysis parsing GMod C-style syntax (//, /* */, &&, `

audit_net_security

Read-only / Audit

Scan addon message graphs for unauthenticated receivers, SQL injections, and missing util.AddNetworkString.

None

analyze_performance

Read-only / Audit

Profile GLua code for Zero-GC hot-path violations (allocations in HUDPaint, Think, uncached fonts).

None

scaffold_gmod_component

Creation

Scaffold idiomatic SWEPs, SENTs, NextBots, STOOLs, VGUI panels, HUDs, Effects, DarkRP modules, or gamemodes.

File creation (Workspace only)

run_glua_test

Execution / Sandbox

Run headless GLua unit tests using the embedded Source Engine mock runtime via LuaJIT / Python.

Sandboxed subprocess

package_and_validate

Verification / Build

Validate addon.json and verify file structures against Steam Workshop & GMA packaging rules.

Optional .gma compilation


πŸ“¦ Addressable MCP Resources

Connect to rich contextual resources using standard MCP URIs:

  • gmod://wiki/hooks β€” Authoritative list of Garry's Mod hooks across all realms.

  • gmod://wiki/libraries β€” Core functions and libraries available in GLua.

  • gmod://realms/matrix β€” Execution realm boundaries, powers, and restrictions.

  • gmod://schemas/addon_json β€” Steam Workshop addon.json schema specification.


🧭 Guided Workflow Prompts

  • audit_addon β€” Comprehensive security and performance review of an addon folder.

  • fix_net_exploit β€” Guided repair workflow for net message vulnerabilities and authorization checks.

  • scaffold_swep β€” Interactive creation of a predicted, zero-latency weapon.

  • build_derma_menu β€” Responsive, DPI-scaled VGUI Derma interface builder.

  • scaffold_nextbot β€” Autonomous NextBot AI entity with navigation coroutines.

  • scaffold_toolgun_stool β€” Production Toolgun STOOL with CPanel convars, left/right clicks, and language strings.

  • scaffold_darkrp_module β€” Modular DarkRP package with custom jobs, shipments, categories, and hooks.

  • scaffold_effect β€” Custom 3D particle and billboard render effect.

  • optimize_zero_gc β€” Profile and optimize rendering hooks for zero garbage-collection stutter.


πŸš€ Quick Start & Installation

Option 1: Run instantly with npx (Recommended)

npx -y mcp-garry-codes

Option 2: Global installation via npm

npm install -g mcp-garry-codes
mcp-garry-codes

πŸ’» Client Configuration

1. Antigravity IDE & Cursor (mcp_config.json)

Add the server definition to your mcp_config.json:

{
  "mcpServers": {
    "mcp-garry-codes": {
      "command": "npx",
      "args": ["-y", "mcp-garry-codes"],
      "env": {
        "WORKSPACE_ROOT": "${workspaceFolder}",
        "PYTHON_PATH": "python"
      }
    }
  }
}

2. Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "garrys-mod": {
      "command": "npx",
      "args": ["-y", "mcp-garry-codes"]
    }
  }
}

πŸ›‘οΈ Security Architecture & Threat Model

  1. Workspace Path Jail: All file queries, linter checks, and scaffolding operations are verified with PathGuard and strictly quarantined within the user's configured workspace.

  2. Subprocess Isolation: External processes (python, glualint, luajit) execute via child_process.execFile with explicit argument arraysβ€”no shell interpolation (shell: false) and strict execution timeouts (5,000ms default).

  3. Automated Credential Redaction: Result envelopes pass through sanitization regexes that scrub Steam API keys, MySQL connection strings, and RCON passwords.

  4. Net Message Auditing: Receivers executing mutations without checking ply:IsAdmin() or access privileges are flagged as critical vulnerabilities.


πŸ§ͺ Headless GLua Simulation Engine

mcp-garry-codes includes an embedded Source Engine mock runtime (src/test_harness/lua/glua_mock.lua) and Python test orchestrator (src/test_harness/python/gmod_tester.py). It enables running headless unit tests without launching the Garry's Mod 32-bit or 64-bit client executable:

  • Full 3D Vector and Angle metatables (Distance, Dot, Cross, Length2D, RotateAroundAxis).

  • Mock Entity and Player objects with health, inventory, and trace methods.

  • In-memory FIFO bitstream queue verifying net.Write* and net.Read* alignment.

  • Event bus verifying hook.Add and hook.Run.


πŸ“„ License

This project is licensed under the MIT License.

Author: M A R W A N

Available Tools

9 tools
analyze_performanceAnalyze GLua Hot-Path PerformanceA
Read-onlyIdempotent

Profile Garry's Mod Lua code via static AST inspection to detect runtime performance traps, Zero-GC violations, and LuaJIT garbage collector bottlenecks. Purely analytical static inspection; does NOT execute code, does NOT evaluate scripts in a VM, and does NOT modify files on disk. Operates under zero-side-effect guarantees. Provide either file_path (workspace path) or code_content (raw snippet); when both are supplied, file_path takes precedence. Automatically inspects high-frequency rendering and simulation hooks (HUDPaint, RenderScreenspaceEffects, Think, Move). Use this tool to prevent client FPS stutter and server tickrate drops by flagging table allocations (Color(), Vector(), Angle()), unlocalized global lookups, and dynamic font creation inside per-frame hooks. Do NOT use for syntax or realm correctness checks (use lint_glua instead), network message exploit detection (use audit_net_security instead), or functional assertion testing (use run_glua_test instead). Returns a GModToolResult envelope with status ('success' or 'failed'), summary, and data containing performance_score (0-100), issues array (hook_name, line, severity, category, description, recommended_code), and allocation metrics (allocations_in_hot_path, global_calls_in_hot_path, dynamic_draw_calls).

Inputs: file_path, code_content. Returns: data, status, summary, evidence, +2 more

audit_net_securityAudit Network Message SecurityA
Read-onlyIdempotent

Perform static AST security auditing across an addon's network messaging architecture (Garry's Mod net library) to identify exploitable receivers, SQL injection vectors, and missing network string registrations. Purely static AST analysis requiring no authentication, no network transmission, and zero file modifications. Scans code without executing it. Specify addon_dir (root directory of the addon; defaults to workspace root if omitted). Optionally provide file_paths array to restrict scanning to specific Lua files within that addon. Use this tool before releasing or deploying multiplayer Garry's Mod addons to detect unauthenticated net.Receive handlers (missing ply:IsAdmin or permission checks), client-authoritative SQL queries, and unregistered net strings that crash network channels. Do NOT use for general syntax validation (use lint_glua instead) or rendering performance profiling (use analyze_performance instead). Returns a GModToolResult envelope with status ('success' or 'failed'), summary, and data containing addon_dir, messages_found, registered_strings, network_graph (transmitters and receivers), and categorized vulnerabilities array (severity, type, message_name, file, line, description, recommended_fix, vulnerable_code).

Inputs: addon_dir, file_paths. Returns: data, status, summary, evidence, +2 more

get_gmod_symbolGet Exact GMod Symbol DocumentationA
Read-onlyIdempotent

Retrieve authoritative, complete API documentation for a specific, known Garry's Mod symbol (function, hook, library method, panel, or class) from the Facepunch Wiki index. Read-only lookup operation with zero side effects, no authentication required, and instant indexed retrieval; does NOT modify the workspace. If the symbol is not found in the index, returns status 'failed' with data null and provides actionable search alternatives in nextActions. Requires an exact, case-sensitive or standard symbol identifier (e.g. 'net.Receive', 'surface.DrawPoly', 'GM:PlayerInitialSpawn', 'Entity:TakeDamage'). Set include_examples to false (defaults to true) to exclude code examples and reduce token consumption. Use this tool when you know the exact symbol name and require complete parameter specifications, return types, engine caveats, realm affinity, or code examples. Do NOT use for keyword or topic searches (use search_gmod_wiki instead). Do NOT use for third-party addon code or community forum workarounds (use web_search_glua instead). Returns a GModToolResult envelope with status ('success' or 'failed'), summary, and data containing symbol, realm, description, arguments array (name, type, optional, default, description), returns array, examples array, notes, warnings, and canonical wiki_url.

Inputs: symbol (required), include_examples. Returns: data, status, summary, evidence, +2 more

lint_gluaLint GLua Static CodeA
Read-onlyIdempotent

Perform deep static analysis and AST validation on Garry's Mod Lua (GLua) source code to detect syntax errors, realm boundary violations (server/client/menu mismatches), global namespace pollution, and missing AddCSLuaFile calls. Purely read-only static analysis requiring zero credentials or network access. Does NOT execute code and does NOT modify files on disk; when fix_formatting is true, the formatted code is returned strictly inside the result envelope without overwriting the source file. Provide either file_path (workspace-relative or absolute) or code_content (raw Lua snippet); when both are supplied, file_path takes precedence. If target_realm is 'auto', automatically detects the execution realm from file path prefixes (sv_, cl_, sh_) or defaults to 'shared'. Use this tool before committing code or running tests to ensure syntax and realm hygiene. Do NOT use for runtime performance profiling (use analyze_performance instead to detect GC allocations in render hooks), network vulnerability scanning (use audit_net_security instead), or functional test execution (use run_glua_test instead). Returns a GModToolResult envelope containing status ('success' or 'failed'), summary, data with valid (boolean), error_count, warning_count, realm_detected, diagnostics list (line, column, severity, rule code, message, suggestion), and optional formatted_code.

Inputs: file_path, code_content, target_realm, fix_formatting. Returns: data, status, summary, evidence, +2 more

package_and_validatePackage and Validate GMA AddonA
Idempotent

Verify a Garry's Mod addon directory against official Steam Workshop and GMA packaging rules (addon.json validation, file extension whitelist, path casing), with optional .gma archive compilation. Read-only validation by default; does NOT mutate files. If build_gma is true AND validation passes with zero illegal files, compiles a .gma binary package using the external gmad executable (requires GMAD_PATH environment variable) to output_gma_path (defaults to '<addon_dir>/out.gma'). addon_dir specifies the root directory of the addon (defaults to workspace root). Set build_gma to true (default false) to trigger .gma compilation. Optional output_gma_path sets the target .gma binary path. Use this tool as the final verification gate before uploading addons to the Steam Workshop or deploying to a dedicated server. Checks addon.json structure, flags non-whitelisted files (e.g. .psd, .git, .exe), and warns on uppercase characters that cause 404s on Linux servers. Use scaffold_gmod_component to bootstrap addon structures, and lint_glua/audit_net_security to audit code quality prior to packaging. Returns a GModToolResult envelope with status ('success' or 'failed'), summary, and data containing valid (boolean), addon_json_valid (boolean), total_files, total_size_bytes, illegal_files array (path, rejection reason), warnings array (casing and metadata warnings), and optional gma_path.

Inputs: addon_dir, build_gma, output_gma_path. Returns: data, status, summary, evidence, +2 more

run_glua_testRun Headless GLua Unit TestsA
Read-onlyIdempotent

Execute headless Garry's Mod unit tests and assertions using the embedded Source Engine mock runtime (Python/Lua test harness) without requiring the Garry's Mod game client. Sandboxed headless subprocess execution with a default 5000ms timeout (configurable via timeout_ms up to 30000ms). Safe and non-destructive; does NOT modify source files on disk. Surfaces assertion failures and runtime exceptions with exact line numbers and stack traces. Provide either test_file_path (workspace path to a test script) or code_to_test (inline GLua test string with assertions); when both are provided, test_file_path takes precedence. Configure mock_realm ('client', 'server', 'shared', default 'shared') to set SERVER and CLIENT boolean constants and simulate realm-specific global libraries. Use this tool to execute automated test suites, verify mathematical computations, test hook callbacks, and validate net message serialization logic. Do NOT use for static analysis without execution (use lint_glua instead) or Zero-GC allocation profiling (use analyze_performance instead). Returns a GModToolResult envelope with status ('success' when all assertions pass, 'failed' on assertion or execution error), summary, and data containing passed (boolean), tests_run count, failures count, errors array (test_name, error_message, stack_trace), output_log (raw stdout/stderr), and execution_time_ms.

Inputs: mock_realm, timeout_ms, code_to_test, test_file_path. Returns: data, status, summary, evidence, +2 more

scaffold_gmod_componentScaffold Garry's Mod ComponentA
Idempotent

Generate production-grade, realm-separated Garry's Mod boilerplate code for 10 standard component architectures: SWEP (weapons), SENT (scripted entities), nextbot (NextBot AI with pathfinding coroutines), custom_tool (toolgun STOOLs with CPanel), vgui_panel (Derma UI), hud (Zero-GC HUDPaint overlays), gamemode (GM framework), effect (dynamic particle render effects), darkrp_module (DarkRP jobs, shipments, categories), and addon_skeleton (standard directory layout with addon.json). Dual operational mode: when output_dir is omitted (default), operates as a zero-side-effect preview returning a virtual code_manifest without touching the disk; when output_dir is provided, writes files directly to disk relative to workspace, creating directories and overwriting existing files at target paths. Implements idiomatic realm separation (e.g. server init.lua, client cl_init.lua with AddCSLuaFile headers, shared.lua). Requires component_type (enum: 'swep', 'sent', 'nextbot', 'custom_tool', 'vgui_panel', 'hud', 'gamemode', 'effect', 'darkrp_module', 'addon_skeleton') and alphanumeric identifier name (e.g. 'weapon_plasma_rifle', 'nb_stalker', 'tool_remover'). Optional output_dir designates target folder on disk. Optional options object configures category, base class, author, printable_name, and vgui_type ('frame', 'button', 'scroll', 'custom'). Use this tool when bootstrapping new Garry's Mod addons, weapons, entities, AI nextbots, STOOLs, or UI panels with idiomatic architecture and prediction support. Do NOT use for editing existing code or linting (use lint_glua). After scaffolding, use package_and_validate to verify Steam Workshop packaging compliance. Returns a GModToolResult envelope with status ('success' or 'failed'), summary, and data containing component_type, files_created array (path, purpose), and code_manifest mapping relative file paths to generated Lua source code strings.

Inputs: name (required), component_type (required), options, output_dir. Returns: data, status, summary, evidence, +2 more

search_gmod_wikiSearch Official Garry's Mod WikiA
Read-onlyIdempotent

Query the official Facepunch Garry's Mod Wiki and indexed API reference by keyword or conceptual topic across functions, hooks, libraries, panels, and enums. Read-only operation with zero side effects, no authentication required, and cached offline-first execution with live documentation fallback; does NOT modify the workspace. Requires a query string. Optionally filter by category ('functions', 'hooks', 'libraries', 'panels', 'enums', 'all', default 'all'), realm ('server', 'client', 'shared', 'menu', 'all', default 'all'), and max_results (1 to 20, default 5). Use this tool for broad discovery, conceptual exploration, or finding candidate APIs when the exact symbol name is unknown. Do NOT use if you already know the exact function or hook identifier (use get_gmod_symbol instead for complete signatures, argument specifications, caveats, and official examples). Do NOT use for third-party libraries, community forum solutions, or undocumented engine quirks (use web_search_glua instead). Returns a GModToolResult envelope with status ('success' or 'failed'), summary, and data containing query, category, realm, total_matches, and an array of matching results (title, canonical wiki_url, realm, summary, signature, category).

Inputs: query (required), realm, category, max_results. Returns: data, status, summary, evidence, +2 more

web_search_gluaSearch GLua Community & GitHubA
Read-onlyIdempotent

Search external Garry's Mod developer communities, GitHub repositories, Facepunch archives, Reddit, and Steam Community forums for community-developed solutions, workarounds, and undocumented engine behaviors. Read-only external web search with open-world egress; requires no credentials and produces zero local file mutations or state modifications. Requires a query string. Optionally filter target domains with domain_filter ('github', 'facepunch', 'reddit', 'steam', 'all', default 'all') and limit results with max_results (1 to 10, default 5). Use this tool for troubleshooting obscure runtime bugs, researching community conventions, finding GitHub code implementations, or resolving undocumented engine quirks where official documentation is silent. Do NOT use for official Garry's Mod API reference, hook signatures, or standard library documentation (use get_gmod_symbol for exact lookups or search_gmod_wiki for topic searches). Returns a GModToolResult envelope with status ('success' or 'failed'), summary, and data containing query and results array (title, destination url, snippet, source platform).

Inputs: query (required), max_results, domain_filter. Returns: data, status, summary, evidence, +2 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 9 tools

    Disambiguation4/5

    Each tool has a clearly distinct primary purpose, and cross-references between similar tools (get vs search, lint vs audit vs analyze) are explicit. However, the three static analyzers (lint_glua, audit_net_security, analyze_performance) all operate on code and return diagnostic-like results, which could lead to misselection if an agent requests a generic 'check my code' without specifying the concern.

    Naming Consistency4/5

    All tool names are lowercase snake_case and start with a verb (get, web_search, lint, search, audit, analyze, scaffold, run, package), creating a generally consistent pattern. Minor deviations exist: web_search_glua and search_gmod_wiki both express search but with different word order and prefixes, and the glua suffix is inconsistently placed (web_search_glua, lint_glua, run_glua_test).

    Tool Count5/5

    Nine tools is well within the ideal 3-15 range and maps neatly to a GMod addon development workflow: documentation lookup, community search, three distinct code quality checks, scaffolding, testing, and packaging. Each tool earns its place with a specific function, and none feel redundant or padding.

    Completeness5/5

    The tool set covers the full addon development lifecycle: discover APIs (get, search), research community solutions (web search), write/analyze code (scaffold, lint, audit, analyze), test (run_glua_test), and package (package_and_validate). There are no dead ends or obvious missing operations for the stated domain of Garry's Mod addon development.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers