-
Notifications
You must be signed in to change notification settings - Fork 437
Add docs with more details on testing tools and update behavior for optional values #356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
olaservo
wants to merge
12
commits into
modelcontextprotocol:main
Choose a base branch
from
olaservo:add-tools-doc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+191
−20
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ce3b5ad
Add tools testing doc
olaservo 18d0bf3
Add auto generated sections to edit
olaservo 37b92f4
Remove a few things
olaservo 9c5f786
Simplify form
olaservo c24e6f9
Reorg doc
olaservo 69da207
Fill out TODO
olaservo 87396c8
Merge branch 'main' into add-tools-doc
olaservo 3b44a3b
Omit any optional fields if not set
olaservo 78ebf2e
Fox formatting
olaservo a89b7b2
Merge remote-tracking branch 'upstream/main' into add-tools-doc
olaservo 971d943
Restore other tests
olaservo b194319
Fix: Apply prettier formatting
olaservo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Tool Testing Guide | ||
|
||
This guide explains how different types of tool inputs are expected be handled in the MCP Inspector. (Note that this guide currently only covers testing using the UI and not CLI mode.) | ||
|
||
The Tools UI provides both structured form and raw JSON editor modes. For supported types, the UI allows switching between modes while preserving values, with some exceptions for [complex objects](#complex-objects). Input types are validated in both modes. | ||
|
||
## Input Type Handling | ||
|
||
### Basic Types | ||
|
||
| Type | Example Schema | Expected Input | Form Behavior | | ||
| --------- | ----------------------- | -------------- | ------------------------ | | ||
| `integer` | `{ "type": "integer" }` | `42` | Number input with step=1 | | ||
| `number` | `{ "type": "number" }` | `42.5` | Number input | | ||
| `string` | `{ "type": "string" }` | `"hello"` | Text input | | ||
| `boolean` | `{ "type": "boolean" }` | `true`/`false` | Checkbox | | ||
| `null` | `{ "type": "null" }` | `null` | N/A | | ||
|
||
### Type Conversion Rules | ||
|
||
| Input Type | Target Type | Conversion Behavior | Example | | ||
| ---------------- | ----------- | -------------------------- | ------------------------ | | ||
| String → Integer | `integer` | Reject if not whole number | "42" → 42, "1.5" → error | | ||
| Number → Integer | `integer` | Reject if not whole number | 42 → 42, 1.5 → error | | ||
| String → Number | `number` | Convert if valid number | "42.5" → 42.5 | | ||
| String → Boolean | `boolean` | Only accept "true"/"false" | "true" → true | | ||
|
||
## Complex Objects | ||
|
||
Complex objects include nested structures (objects within objects) and arrays. Their handling differs between form and JSON modes based on complexity. | ||
|
||
### Array Handling | ||
|
||
| Type | Example Schema | Expected Input | Form Behavior | | ||
| -------------- | --------------------------------------------------- | ---------------------------------------- | ------------------------------------------ | | ||
| Simple Array | `{ "type": "array", "items": { "type": "string" }}` | `["item1", "item2"]` | Dynamic list with add/remove buttons | | ||
| Object Array | `{ "type": "array", "items": { "type": "object" }}` | `[{"name": "item1"}, {"name": "item2"}]` | Dynamic form rows with nested fields | | ||
| Optional Array | `{ "type": ["array", "null"] }` | `[]` or omitted | Empty array or field omitted, never `null` | | ||
|
||
### Nested Objects | ||
|
||
| Structure | Example Schema | Form Mode | JSON Mode | | ||
| ------------ | ---------------------------------------------------------------- | --------------- | --------- | | ||
| Single Level | `{"type": "object", "properties": {"name": {"type": "string"}}}` | Structured form | Available | | ||
| Multi Level | `{"type": "object", "properties": {"user": {"type": "object"}}}` | JSON only | Available | | ||
| Mixed Types | `{"type": "object", "properties": {"data": {"oneOf": [...]}}}` | JSON only | Available | | ||
|
||
### Optional Fields in Complex Types | ||
|
||
| Scenario | Example | Expected Behavior | | ||
| ------------------------- | ------------------------------ | --------------------------------- | | ||
| Optional field (any type) | `{"required": false}` | Omit field entirely from request | | ||
| Nullable field | `{"type": ["string", "null"]}` | May explicitly set to `null` | | ||
| Empty array (when set) | `{"type": "array"}` | Send `[]` if explicitly set empty | | ||
| Empty object (when set) | `{"type": "object"}` | Send `{}` if explicitly set empty | | ||
|
||
## Testing Scenarios and Expected Results for Complex Objects | ||
|
||
| Test Case | Description | Expected Behavior | | ||
| -------------------------- | ------------------------------------------- | -------------------------------------------------------- | | ||
| Complex nested form fields | Tool with multiple levels of nested objects | Only JSON mode is available | | ||
| Array field manipulation | Add/remove items in array | Form mode allows for items to be added and removed | | ||
| Optional nested fields | Object with optional nested properties | Field omitted entirely when not set | | ||
| Mixed type arrays | Array accepting multiple types | Only JSON mode is available | | ||
| Nullable vs Optional | Field allowing null vs optional field | Null explicitly set vs field omitted | | ||
| Empty collections | Empty arrays or objects | Send `[]` or `{}` only if explicitly set, otherwise omit | | ||
|
||
## Optional Parameters | ||
|
||
**When an optional parameter is not set by the user:** | ||
|
||
- The parameter will be completely omitted from the request | ||
- Example: If `name` is optional and unset: `{}` will be sent in the request. | ||
|
||
**When an optional parameter explicitly accepts null:** | ||
|
||
- Schema must declare null as valid: `{ "type": ["string", "null"] }` | ||
- Only then will null be sent: `{ "name": null }` | ||
|
||
**When an optional string is set to empty:** | ||
|
||
- Empty string will be sent, eg: `{ "name": "" }` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to the above changes - want some feedback on if this should be the expected behavior for optional objects and arrays.