Skip to content

Add a pytest suite for the MCP server tools #40

Closed

Description

@TMHSDigital

Summary

The repo has no automated tests: no test directory, no test_*.py, and no pytest configuration. Every MCP tool module has zero coverage, including the only tool that writes to disk and the four tools that act on a live server. Add a pytest suite under mcp-server/tests/ and run it in CI.

Where

  • mcp-server/tools/ (all modules: scaffold.py, manifest_gen.py, manifest_common.py, natives.py, detect_framework.py, event_search.py, docs_search.py, txadmin.py, txadmin_client.py)
  • .github/workflows/validate.yml:234-260 (validate-python)

Details

Several bugs found in this audit would have been caught by basic tests. The bug issues carry the specific test cases for each module; this issue is the umbrella for the harness and the modules not covered there:

  • "scaffold_resource_tool overwrites existing files and writes relative to the CWD" (scaffold tests)
  • "generate_manifest emits Lua tables without commas, mishandles scanned scripts" (manifest tests)
  • "detect_framework reports ox_lib users as ox_core and breaks ties by dict order" (detection tests)
  • "txAdmin tools report unexpected or error responses as success" (txAdmin tests with a fake HTTP panel)
  • "lookup_native returns nothing for canonical SCREAMING_SNAKE native names" (natives tests)

Modules with no bug issue of their own: event_search.py, docs_search.py, and manifest_common.py helpers.

Impact

Any change to the tools can regress unnoticed, and fixes for the bugs above cannot be pinned. The txAdmin tools cannot be exercised without a real panel.

Suggested fix

  1. Add mcp-server/requirements-dev.txt with pytest, and mcp-server/tests/conftest.py that puts mcp-server on sys.path.
  2. Use tmp_path and monkeypatch.chdir for file-writing tools, small fixture JSON files for the data tools, and a local http.server.ThreadingHTTPServer on 127.0.0.1:0 as a fake txAdmin panel (no real network).
  3. Test files: test_scaffold.py, test_manifest_gen.py, test_manifest_common.py, test_detect_framework.py, test_natives.py, test_txadmin.py, test_search.py (events and docs), test_server.py (import server, assert list_tools() returns the 10 documented names).
  4. Cases for test_search.py: empty query returns the summary for each tool; search_events(side="server") includes shared events; search_events(game="rdr3") excludes gta5-only events; invalid docs section returns the error; missing and malformed data files return an error rather than raising.
  5. Cases for manifest_common.py: read_workspace_context skips node_modules/.git and returns the first author found; validate_inputs accepts every framework in VALID_FRAMEWORKS.
  6. Add a pytest step to the validate-python job.

Acceptance criteria

  • cd mcp-server && pytest runs and passes locally with no network access.
  • Every tool module has at least one test file.
  • CI runs the suite on every PR and push to main.
  • Contributor docs explain how to run the tests.

Getting started

  • Relevant files: mcp-server/tools/, mcp-server/server.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: CONTRIBUTING.md, CLAUDE.md (MCP server development)

Filed by repo-audit/full-audit at 701824d. Severity: medium. Effort: M. audit-key: testing|mcp-server/tools|pytest-suite

Activity

  1. added
    help wanted
    testing
    on Nov 21, 2026
  2. TMHSDigital commented on Nov 21, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in 19d907a.

    Added mcp-server/tests/ (one file per tool module plus a server registration test), a fake txAdmin panel, fixture data, requirements-dev.txt, a pytest step in CI, and a CONTRIBUTING section on running the tests. Data tools now return an error for malformed data files.

    Verified: 104 tests pass locally with no network access.

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

    help wantedseverity: mediumtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions