Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 7, 2025

This PR implements support for complex data types in McpToolProperty, enabling developers to define array, object, number, and boolean parameters instead of being limited to string types only.

What's Changed

New Property Type Constants
Added comprehensive type constants in ToolsInformation.cs:

  • ArrayPropertyType - for arrays and lists
  • ObjectPropertyType - for complex objects
  • NumberPropertyType - for numeric data
  • BooleanPropertyType - for true/false values
  • StringPropertyType - for text data (replacing generic PropertyType)

Snippets-Focused Examples
Enhanced SnippetsTool.cs with practical examples demonstrating complex type usage:

[Function(nameof(BulkSaveSnippets))]
public string BulkSaveSnippets(
    [McpToolTrigger("bulk_save_snippets", "Save multiple code snippets at once")] ToolInvocationContext context,
    [McpToolProperty("snippets", ArrayPropertyType, "Array of snippet objects containing name, content, description, and tags")]
        List<SnippetInfo> snippets,
    [McpToolProperty("overwrite-existing", BooleanPropertyType, "Whether to overwrite existing snippets with same names")]
        bool overwriteExisting = false
)

[Function(nameof(SearchSnippets))]
public string SearchSnippets(
    [McpToolTrigger("search_snippets", "Search for snippets using various criteria")] ToolInvocationContext context,
    [McpToolProperty("search-criteria", ObjectPropertyType, "Search criteria object with tags, name pattern, and content inclusion options")]
        SnippetSearchCriteria searchCriteria
)

Enhanced Documentation
Updated README.md with comprehensive examples showing:

  • How to use each property type with snippet-related functionality
  • Complete working examples aligned with the repository's snippet management theme
  • Best practices for parameter definitions

Backward Compatibility
All existing code continues to work unchanged. The original PropertyType constant is preserved, and existing tools using string parameters require no modifications.

This change directly addresses the original issue request for defining complex types like arrays and objects while maintaining focus on the repository's core snippet management functionality.

Fixes #28.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] How to define a complex type in McpToolProperty Add support for complex types in McpToolProperty Aug 7, 2025
@paulyuk
Copy link
Contributor

paulyuk commented Aug 7, 2025

@copilot Please recommend the smallest change that also shows a working property similar to what @jonas-tian mentions. The theme of this sample is working with snippets, so suggest one more new tool/function that works with a more complex type like a snippets array (perhaps a function that lists all snippets?). Please do not add any examples that are off topic or not aligning with theme, like order-items.

@paulyuk
Copy link
Contributor

paulyuk commented Aug 7, 2025

@copilot - Ignore the idea around Order tools and order-items. Please restart this PR and only use this instruction:

Please recommend the smallest change that also shows a working property similar to what @jonas-tian mentions but sticking to the Snippets tool and theme. The theme of this sample is working with snippets, so suggest one more new tool/function that works with a more complex type like a snippets array (perhaps a function that lists all snippets?). Please do not add any examples that are off topic or not aligning with theme, like order-items.

Copy link
Contributor Author

Copilot AI commented Aug 7, 2025

@copilot Please recommend the smallest change that also shows a working property similar to what @jonas-tian mentions. The theme of this sample is working with snippets, so suggest one more new tool/f...

I've implemented the requested changes. Removed the off-topic OrderTool and added two snippets-focused functions that demonstrate complex types:

  1. BulkSaveSnippets - takes an array of snippet objects (List<SnippetInfo>) and a boolean flag
  2. SearchSnippets - takes a complex search criteria object (SnippetSearchCriteria)

Both stay completely on theme with the snippets concept while showing practical usage of array, object, and boolean property types. The examples are much more minimal and aligned with the existing codebase theme.

Commit: Replace OrderTool with snippets-focused complex type examples

Copilot AI changed the title Add support for complex types in McpToolProperty Add support for complex types in McpToolProperty with snippets examples Aug 7, 2025
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.

How to define a complex type in McpToolProperty

2 participants