Skip to content

Add validation tests for MCP tool schemas and error messages - #7967

Merged
pelikhan merged 3 commits into
mainfrom
copilot/add-validation-tests-mcp-schemas
Dec 28, 2025
Merged

pelikhan merged 3 commits into
mainfrom
copilot/add-validation-tests-mcp-schemas

Conversation

Copilot AI commented Dec 28, 2025 •

Copy link
Copy Markdown
Contributor

Summary: Add validation tests for MCP tool schemas and error messages ✅

This PR adds comprehensive tests for MCP tool schema validation and error message generation to prevent regressions and ensure consistent behavior across all safe output MCP tools.

Changes

New Test Files

  1. safe_outputs_mcp_schema_validation.test.cjs (13 tests)

    • Schema completeness validation
    • Required and optional parameter descriptions
    • Tool description quality checks
    • Schema consistency enforcement
    • Enum value conventions
  2. safe_outputs_mcp_error_messages.test.cjs (12 tests)

    • validateRequiredFields function behavior
    • Error message format validation
    • Consistency across tools
    • Real tool error quality checks
    • Enhancement opportunities documentation

Formatting & Linting

  • ✅ All files formatted with prettier
  • ✅ All linting checks pass
  • ✅ Code follows repository style guidelines

Test Coverage

✅ 25 tests pass successfully

  • All 22+ safe output MCP tools covered
  • Schema validation prevents documentation regressions
  • Error message validation ensures user-friendly errors

What These Tests Prevent

  1. Schema Regressions: Missing or incomplete parameter descriptions
  2. Inconsistent Error Messages: Different error formats across tools
  3. Poor Documentation: Insufficient examples or unclear descriptions
  4. Schema Inconsistencies: Type mismatches, naming violations, loose validation

Running the Tests

# From repository root
make test

# JavaScript tests only
cd actions/setup/js && npm run test:js

# Specific test files
npm run test:js -- safe_outputs_mcp_schema_validation.test.cjs safe_outputs_mcp_error_messages.test.cjs

Example Test Output

✓ safe_outputs_mcp_schema_validation.test.cjs (13 tests) 14ms
✓ safe_outputs_mcp_error_messages.test.cjs (12 tests) 50ms

Test Files  2 passed (2)
Tests  25 passed (25)

Validation Examples

Schema Quality Checks

  • ✅ Required parameters have detailed descriptions (≥50 chars)
  • ✅ Descriptions include examples or format guidance
  • ✅ Tool names use snake_case
  • ✅ Schemas enforce strict validation with additionalProperties: false

Error Message Checks

  • ✅ Missing parameter errors: "Invalid arguments: missing or empty 'title', 'body'"
  • ✅ Consistent format across all tools
  • ✅ Parameter names always quoted for clarity

Future Enhancement Opportunities

Tests document potential improvements:

  • Including schema examples in error messages
  • Providing format hints based on parameter types
  • Suggesting correct enum values in errors

Related to #7950

Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Add validation tests for MCP tool schemas and error messages</issue_title>
<issue_description>## Objective

Create comprehensive tests for MCP tool schema validation and error message generation to prevent regressions and ensure consistent behavior.

Context

After enhancing MCP schemas and error messages, we need tests to verify:

  1. Schema documentation is complete for all required parameters
  2. Error messages follow the enhanced format with examples
  3. Future schema changes don't break validation

Approach

  1. Create test file(s) for MCP schema validation
  2. Add tests that verify:
    • All required parameters have descriptions
    • Descriptions include examples
    • Error messages include parameter name, description, and example
    • Error format is consistent across tools
  3. Use existing test patterns from the codebase (e.g., *_test.go files)

Files to Create/Modify

  • Create test file for MCP schema validation (follow existing patterns)
  • Look at existing tests in actions/setup/js/*.test.cjs for JavaScript testing patterns
  • May need to add Go tests if MCP schema validation happens at compile time

Test Cases to Cover

  1. Schema Completeness:

    • All required parameters have non-empty descriptions
    • Descriptions include examples or format guidance
    • Tool schemas include usage examples
  2. Error Message Format:

    • Missing parameter errors include parameter name
    • Errors include expected format
    • Errors include example correct usage
  3. Regression Prevention:

    • Test that schemas can be parsed correctly
    • Test that error message generation doesn't break

Acceptance Criteria

  • Tests verify all required parameters have detailed descriptions
  • Tests verify error messages follow enhanced format
  • Tests pass with make test
  • Test coverage includes all safe output MCP tools

Testing

After creating tests:

make test            # Run all tests including new validation tests
make test-unit       # Run just unit tests for faster feedback

Related to #7950

AI generated by Plan Command for discussion #7934

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Create safe_outputs_mcp_schema_validation.test.cjs for schema validation
  - Test all required parameters have descriptions with examples
  - Test optional parameters have descriptions
  - Test tool descriptions are detailed with use cases
  - Test schema consistency (types, snake_case, additionalProperties)
  - Test enum values follow conventions

- Create safe_outputs_mcp_error_messages.test.cjs for error message validation
  - Test validateRequiredFields function behavior
  - Test error messages include parameter names
  - Test error format consistency across tools
  - Document current error message format for future enhancement

- All 25 tests pass successfully
- Tests cover all safe output MCP tools
- Tests prevent regressions in schema quality and error messages

Related to #7950

Co-authored-by: mnkiefer <[email protected]>
Copilot AI changed the title [WIP] Add validation tests for MCP tool schemas and error messages Add validation tests for MCP tool schemas and error messages Dec 28, 2025
Copilot AI requested a review from mnkiefer December 28, 2025 07:17
@pelikhan
pelikhan marked this pull request as ready for review December 28, 2025 15:57
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot format and lint

- Format .cjs test files with prettier
- Format devcontainer.json
- Update package-lock.json
- All 25 tests still pass

Co-authored-by: pelikhan <[email protected]>

Copilot AI commented Dec 28, 2025

Copy link
Copy Markdown
Contributor Author

@copilot format and lint

Formatting and linting complete. All code formatted with prettier and linting checks pass. Changes committed in 43d409d.

Copilot AI requested a review from pelikhan December 28, 2025 16:09
@pelikhan
pelikhan merged commit 896978d into main Dec 28, 2025
@pelikhan
pelikhan deleted the copilot/add-validation-tests-mcp-schemas branch December 28, 2025 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plan] Add validation tests for MCP tool schemas and error messages

3 participants