Skip to content

lookup_native returns nothing for canonical SCREAMING_SNAKE native names #35

Closed

Description

@TMHSDigital

Summary

lookup_native_tool matches the query as a plain lowercase substring of the stored PascalCase name, so the canonical SCREAMING_SNAKE names used by the upstream native reference and most docs (for example GET_PLAYER_PED) return no results.

Where

  • mcp-server/tools/natives.py:53-60 (lookup_native, match logic)
  • mcp-server/tools/natives.py:29-33 (game interpolated into the filename unvalidated)
  • mcp-server/tools/natives.py:55-58, mcp-server/tools/natives.py:116 (.lower() on description/hash, indexing p['type']/p['name'])
  • .github/workflows/validate.yml:25-55 (native schema checks)

Details

Against the shipped data at 701824d:

  • lookup_native('GET_PLAYER_PED', 'gta5', None, './data') returns No natives found matching 'GET_PLAYER_PED' for gta5.
  • lookup_native('GetPlayerPed', ...) returns 4 results.

game is used directly in natives_{game}.json, so game='rdr2' returns Error: native database not found at ./data/natives_rdr2.json (exposing the path) instead of an invalid-game message.

Lines 55-58 call .lower() on description and hash, and line 116 indexes p['type']/p['name'], but the CI schema step only asserts that keys exist. A future transform_natives.py run that emits "description": null or a param without type would crash every query. The current data is clean.

Impact

Native lookup is a core tool. An agent that follows the upstream reference or docs (which use SCREAMING_SNAKE) is told that natives such as GET_ENTITY_COORDS do not exist.

Steps to reproduce

  1. cd mcp-server
  2. python -c "from tools.natives import lookup_native as l; print(l('GET_PLAYER_PED','gta5',None,'./data'))"
  3. Output: No natives found matching 'GET_PLAYER_PED' for gta5.

Suggested fix

  • Normalise both the query and the native name by removing _ and lowercasing before the name comparison (keep the hash comparison as is, accepting with or without 0x).
  • Validate game against {"gta5", "rdr3"} and return a clear error otherwise.
  • Use str(native.get("description") or "") style access and p.get("type", "") so malformed entries do not raise.
  • Extend the validate.yml schema step to assert description and hash are strings and each param has type and name.

Acceptance criteria

  • GET_PLAYER_PED, GetPlayerPed and getplayerped all find GetPlayerPed.
  • Hash lookup works with and without 0x, in any case.
  • game="rdr2" returns an invalid-game error without a file path.
  • A native with description: null or a param missing type does not raise.
  • Tests (small fixture JSON plus one smoke test on real data) also cover: side="server" includes shared and excludes client; category="vehicle" matches VEHICLE; empty query and category returns the category summary whose counts sum to the total; more than 25 results shows 25 plus "... and N more"; descriptions over 300 chars are truncated.

Getting started

  • Relevant files: mcp-server/tools/natives.py, .github/workflows/validate.yml
  • 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/native-functions/SKILL.md

Filed by repo-audit/full-audit at 701824d. Severity: medium. Effort: S. audit-key: bug|mcp-server/tools/natives.py|lookup_native

Activity

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

    @TMHSDigital
    OwnerAuthor

    Fixed in ef4d72f.

    Names are compared with underscores removed and case folded, hashes match with or without 0x, game is validated, optional fields are read defensively, and validate.yml asserts hash/description/param shape.

    Verified: GET_PLAYER_PED, GetPlayerPed and getplayerped all find GetPlayerPed; 0x6E31E993 and 6e31e993 match by hash; game="rdr2" errors without a path; null description / param without type do not raise. Covered by mcp-server/tests/test_natives.py.

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

    buggood first issueseverity: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions