ruby-sdk/test/mcp
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Edgars Beigarts a3c24d2bcc
Refactor schema validation to reduce duplication and add additionalProperties support
This refactoring extracts common schema validation logic into a base Schema
class, eliminating ~100 lines of duplicate code between InputSchema and
OutputSchema. It also adds support for the JSON Schema `additionalProperties`
keyword to allow fine-grained control over extra properties in tool arguments.

Previously `additionalParameters` could be set only on OutputSchema.

Key changes:

- Created MCP::Tool::Schema base class consolidating:
  - Schema validation against JSON Schema Draft 4 metaschema
  - Deep key transformation (string to symbol conversion)
  - $ref disallowance checking
  - Common validation methods

- Refactored InputSchema to inherit from Schema:
  - Simplified constructor to accept full schema hash
  - Changed required fields storage from symbols to strings
  - Removed ~40 lines of duplicated validation logic

- Refactored OutputSchema to inherit from Schema:
  - Removed ~54 lines of duplicated validation logic
  - Now shares all common functionality with InputSchema

- Updated Tool.input_schema setter:
  - Simplified to pass full hash directly to InputSchema

- Added additionalProperties support:
  - By default, tools now allow additional properties (JSON Schema default)
  - Can explicitly set `additionalProperties: false` to disallow extras
  - Added comprehensive test coverage for both behaviors
2025-12-12 12:49:52 +02:00
..
client Add Tool output_schema support with comprehensive validation 2025-09-11 11:12:27 -04:00
server/transports Add "Draft" protocol version to supported protocol versions 2025-11-11 15:44:36 +09:00
tool Refactor schema validation to reduce duplication and add additionalProperties support 2025-12-12 12:49:52 +02:00
client_test.rb Merge pull request #163 from dak2/add-client-prompts-support 2025-10-19 02:24:36 +09:00
configuration_test.rb Add "Draft" protocol version to supported protocol versions 2025-11-11 15:44:36 +09:00
instrumentation_test.rb Rename test directory from model_context_protocol to mcp 2025-06-01 02:13:28 +09:00
methods_test.rb Add Elicitation skeleton 2025-11-21 02:42:20 +09:00
prompt_test.rb add _meta field to Prompt 2025-10-10 09:05:55 -04:00
server_context_test.rb Fix tool error handling to follow MCP spec 2025-10-21 18:33:42 -07:00
server_notification_test.rb Remove useless magic comment 2025-09-15 12:33:09 +09:00
server_test.rb Refactor schema validation to reduce duplication and add additionalProperties support 2025-12-12 12:49:52 +02:00
string_utils_test.rb Rename test directory from model_context_protocol to mcp 2025-06-01 02:13:28 +09:00
tool_test.rb Refactor schema validation to reduce duplication and add additionalProperties support 2025-12-12 12:49:52 +02:00
transport_test.rb Remove redundant require statements 2025-08-02 00:57:31 +09:00