Skip to content

Commit 4c13f6d

Browse files
committed
Update metaschema URI format in input_schema.rb and output_schema.rb for
cross-compatibility across different OS
1 parent c5f2f98 commit 4c13f6d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/mcp/tool/input_schema.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ def validate_schema!
5050
accept_uri: false,
5151
accept_file: ->(path) { path.to_s.start_with?(Gem.loaded_specs["json-schema"].full_gem_path) },
5252
)
53-
metaschema = JSON::Validator.validator_for_name("draft4").metaschema
53+
metaschema_path = Pathname.new(JSON::Validator.validator_for_name("draft4").metaschema)
54+
# Converts metaschema to a file URI for cross-platform compatibility
55+
metaschema_uri = JSON::Util::URI.file_uri(metaschema_path.expand_path.cleanpath.to_s.tr("\\", "/"))
56+
metaschema = metaschema_uri.to_s
5457
errors = JSON::Validator.fully_validate(metaschema, schema, schema_reader: schema_reader)
5558
if errors.any?
5659
raise ArgumentError, "Invalid JSON Schema: #{errors.join(", ")}"

lib/mcp/tool/output_schema.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ def validate_schema!
5555
accept_uri: false,
5656
accept_file: ->(path) { path.to_s.start_with?(Gem.loaded_specs["json-schema"].full_gem_path) },
5757
)
58-
metaschema = JSON::Validator.validator_for_name("draft4").metaschema
58+
metaschema_path = Pathname.new(JSON::Validator.validator_for_name("draft4").metaschema)
59+
# Converts metaschema to a file URI for cross-platform compatibility
60+
metaschema_uri = JSON::Util::URI.file_uri(metaschema_path.expand_path.cleanpath.to_s.tr("\\", "/"))
61+
metaschema = metaschema_uri.to_s
5962
errors = JSON::Validator.fully_validate(metaschema, schema, schema_reader: schema_reader)
6063
if errors.any?
6164
raise ArgumentError, "Invalid JSON Schema: #{errors.join(", ")}"

0 commit comments

Comments
 (0)