Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 19, 2025

SEP-973: Icons and metadata support implementation

This PR implements SEP-973 which adds support for icons and additional metadata for Implementations, Resources, Tools, and Prompts.

Implementation Plan

  • Review and understand SEP-973 specification requirements
  • Understand current codebase structure and build system
  • Create Icon class with Source, MimeType, and Sizes properties
  • Add Icons property to Implementation class
  • Add WebsiteUrl property to Implementation class
  • Add Icons property to Resource class
  • Add Icons property to Tool class
  • Add Icons property to Prompt class
  • Create comprehensive tests for Icon validation and serialization
  • Create tests for all updated classes with icon support
  • Fix property accessor consistency across classes
  • Address code review feedback and improve test patterns
  • Simplify XML documentation for Icons properties
  • Rename Icon.Src to Icon.Source for .NET naming conventions
  • Add icon support to server tooling infrastructure (McpServerTool, attributes, and options)
  • Refactor tests to use established patterns

Recent Changes (Addressing Code Review Feedback)

  • Removed documentation files: Removed SEP-973-IMPLEMENTATION.md and SEP-973-EXAMPLES.md as they shouldn't be checked in
  • Enhanced test patterns: Updated all test classes to follow existing patterns with round-trip serialization validation
  • Added JsonException tests: Added tests that verify proper exceptions are thrown for invalid JSON payloads
  • Split test files: Separated combined test classes into individual files (ResourceTests.cs, PromptTests.cs)
  • Renamed test classes: Changed ToolIconTests to ToolTests and made tests less icon-centric
  • Improved test coverage: Tests now focus on overall functionality rather than just icon-specific behavior
  • Simplified documentation: Streamlined XML documentation for Icons properties per code review feedback
  • Improved .NET naming: Renamed Icon.Src property to Icon.Source while maintaining JSON compatibility
  • Added server tooling integration: Extended McpServerTool infrastructure with comprehensive icon support
  • Refactored test patterns: Updated icon tests to use Delegate overload and inline attribute syntax following established codebase patterns

Key Changes Implemented

1. New Icon Class (Icon.cs)

  • Required: Source property for URI pointing to icon resource (serialized as "src" in JSON)
  • Optional: MimeType and Sizes properties
  • Supports HTTP/HTTPS URLs and data URIs
  • Comprehensive security documentation per SEP-973
  • Uses init-only properties for immutability
  • Follows .NET naming conventions with Source property

2. Enhanced Classes with Icon Support

  • Implementation: Added Icons and WebsiteUrl properties
  • Resource: Added Icons property
  • Tool: Added Icons property
  • Prompt: Added Icons property

3. Server-Side Tooling Integration

  • McpServerToolCreateOptions: Added Icons property for programmatic multi-icon configuration
  • McpServerToolAttribute: Added IconSource property for simple attribute-based single-icon configuration
  • AIFunctionMcpServerTool: Enhanced to handle icon properties from both options and attributes with proper precedence
  • Flexible Configuration: Attribute provides basic support; options provide full multi-icon capabilities
  • Precedence Rules: CreateOptions.Icons takes precedence over attribute IconSource for maximum control

4. Specification Compliance

✅ Matches TypeScript schema exactly
✅ Correct JSON property names (icons, websiteUrl, src, mimeType, sizes)
✅ All new properties are optional for backward compatibility
✅ Supports multiple icons per entity
✅ Documents required (PNG, JPEG) and recommended (SVG, WebP) MIME types
✅ Includes security considerations for SVG and URI validation
✅ Uses .NET naming conventions while preserving JSON compatibility

5. Comprehensive Test Coverage

  • IconTests.cs: Icon serialization, round-trip validation, and JsonException tests
  • ImplementationTests.cs: Full Implementation testing with required property validation
  • ToolTests.cs: Tool functionality testing including new icon support
  • ResourceTests.cs: Resource serialization and property validation
  • PromptTests.cs: Prompt functionality testing
  • McpServerToolTests.cs: Server-side icon support using established Delegate patterns and inline attribute syntax
  • All tests follow existing repository patterns with round-trip validation
  • Tests validate JsonException behavior for invalid JSON
  • Tests cover all properties, not just icon-specific functionality
  • Tests updated to use Source property name and consistent patterns

Usage Examples

Simple Attribute-Based Icon Configuration:

McpServerTool.Create([McpServerTool(IconSource = "https://example.com/icon.png")] () => "result");

Advanced Multi-Icon Configuration:

var tool = McpServerTool.Create(() => "result", new McpServerToolCreateOptions
{
    Icons = new List<Icon>
    {
        new() { Source = "https://example.com/icon.png", MimeType = "image/png", Sizes = "48x48" },
        new() { Source = "https://example.com/icon.svg", MimeType = "image/svg+xml", Sizes = "any" }
    }
});

Technical Details

  • Uses IList<Icon>? for consistency with existing collection patterns
  • Proper JSON serialization with JsonPropertyName attributes
  • Follows existing codebase conventions and patterns
  • All optional properties use nullable types
  • Test classes follow established naming and structure patterns
  • Concise XML documentation that focuses on essential information
  • .NET-style property naming with JSON compatibility via attributes
  • Server tooling integration maintains existing patterns and precedence rules
  • Tests use Delegate overload and inline attribute syntax per established codebase patterns

Security Features

Implementation includes documentation for:

  • URI validation and trusted domain requirements
  • SVG security precautions (executable JavaScript content)
  • Resource exhaustion protection recommendations
  • MIME type validation guidelines

Note: Build validation requires .NET 9 SDK. The implementation follows established patterns and should compile correctly with the appropriate SDK version.

Fixes #753.


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

Copy link
Contributor Author

Copilot AI commented Sep 19, 2025

@MackinnonBuck 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@Copilot Copilot AI changed the title [WIP] Implement SEP-973: Icons and metadata support Implement SEP-973: Icons and metadata support for Implementations, Resources, Tools, and Prompts Sep 19, 2025
@Copilot Copilot AI requested a review from MackinnonBuck September 19, 2025 21:31
Copilot finished work on behalf of MackinnonBuck September 19, 2025 21:31
@Copilot Copilot AI requested a review from MackinnonBuck September 19, 2025 22:22
Copilot finished work on behalf of MackinnonBuck September 19, 2025 22:22
@MackinnonBuck MackinnonBuck marked this pull request as ready for review September 19, 2025 23:24
@Copilot Copilot AI requested a review from MackinnonBuck September 23, 2025 17:00
Copilot finished work on behalf of MackinnonBuck September 23, 2025 17:00
Copilot finished work on behalf of MackinnonBuck September 23, 2025 17:58
@Copilot Copilot AI requested a review from MackinnonBuck September 23, 2025 18:16
Copilot finished work on behalf of MackinnonBuck September 23, 2025 18:17
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.

Implement SEP-973: Icons and metadata support
3 participants