Skip to content

All docs_index.json snippets are the same HTML fragment, breaking search_docs #24

Closed

Description

@TMHSDigital

Summary

Every entry in the committed mcp-server/data/docs_index.json has the same snippet, <a class="active" href, so search_docs_tool can only match page titles and URLs. Content queries return nothing, and every hit shows the same useless snippet.

Where

  • .github/scripts/build_docs_index.py:142-156 (extract_snippet)
  • .github/scripts/build_docs_index.py:136 (extract_title, suffix list)
  • .github/scripts/build_docs_index.py:203-215 (main, writes before the failure threshold check)
  • .github/workflows/update-docs-index.yml:25-38 (Validate index step)
  • mcp-server/tools/docs_search.py:61-67 (search_docs, match logic)
  • mcp-server/data/docs_index.json

Details

extract_snippet slices raw_html[body_start : body_start + 10000] from the first <main/<article/<body, strips complete tags with a regex, and keeps the rest. On the current docs.fivem.net markup the first 10,000 characters are navigation markup with no text, and the slice ends partway through a tag the regex cannot match. Result at 701824d: all 82 entries have "snippet": "<a class=\"active\" href" (22 chars, 82/82 identical).

Titles are also wrong: extract_title strips " | FiveM Documentation" and " - Cfx.re Docs", but the live suffix is " - Cfx Documentation", so every title keeps it (for example Scripting Introduction - Cfx Documentation).

The monthly workflow only checks that the snippet key exists, so the bad data has been re-committed by the bot on each run.

Separately, main() writes OUTPUT_PATH first and only then checks if len(index) < len(PAGES) * 0.8: sys.exit(1). A local run during an outage replaces the committed index with a partial or empty one.

Impact

search_docs_tool, documented as searching "for parameters, gotchas, and code samples", works only as a lookup over 82 page titles. Every agent query for an API name or concept (for example replicated, routing bucket, AddStateBagChangeHandler) returns "No documentation pages found", and queries for markup words such as class match all 82 pages.

Steps to reproduce

  1. cd mcp-server
  2. python -c "from tools.docs_search import search_docs; print(search_docs('replicated', '', './data'))" returns no pages, although the state bags page is about replication.
  3. python -c "from tools.docs_search import search_docs; print(search_docs('class', '', './data')[:80])" returns Found 82 page(s).
  4. python -c "import json,collections; d=json.load(open('data/docs_index.json',encoding='utf-8')); print(collections.Counter(p['snippet'] for p in d))" shows one value with count 82.

Suggested fix

  • Parse pages with the stdlib html.parser: drop <script>, <style> and <nav>, then take the text of the main article container instead of a fixed 10 KB window.
  • Add " - Cfx Documentation" to the title suffixes.
  • In main(), check the threshold before writing, or write to a temp file and os.replace only on success.
  • In update-docs-index.yml, require non-trivial snippets (for example at least 80% of pages have a snippet of 100+ characters that does not start with <, and the number of distinct snippets is close to the page count).
  • Regenerate and commit docs_index.json.

Acceptance criteria

  • Regenerated docs_index.json has distinct, human-readable snippets for most pages and no snippet starting with <.
  • No title ends with - Cfx Documentation.
  • search_docs('replicated') returns the state bags page.
  • A failed or partial fetch run leaves the existing docs_index.json untouched.
  • The workflow validation step fails on an index where all snippets are identical.

Getting started

  • Relevant files: .github/scripts/build_docs_index.py, .github/workflows/update-docs-index.yml, mcp-server/tools/docs_search.py, mcp-server/data/docs_index.json
  • 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: CLAUDE.md (MCP Server table, search_docs_tool row)

Filed by repo-audit/full-audit at 701824d. Severity: high. Effort: S. audit-key: bug|.github/scripts/build_docs_index.py|extract_snippet

Activity

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

    @TMHSDigital
    OwnerAuthor

    Fixed in 0be581d.

    Rewrote the docs index extractor to take text from the docs content container with html.parser, stripped the new title suffix, made the build write atomically only after the threshold check, added a snippet-quality gate to update-docs-index.yml, and regenerated docs_index.json.

    Verified: Regenerated index has 82 pages with 82 distinct snippets, none starting with <, no title ending in "- Cfx Documentation"; search_docs('replicated') returns the State Bags page; the new workflow gate rejects the previous index and accepts the new one.

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