Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

Add test that validates tools.json against MCP tools JSON schema

  • Explore repository structure and understand tools.json format
  • Understand MCP tool schema from @modelcontextprotocol/sdk
  • Create MCP tools JSON schema file
  • Create test that validates tools.json against the schema
  • Run tests and verify validation works
  • All tests pass successfully
  • Remove duplicate schema file per feedback
  • Add error handling for debug JSON unmarshal
  • Clarify title field descriptions in schema
  • Pass lint checks

Changes Made

Created MCP Tools JSON Schema:

  • Created pkg/workflow/schemas/mcp-tools.json (removed duplicate from root schemas/)
  • Schema defines the structure for MCP tool arrays based on the Model Context Protocol specification
  • Includes required fields: name, inputSchema
  • Includes optional fields: title, description, outputSchema, annotations
  • Clarified that title can appear both at tool level and in annotations with different purposes

Created Comprehensive Tests:

  • TestSafeOutputsToolsJSONCompliesWithMCPSchema: Validates the entire tools.json file against the MCP schema using jsonschema validator
  • TestEachToolHasRequiredMCPFields: Validates each tool has the required MCP fields (name, inputSchema with proper structure)
  • TestToolsJSONStructureMatchesMCPSpecification: Validates that tools don't have unexpected fields and follow MCP specification
  • Added proper error handling for debug JSON unmarshal operation

All Tests Pass:

  • Unit tests: ✓
  • Schema validation tests: ✓
  • Lint checks: ✓
  • All 12 tools validated successfully
Original prompt

Add a test that validates that the tools.json file complies with the MCP tools JSON schema.


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

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test for tools.json schema validation Add MCP tools JSON schema validation test Nov 18, 2025
Copilot finished work on behalf of pelikhan November 18, 2025 13:36
Copilot AI requested a review from pelikhan November 18, 2025 13:36
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review November 18, 2025 13:50
Copilot AI review requested due to automatic review settings November 18, 2025 13:50
Copilot AI requested a review from pelikhan November 18, 2025 13:50
Copilot finished work on behalf of pelikhan November 18, 2025 13:50
Copilot finished reviewing on behalf of pelikhan November 18, 2025 13:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive schema validation for the tools.json file against the Model Context Protocol (MCP) specification. The changes ensure that the safe outputs tools conform to the MCP standard through automated testing.

Key Changes

  • Created an MCP tools JSON schema file defining the structure for MCP tool arrays with required and optional fields
  • Added three comprehensive test functions that validate tools.json against the MCP schema using different validation approaches
  • All tests validate the structure and compliance of 12 safe output tools

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/workflow/schemas/mcp-tools.json New JSON schema file defining MCP tools specification with required fields (name, inputSchema) and optional fields (title, description, outputSchema, annotations)
pkg/workflow/safe_outputs_tools_schema_test.go New test file with three test functions validating tools.json against MCP schema using jsonschema validator and manual field validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 101 to 104
"title": {
"type": "string",
"description": "A human-readable title for the tool"
},
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title field appears in both the Tool definition (line 19-22) and the ToolAnnotations definition (lines 101-104) with slightly different descriptions. This duplication is confusing. According to MCP specification, title should only be at the tool level (for UI display) or within annotations. Consider removing the duplicate or clarifying in the description that these are distinct fields for different purposes.

Suggested change
"title": {
"type": "string",
"description": "A human-readable title for the tool"
},

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified the descriptions in b6a4c74. Both title fields are valid per the MCP spec: the tool-level title is for UI display, while the annotations title is a hint. Updated descriptions to distinguish between them.

@pelikhan
Copy link
Contributor

@copilot lint

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 18, 2025

@copilot lint

Lint passed successfully in b6a4c74.

Copilot finished work on behalf of pelikhan November 18, 2025 15:13
@pelikhan pelikhan merged commit f5fda2a into main Nov 18, 2025
12 of 13 checks passed
@pelikhan pelikhan deleted the copilot/add-tools-json-schema-test branch November 18, 2025 16:12
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.

2 participants