Skip to content

generate_manifest emits Lua tables without commas, mishandles scanned scripts #26

Closed

Description

@TMHSDigital

Summary

generate_manifest_tool writes each table entry on its own line with no separator, so any manifest with more than one entry in a block is invalid Lua. The workspace scan also drops shared scripts, hardcodes ui_page 'html/index.html', and duplicates globbed files.

Where

  • mcp-server/tools/manifest_gen.py:110-118 (generate_manifest, client/server table rendering)
  • mcp-server/tools/manifest_gen.py:47-53 (scanned shared bucket ignored)
  • mcp-server/tools/manifest_gen.py:85-91 (config.lua always emitted, globs plus scanned files)
  • mcp-server/tools/manifest_gen.py:101-108 (unclassified scripts routed to client_scripts)
  • mcp-server/tools/manifest_gen.py:120-126 (hardcoded ui_page / files)
  • mcp-server/tools/manifest_gen.py:67-68, 81, 104-106 (values interpolated into Lua strings unescaped)
  • mcp-server/tools/manifest_common.py:25-26 (AUTHOR_RE / DESC_RE)
  • mcp-server/tools/manifest_common.py:131-143 (detect_nui_presence returns only a bool)

Details

lines.append("client_scripts {")
for entry in client_entries:
    lines.append(f"    {entry}")
lines.append("}")

With scripts=['client/a.lua'], or a workspace_path containing script files, the output is:

client_scripts {
    'client/*.lua'
    'client/a.lua'
}

{ 'a' 'b' } is a Lua syntax error. Other problems in the same function:

  • scan_script_files returns a shared list, but only client and server are copied into scripts, so shared/*.lua, sh_*.lua and a scanned config.lua are discarded.
  • shared_scripts { 'config.lua' } is emitted for Lua even when no config.lua exists.
  • Caller-supplied scripts whose path contains neither "client" nor "server" go to client_scripts, so shared code never runs on the server.
  • detect_nui_presence returns True for web/dist, ui/ or nui/, but the output always says ui_page 'html/index.html' and files { 'html/**' }.
  • Scanned client/main.lua is listed next to the 'client/*.lua' glob that already covers it.
  • Quotes are not escaped: name="o'brien" yields description 'o'brien'. AUTHOR_RE ([^'"]+) reads author "O'Brien" as O.

Impact

The documented auto-detect mode (workspace_path) and the scripts parameter both return an fxmanifest.lua that FXServer cannot parse, so the resource fails to start. Even after fixing commas, typical layouts (a shared/ folder, a Vite NUI in web/dist) get manifests with missing shared code, a missing config.lua, and a blank NUI. The single-entry default output happens to be valid, which hides the bug.

Steps to reproduce

  1. cd mcp-server
  2. python -c "from tools.manifest_gen import generate_manifest as g; print(g('r','gta5','lua','standalone',scripts=['client/a.lua']))"
  3. Observe two entries on consecutive lines with no comma.
  4. Create a workspace with shared/utils.lua, client/main.lua and web/dist/index.html, then call g('x','gta5','lua','standalone', workspace_path=<dir>): no shared/utils.lua, an unconditional config.lua, and ui_page 'html/index.html'.

Suggested fix

  • Join entries with ",\n" (or put a trailing comma on every entry, which Lua allows).
  • Emit shared_scripts from the scanned shared list; include config.lua only if it exists; route unclassified files to shared, not client.
  • When scanning, use either the scanned list or the globs, not both.
  • Return the detected NUI root from detect_nui_presence (for example web/dist/index.html) and derive ui_page and files from it.
  • Escape \ and ' in all interpolated values (shared helper with the scaffolder), and make AUTHOR_RE/DESC_RE match the opening quote.

Acceptance criteria

  • Every generated list block separates entries with commas; output with multiple scripts parses with luac -p (or a Lua parser).
  • Default lua/gta5/standalone output matches a pinned golden string.
  • scripts=["shared/config.lua"] and scanned shared files land in shared_scripts.
  • A workspace with only web/dist/index.html produces ui_page 'web/dist/index.html'; with html/index.html it produces html/index.html.
  • Name, author, description and dependency strings containing ' or \ are escaped or rejected.
  • dependencies=["ox_lib"] with framework esx gives es_extended then ox_lib, with no duplicate when es_extended is also passed.
  • Tests for scan_script_files: cl_x.lua to client, sv_x.lua to server, sh_x.lua to shared, README.md ignored, nonexistent dir returns empty lists.

Getting started

  • Relevant files: mcp-server/tools/manifest_gen.py, mcp-server/tools/manifest_common.py
  • How to run checks: there is no test suite yet; run the MCP server with cd mcp-server && pip install -r requirements.txt && python server.py, and CI checks live in .github/workflows/validate.yml
  • Related docs: skills/fxmanifest/SKILL.md, rules/fxmanifest-standards.mdc

Filed by repo-audit/full-audit at 701824d. Severity: high. Effort: S. audit-key: bug|mcp-server/tools/manifest_gen.py|generate_manifest

Activity

  1. added
    bug
    on Nov 21, 2026
  2. TMHSDigital commented on Nov 21, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in 8e550e1.

    Rendered all list blocks with comma-separated, escaped entries; routed scanned and unclassified scripts to shared_scripts; used either the scanned list or default globs; derived ui_page/files from the detected NUI page; deduped dependencies; read quoted author/description values whole.

    Verified: Exercised default output (unchanged golden), multi-script caller input, a workspace with shared/, sh_x.lua, README.md and web/dist (ui_page 'web/dist/index.html'), an html/ workspace, an O'Brien author and ox_lib + es_extended dependencies. No Lua parser is available locally, so comma placement was verified by inspection of the output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugseverity: high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions