fix(web): read the literal, not the parsed number; project cursors and tool args

Copilot's eighth pass, three comments, all real.

- The precision check now reads the **source text**. Inferring the literal from
  `String(value)` was wrong in both directions: it accepted every full-form
  integer at or above 1e21 (`1000000000000000000001` parses to `1e21` and is
  written back as `1e+21`), and refused `2^54`, which is written out in full
  and exactly representable. `hasImpreciseIntegerLiteral` scans the draft for
  numeric tokens — skipping strings, so a digit-string value is untouched — and
  compares `BigInt(literal)` against `BigInt(Number(literal))`, which is exact.

- `""` is now reported as a surviving cursor for `tools/list` only. It builds
  its params with `cursor !== undefined` and carries the empty string
  deliberately; the other four list adapters use a truthiness check and drop
  it, so the editor showed `{"cursor":""}` while `{}` went out. The asymmetry
  looks like a latent bug in those four, but this function's job is to describe
  what the dispatch does.

- `callTool` runs every string-valued argument through `convertToolParameters`,
  so `{"count":"2"}` against a numeric schema is sent as `{"count":2}`.
  `reshapedReplayParam` now takes the tool and detects that by running the same
  conversion and comparing, rather than restating its rules — the two cannot
  drift. `tools` is threaded to `ProtocolEntry` for it, optional throughout: an
  unknown tool skips the check rather than blocking a replay.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UL9retfvAXRgvi6EWk4SY4
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
cliffhall 2026-08-27 04:56:22 -04:00
commit fcdc65b289

View file

@ -12,6 +12,7 @@ import {
Text,
} from "@mantine/core";
import { RiErrorWarningLine } from "react-icons/ri";
import type { Tool } from "@modelcontextprotocol/client";
import type { MessageEntry } from "@inspector/core/mcp/types.js";
import { ContentViewer } from "../../elements/ContentViewer/ContentViewer";
import { CopyButton } from "../../elements/CopyButton/CopyButton";
@ -70,6 +71,13 @@ export interface ProtocolEntryProps {
* correlated HTTP record.
*/
correlatedHttpStatus?: number;
/**
* The connected server's tools, used only to tell whether an edited
* `tools/call` argument would be coerced by the schema on the way out
* (#2151). Optional: without it that one check is skipped, which is the right
* answer when the tool list is not known rather than a reason to block.
*/
tools?: Tool[];
}
const EntryContainer = Card.withProps({
@ -327,6 +335,7 @@ export function ProtocolEntry({
embedded = false,
onRevealInNetwork,
correlatedHttpStatus,
tools,
}: ProtocolEntryProps) {
const [isExpanded, setIsExpanded] = useState(isListExpanded);
const [isEditingReplay, setIsEditingReplay] = useState(false);
@ -337,6 +346,12 @@ export function ProtocolEntry({
const requestParams = extractParams(entry);
const canReplay = isReplayableProtocolMethod(method);
const editableParams = replayableParams(method, requestParams);
// The tool this entry called, when it called one — the schema an edited
// argument would be coerced against.
const replayedTool =
method === "tools/call" && typeof requestParams?.name === "string"
? tools?.find((candidate) => candidate.name === requestParams.name)
: undefined;
const resultType = extractResultType(entry);
const subscriptionId = extractSubscriptionId(entry);
@ -488,6 +503,7 @@ export function ProtocolEntry({
// the editor must not offer a field that Send would drop.
params={editableParams.params}
droppedParamKeys={editableParams.dropped}
tool={replayedTool}
onSend={onReplay}
onClose={() => setIsEditingReplay(false)}
/>