Skip to content

Conversation

Copy link

Copilot AI commented Aug 5, 2025

Implements the OutputSchema feature for MCP tools as specified in the Model Context Protocol 2025-06-18 specification to address issue #215.

Changes Made

Core Schema Updates

  • Added Title field to ToolSchema struct - optional human-readable title for tools
  • Added OutputSchema field to ToolSchema struct - optional JSON Schema defining expected tool output
  • Both fields use omitempty JSON tags to maintain backward compatibility

Configuration Support

  • Updated ToolConfig to include Title and OutputSchema fields for YAML/JSON configuration
  • Enhanced ToToolSchema() method to properly convert configuration to MCP schema format
  • Maintains existing input schema generation while adding output schema support

Protocol Integration

  • Updated tool schema copying in SSE handler and all MCP proxy transports (SSE, stdio, streamable)
  • Added placeholder support for external MCP servers (will be fully supported when github.com/mark3labs/mcp-go library updates)

Example Usage

Tools can now be configured with optional title and output schema:

tools:
  - name: get_weather_data
    title: Weather Data Retriever
    description: Get current weather data for a location
    outputSchema:
      temperature:
        type: number
        description: Temperature in celsius
      conditions:
        type: string
        description: Weather conditions description
      humidity:
        type: number
        description: Humidity percentage

This produces the JSON format specified in the MCP 2025-06-18 specification:

{
  "name": "get_weather_data",
  "title": "Weather Data Retriever", 
  "description": "Get current weather data for a location",
  "inputSchema": { ... },
  "outputSchema": {
    "type": "object",
    "properties": {
      "temperature": { "type": "number", "description": "Temperature in celsius" },
      "conditions": { "type": "string", "description": "Weather conditions description" },
      "humidity": { "type": "number", "description": "Humidity percentage" }
    }
  }
}

Backward Compatibility

All existing tools continue to work without modification. The new fields are optional and tools without them will serialize without the new fields, maintaining full compatibility with existing MCP clients and configurations.

Testing

Added comprehensive test coverage including:

  • JSON serialization/deserialization validation
  • Configuration conversion testing
  • Backward compatibility verification
  • Integration testing with ListToolsResult

Closes #215


💬 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] Try to implement this feature: @AmoyLab/Unla/issues/215 Implement OutputSchema support for MCP tools according to 2025-06-18 specification Aug 5, 2025
Copilot AI requested a review from iFurySt August 5, 2025 09:44
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.

[FEATURE] Add OutputSchema

2 participants