Skip to content

Support default values in input schema and skip optional properties without defaults#64

Merged
MaestroError merged 5 commits intomainfrom
copilot/support-default-field-parsing
Nov 11, 2025
Merged

Support default values in input schema and skip optional properties without defaults#64
MaestroError merged 5 commits intomainfrom
copilot/support-default-field-parsing

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 11, 2025

Tool property parsing ignored the default field in input schemas and attempted to resolve all schema-defined properties in templates, causing errors when optional properties without defaults were omitted.

Changes

Property Resolution Logic

  • Added _resolve_properties_with_defaults() method that builds execution context with:
    • Provided property values (highest priority)
    • Default values from schema for unprovided optional properties
    • Omits optional properties without defaults (prevents template substitution errors)

Execution Flow

  • Updated execute() to use resolved properties instead of raw input
  • Maintains backward compatibility: tools without schemas or with empty schemas use properties as-is

Example

{
  "inputSchema": {
    "properties": {
      "query": { "type": "string" },
      "case_sensitive": { "type": "boolean", "default": false },
      "max_results": { "type": "number", "default": 100 },
      "filter": { "type": "string" }
    },
    "required": ["query"]
  }
}
# Before: would fail trying to resolve {{props.filter}}
client.execute("search", properties={"query": "test"})

# After: uses defaults for case_sensitive/max_results, omits filter
client.execute("search", properties={"query": "test"})
# Context: {case_sensitive: false, max_results: 100, query: "test"}

Tests

  • 11 unit tests for property resolution logic
  • 10 integration tests for real-world scenarios and backward compatibility

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.example.com
    • Triggering command: /home/REDACTED/work/mci-py/mci-py/.venv/bin/python /home/REDACTED/work/mci-py/mci-py/.venv/bin/pytest (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Support 'default' field in tool property parsing and conditional property resolution</issue_title>
<issue_description>### Problem
Currently, tool property parsing in MCI adapter does not support the default field in tool schemas. When a property (such as "include_images") is defined with a default value but not provided at execution time, the adapter ignores the default and attempts to resolve props.VAR_NAME, which can result in missing or erroneous property values. Additionally, properties that are neither in the required array nor have a default value are still attempted to be resolved, causing unnecessary template substitutions or errors.

Example:

"include_images": {
    "type": "boolean",
    "default": false
}

Feature Requirements

  • Default Value Support: When executing a tool, for each property in the input schema, if the property is missing from provided properties, and the input schema defines a default field, use this default value during execution.
  • Optional Property Skipping: For each property not listed in required and without a default, simply skip. Do not attempt to resolve props.VAR_NAME for missing optional properties unless explicitly present in input.
  • The adapter should avoid any form of template substitution or error for properties that are neither required nor have a default value if they're not provided.

Acceptance Criteria

  • Given an input schema property with a default, when omitted from execution properties, the default is used in templating/execution context.
  • If a property is not required and has no default, then it is ignored/skipped (including in template substitution for execution configs, body, etc.).
  • Regression tests/checks pass for property resolution logic before and after this change.

Implementation Suggestions

  • Update property resolution logic in the adapter (likely in the context-building or execution step).
  • Add/extend unit tests in input schema parsing and execution flows.
  • Update documentation to describe how default and optional property skipping works.

References


  • Label: enhancement
  • Type: Feature</issue_description>

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits November 11, 2025 00:49
Co-authored-by: MaestroError <46760939+MaestroError@users.noreply.github.com>
Co-authored-by: MaestroError <46760939+MaestroError@users.noreply.github.com>
Co-authored-by: MaestroError <46760939+MaestroError@users.noreply.github.com>
Co-authored-by: MaestroError <46760939+MaestroError@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for default field in tool property parsing Support default values in input schema and skip optional properties without defaults Nov 11, 2025
Copilot AI requested a review from MaestroError November 11, 2025 01:00
@MaestroError MaestroError requested a review from Copilot November 11, 2025 15:00
Copy link
Copy Markdown
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 support for default values in tool input schemas and implements conditional property resolution to prevent template substitution errors when optional properties are omitted. The implementation allows tools to define default values for properties that will be used when not provided at execution time, while skipping optional properties without defaults entirely.

Key Changes:

  • Added _resolve_properties_with_defaults() method to handle property resolution with defaults
  • Updated execute() to use resolved properties instead of raw input
  • Modified template context building to use resolved properties for both props and input keys

Reviewed Changes

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

Show a summary per file
File Description
src/mcipy/tool_manager.py Core logic: Added property resolution method and integrated it into execution flow
tests/unit/test_tool_manager.py Unit tests for property resolution with various edge cases and backward compatibility
tests/test_default_values_integration.py Integration tests demonstrating real-world usage scenarios
testsManual/test_default_values.py Manual test showcasing the feature in action with human-readable output
docs/schema_reference.md Documentation explaining default values behavior with examples
src/mcipy/mcp_integration.py Code formatting fix (import statement split)

@MaestroError MaestroError marked this pull request as ready for review November 11, 2025 15:13
@MaestroError MaestroError merged commit 3ee5830 into main Nov 11, 2025
12 checks passed
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.

Support 'default' field in tool property parsing and conditional property resolution

3 participants