CLI: coerce --tool-arg values using the tool's inputSchema (zip=10001 is sent as a number to a string field)

Ouverte
#3,075 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
62/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
typescript
Domaine
cli

Piste de recherche

Start in the CLI's --tool-arg parsing and the tool lookup that already produces tool_not_found and reads inputSchema, since the coercion has to use that schema. The --prompt-args handling after #2859 is the reference for keeping string values verbatim. Done when zip=10001 reaches a string field unchanged, a non-parsing value for a number field gives a usage error naming the key, and --tool-args-json behaves as before.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

enhancement v2
Which client?

CLI

The problem

--tool-arg JSON-parses every value, so zip=10001 is sent as the number 10001. A tool whose inputSchema declares zip as string rejects the call:

mcp-inspector --cli node server.mjs --method tools/call --tool-name echo_typed --tool-arg zip=10001
→ Input validation error: ... zip: Invalid input: expected string, received number   (exit 5)

The behaviour is documented (count=1 becomes a number), but it makes --tool-arg unreliable for ZIP codes, IDs, phone numbers, versions (1.10 → 1.1) and other numeric-looking strings. Users have to know to switch to --tool-args-json and quote everything. Verified on 2.17.0 (main @ 2069a1a).

Solution you have in mind (optional)

The CLI already looks the tool up (tool_not_found, --strict), so it has the inputSchema. Coerce each key=value by the declared type of that property:

  • type: "string" → keep the raw text verbatim (as --prompt-args now does after #2859)
  • number / integer / boolean / object / array → JSON-parse as today, and fail with a usage error naming the key if it doesn't parse to that type
  • no schema for the key, or a union type → current behaviour

The same applies to mcpdo's --tool-arg and key:=value positionals. --tool-args-json stays verbatim. That matches #2171, which kept raw JSON in the web client from being retyped by the schema; this request only covers key=value text.

Alternatives or workarounds you have tried

--tool-args-json '{"zip":"10001"}', or --tool-arg zip='"10001"'. Both work but need shell quoting, which is especially awkward in PowerShell and cmd.

Already built it locally?

No response

Before you submit
  • I searched existing issues and this is not a duplicate.
  • This is a request for the Inspector itself, not for the MCP specification or an SDK.
Langage dominant
TypeScript
Étoiles
11.3k
Forks
1.6k
Merge moyen
2 h 28 min
PR mergées (30 j)
111

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de modelcontextprotocol/inspector

Toutes les issues de modelcontextprotocol/inspector

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.