Skip to content

backupList and JSON API tools return unbounded raw output to the model #117

Closed

Description

@TMHSDigital

Summary

homelab_backupList returns restic snapshots --json for the whole repository with no limit, and several API tools return raw service JSON unchanged. The only bound is the 1 MiB output cap, and when it trips the JSON is cut from the front and no longer parses.

Where

  • mcp-server/src/tools/backupList.ts:30 (no count/--latest, unlike backupStatus)
  • mcp-server/src/tools/prometheusQuery.ts:30
  • mcp-server/src/tools/npmProxyHosts.ts:19, npmCerts.ts, grafanaSnapshot.ts:25
  • mcp-server/src/tools/adguardQueryLog.ts:35 (up to count=500)
  • mcp-server/src/utils/ssh-api.ts:217 (HOMELAB_MAX_OUTPUT_BYTES, default 1 MiB)

Impact

A daily backup schedule produces about 365 snapshots a year. At roughly 500-800 bytes of JSON each, one backupList call returns 200-300 KB, which is tens of thousands of tokens and more than common MCP clients accept for a single tool result. Broad PromQL queries behave the same way. The model gets truncated, unparseable JSON or uses up its context.

Steps to reproduce

  1. Repository with a year of daily snapshots.
  2. Call homelab_backupList with no filters.

Suggested fix

  • Add count (default 20, max 200) to backupList.
  • For JSON tools, parse and return a compact summary by default (backupList: id, time, host, paths, tags; prometheusQuery: labels and value, first N series with a "N more" note), with an option for raw output.
  • Truncate at entry boundaries rather than with the byte tail.

Acceptance criteria

  • backupList output size is bounded by a parameter.
  • JSON tools never return syntactically broken JSON because of truncation.

Getting started

  • Relevant files: mcp-server/src/tools/backupList.ts, mcp-server/src/tools/prometheusQuery.ts
  • How to run tests: cd mcp-server && npm install && npm test

Filed by repo-audit/full-audit at a59395f. Severity: medium. Effort: M. audit-key: performance|mcp-server/src/tools/backupList.ts|snapshots-json

Activity

  1. added
    help wanted
    performance
    severity: medium
    on Nov 18, 2026
  2. TMHSDigital commented on Nov 18, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in b7017a0. backupList now takes count (default 20, max 200) and returns compact newest-first entries; prometheusQuery takes limit (default 100) and trims series while staying valid JSON; backupList, prometheusQuery, npmProxyHosts, npmCerts, grafanaSnapshot and adguardQueryLog return a clear error instead of cut JSON when the output cap is hit. Verified with new handler tests (369 passing).

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 wantedmcp-serverperformanceseverity: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions