An agent sends tool arguments as JSON, and a missing field or wrong type can make the tool fail or act on bad data. Validating the arguments before the call runs catches those errors while they are still cheap. Check the JSON parses, then check each required field against the schema.
Checked on 2026-11-29. We did not run any tool for this guide. Every result below is an expected result, marked UNTESTED, for you to confirm on your own files.
Prerequisites
- The tool schema with required fields and types
- The agent log showing the arguments it sent
- A JSON validator or a small script
Steps
1. Parse the arguments as JSON
Take the arguments string from the log and parse it. If it fails to parse, the call is rejected.
Expected result: The arguments parse as JSON, or the call is rejected with the error named.
2. Check required fields exist
Compare the parsed object with the schema and list any required field that is missing.
Expected result: Missing fields are listed, or none are missing.
3. Check the field types
Check each value matches its type, for example a number is a number and not a string.
Expected result: Each field is marked with the right type, or the wrong ones are listed.
4. Run only a valid call
Run the tool only when the arguments are valid. Log the invalid ones so you can fix the prompt or schema.
Expected result: Valid calls run and invalid calls are logged, not run.
Worked example
A practice refund call sent three fields. One was the wrong type and the call was stopped.
| Field | Expected type | Sent value |
|---|---|---|
| order_id | string | ORD-1042 |
| amount | number | 25.50 |
| reason | string | missing |
Expected result: Two fields validate and reason is missing, so the call is stopped and the agent is asked again (UNTESTED – confirm it yourself.)
Verdict table
| Check | Expected result | Pass? |
|---|---|---|
| Parse the arguments as JSON | The arguments parse as JSON, or the call is rejected with the error named. | – |
| Check required fields exist | Missing fields are listed, or none are missing. | – |
| Check the field types | Each field is marked with the right type, or the wrong ones are listed. | – |
| Run only a valid call | Valid calls run and invalid calls are logged, not run. | – |
Limits
- Valid JSON does not mean the values are correct; check amounts and IDs against the source too.
- Some agents send arguments as text with extra words; strip those before parsing.
Sources
- Model Context Protocol (Stanford CS329T slides) – checked 2026-11-29
- The Model Context Protocol (MCP) for compliance data – checked 2026-11-29
- What is the Model Context Protocol (MCP)? – checked 2026-11-29
- Ollama v0.9.1 release notes – checked 2026-11-29
