Skip to content

Commit 7ca4bf8

Browse files
authored
Merge pull request #193 from devonboyer/fix-symlink-path-comparison-in-schema-validation
Fix symlink path comparison in schema validation
2 parents 00392b6 + b34fae9 commit 7ca4bf8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/mcp/tool/input_schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ def validate_arguments(arguments)
4646
def validate_schema!
4747
check_for_refs!
4848
schema = to_h
49+
gem_path = File.realpath(Gem.loaded_specs["json-schema"].full_gem_path)
4950
schema_reader = JSON::Schema::Reader.new(
5051
accept_uri: false,
51-
accept_file: ->(path) { path.to_s.start_with?(Gem.loaded_specs["json-schema"].full_gem_path) },
52+
accept_file: ->(path) { File.realpath(path.to_s).start_with?(gem_path) },
5253
)
5354
metaschema_path = Pathname.new(JSON::Validator.validator_for_name("draft4").metaschema)
5455
# Converts metaschema to a file URI for cross-platform compatibility

lib/mcp/tool/output_schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ def deep_transform_keys(schema, &block)
5151

5252
def validate_schema!
5353
schema = to_h
54+
gem_path = File.realpath(Gem.loaded_specs["json-schema"].full_gem_path)
5455
schema_reader = JSON::Schema::Reader.new(
5556
accept_uri: false,
56-
accept_file: ->(path) { path.to_s.start_with?(Gem.loaded_specs["json-schema"].full_gem_path) },
57+
accept_file: ->(path) { File.realpath(path.to_s).start_with?(gem_path) },
5758
)
5859
metaschema_path = Pathname.new(JSON::Validator.validator_for_name("draft4").metaschema)
5960
# Converts metaschema to a file URI for cross-platform compatibility

0 commit comments

Comments
 (0)