Skip to content

Migrate MCP relationship prose to JSON Schema constraints with $comment documentation#7598

Merged
pelikhan merged 3 commits intomainfrom
copilot/refactor-relationship-prose
Dec 25, 2025
Merged

Migrate MCP relationship prose to JSON Schema constraints with $comment documentation#7598
pelikhan merged 3 commits intomainfrom
copilot/refactor-relationship-prose

Conversation

Copy link
Contributor

Copilot AI commented Dec 25, 2025

Field relationship requirements were documented only in prose within description fields, preventing schema validators from automatically enforcing constraints. This migrates key MCP relationships to JSON Schema's standard constraint keywords while documenting complex validation logic.

Changes

Schema Constraints Added

  • MCP Gateway (sandbox.mcp): Enforces mutual exclusion between command and container using anyOf + not.allOf
  • MCP Gateway (sandbox.mcp): Conditional requirement that entrypointArgs requires container using if/then
  • stdio_mcp_tool: Added comprehensive $comment documenting existing constraint patterns

Documentation via $comment

Added 10 $comment fields explaining:

  • Why strict mode + write permissions → safe-outputs dependency remains in Go validation (too complex for schema)
  • Network field requirements in strict mode
  • All MCP mutual exclusion and conditional requirements
  • Validation location references (pkg/workflow/strict_mode_validation.go)

Test Alignment

  • Fixed TestSandboxConfigWithMCPGateway to include required container field per schema examples

Example

Before (prose only):

{
  "command": {
    "type": "string",
    "description": "Custom command (mutually exclusive with 'container')"
  }
}

After (enforced + documented):

{
  "command": {
    "type": "string",
    "$comment": "Mutually exclusive with 'container' - only one execution mode can be specified.",
    "description": "Custom command to execute the MCP gateway"
  },
  "anyOf": [{"required": ["command"]}, {"required": ["container"]}],
  "not": {"allOf": [{"required": ["command"]}, {"required": ["container"]}]}
}

Schema validators now automatically catch relationship violations. Binary rebuilt with make build to embed updated schema.

Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Refactor relationship prose to use dependencies keyword</issue_title>
<issue_description>## Objective

Migrate field relationship descriptions from prose in description fields to JSON Schema's standard dependencies and dependentRequired keywords.

Context

Currently, all field relationships are described only in prose within description fields. This means schema validators can't automatically check relationships, and users relying on schema-driven tooling don't get validation errors for relationship violations.

Relationships to Migrate

Audit the schema for relationship prose in description fields and convert to JSON Schema standard keywords:

  1. dependencies - When field X requires field Y
  2. dependentRequired - When field X requires fields Y and Z
  3. dependentSchemas - When field X changes schema requirements

Example Migration

Before:

{
  "safe-outputs": {
    "description": "Configure safe outputs. Note: write permissions in strict mode require safe-outputs to be configured."
  }
}

After:

{
  "description": "Configure safe outputs.",
  "if": {
    "properties": { "strict": { "const": true } }
  },
  "then": {
    "if": {
      "properties": {
        "permissions": {
          "patternProperties": {
            ".*": { "enum": ["write"] }
          }
        }
      }
    },
    "then": {
      "required": ["safe-outputs"]
    }
  }
}

Approach

  1. Audit all description fields for relationship prose
  2. Create mapping of relationships to JSON Schema keywords
  3. Implement using dependencies, dependentRequired, or dependentSchemas
  4. Update description fields to remove redundant prose
  5. Add $comment for complex relationships needing explanation

Files to Modify

  • pkg/parser/schemas/frontmatter.json - Refactor all relationship prose
  • After changes, run make build to rebuild with embedded schema

Acceptance Criteria

  • All field relationships use JSON Schema standard keywords
  • No relationship information only in prose descriptions
  • Complex relationships have $comment explanations
  • Schema validators catch relationship violations
  • Existing valid configurations still pass validation
  • Documentation updated to reference relationship keywords

Testing

Test with JSON Schema validators that support dependencies to verify automatic relationship checking.
Related to #7575

AI generated by Plan Command for discussion #7569

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


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 25, 2025 07:03
Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
- Add mutual exclusion constraints for MCP gateway command/container
- Add if/then for entrypointArgs requiring container
- Add $comment fields explaining relationship validation
- Document strict mode dependencies (validated in Go code)
- Update TestSandboxConfigWithMCPGateway to include required container
- Rebuild binary with updated embedded schema

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor relationship prose to use dependencies keyword Migrate MCP relationship prose to JSON Schema constraints with $comment documentation Dec 25, 2025
Copilot AI requested a review from mnkiefer December 25, 2025 07:27
@pelikhan pelikhan marked this pull request as ready for review December 25, 2025 10:43
@pelikhan pelikhan merged commit 5a344f7 into main Dec 25, 2025
162 of 163 checks passed
@pelikhan pelikhan deleted the copilot/refactor-relationship-prose branch December 25, 2025 10:48
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] Refactor relationship prose to use dependencies keyword

3 participants