Skip to content

Same JSON-body pretty-print logic is duplicated verbatim in four places #2413

Description

@CloneOfAlex

Which version line?

v2 — current (@modelcontextprotocol/inspector@latest)

Which client?

TUI

Inspector version

2.7.0 (git tag) — static code-review finding, not run locally

Node version

N/A — static code review, no live run performed

Operating system (and browser, for the web client)

N/A — static code review

Transport

Not applicable / never connected

MCP server under inspection

N/A — this is a static code-review finding against the 2.7.0 tag source (clients/tui/src/App.tsx, clients/tui/src/components/RequestsTab.tsx), not a live reproduction against a running MCP server.

Steps to reproduce

Found via static review of the 2.7.0 tag source, not a live run.

  1. The JSON body pretty-print logic (splitting a stringified tool-call result into lines for Ink rendering) appears verbatim in four places: App.tsx (x2) and RequestsTab.tsx (x2).
  2. Beyond the size-cap gap tracked separately (TUI request/response body rendering has no size cap — risk of terminal hang on large payloads #2407), any future fix (syntax highlighting, a max-line count, wrap behavior) has to be applied by hand in all four places, and it is easy to miss one.

I have not modified one copy to watch the others diverge live; flagging the duplication itself as the maintenance risk, and as a likely source of a future "why does this tab render bodies differently" report.

Expected behavior

The JSON body pretty-print logic lives in one shared helper that all four call sites use, so a future fix (size cap, syntax highlighting, wrap behavior) is applied once.

Actual behavior

The same pretty-print logic is copy-pasted across App.tsx (x2) and RequestsTab.tsx (x2).

Suggested fix: extract a shared formatting helper used by all four sites, ideally alongside the related size-cap fix (#2407).

Logs, errors, or screenshots

No response

Already prototyped a fix?

No response

Before you submit

  • I searched existing issues and this is not a duplicate.
  • This is not a security vulnerability report (those go through the private advisory process).

Activity

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

Metadata

Metadata

Assignees

Labels

choreMaintenance: deps, build tooling, CI, cleanup — no user-facing behavior changev2Issues and PRs for v2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions