Add input validation guidelines and enhance cleanParams function to preserve default values

This commit is contained in:
olaservo 2025-10-08 08:43:11 -07:00
commit 0123a71da4

View file

@ -31,3 +31,14 @@ The project is organized as a monorepo with workspaces:
- `client/`: React frontend with Vite, TypeScript and Tailwind
- `server/`: Express backend with TypeScript
- `cli/`: Command-line interface for testing and invoking MCP server methods directly
## Tool Input Validation Guidelines
When handling tool input parameters and form fields:
- **Optional fields with empty values should be omitted entirely** - Do not send empty strings or null values for optional parameters, UNLESS the field has an explicit default value in the schema that matches the current value
- **Fields with explicit defaults should preserve their default values** - If a field has an explicit default in its schema (e.g., `default: null`), and the current value matches that default, include it in the request. This is a meaningful value the tool expects
- **Required fields should preserve their values even when empty** - This allows the server to properly validate and return appropriate error messages
- **Deeper validation should be handled by the server** - Inspector should focus on basic field presence, while the MCP server handles parameter validation according to its schema
These guidelines ensure clean parameter passing and proper separation of concerns between the Inspector client and MCP servers.