Skip to content

JSON validation error on Windows #131

@dr03ramos

Description

@dr03ramos

Describe the bug
When using this lib on a Windows environment, a bug appears when trying to run a local server due to an argument passed to the JSON validation process.

To Reproduce
Steps to reproduce the behavior:

  1. Download and install Ruby on Windows
  2. Download this source code, open folder in terminal
  3. Install dependencies with bundle
  4. Try running one of the examples, like:

ruby .\examples\stdio_server.rb

  1. Notice an error shows up and the server isn't open.

Could reproduce on two Windows machines. Could not reproduce on a Linux environment.

Expected behavior
After running the STDIO example, the server should be up and running.

Logs
PS C:\Users\rechinfo\Downloads\ruby-sdk-main> ruby .\examples\stdio_server.rb
C:/Users/rechinfo/.local/share/gem/ruby/3.4.0/gems/json-schema-6.0.0/lib/json-schema/schema/reader.rb:125:in 'JSON::Schema::Reader#read_uri': Read of URI at C:/Users/rechinfo/.local/share/gem/ruby/3.4.0/gems/json-schema-6.0.0/resources/draft-04.json refused (JSON::Schema::ReadRefused)
from C:/Users/rechinfo/.local/share/gem/ruby/3.4.0/gems/json-schema-6.0.0/lib/json-schema/schema/reader.rb:93:in 'JSON::Schema::Reader#read'
from C:/Users/rechinfo/.local/share/gem/ruby/3.4.0/gems/json-schema-6.0.0/lib/json-schema/validator.rb:559:in 'JSON::Validator#initialize_schema'
from C:/Users/rechinfo/.local/share/gem/ruby/3.4.0/gems/json-schema-6.0.0/lib/json-schema/validator.rb:60:in 'block in JSON::Validator#initialize'
from C:/Users/rechinfo/.local/share/gem/ruby/3.4.0/gems/json-schema-6.0.0/lib/json-schema/validator.rb:60:in 'Thread::Mutex#synchronize'
from C:/Users/rechinfo/.local/share/gem/ruby/3.4.0/gems/json-schema-6.0.0/lib/json-schema/validator.rb:60:in 'JSON::Validator#initialize'
from C:/Users/rechinfo/.local/share/gem/ruby/3.4.0/gems/json-schema-6.0.0/lib/json-schema/validator.rb:270:in 'Class#new'
from C:/Users/rechinfo/.local/share/gem/ruby/3.4.0/gems/json-schema-6.0.0/lib/json-schema/validator.rb:270:in 'JSON::Validator.validate!'
from C:/Users/rechinfo/.local/share/gem/ruby/3.4.0/gems/json-schema-6.0.0/lib/json-schema/validator.rb:288:in 'JSON::Validator.fully_validate'
from C:/Users/rechinfo/Downloads/ruby-sdk-main/lib/mcp/tool/input_schema.rb:54:in 'MCP::Tool::InputSchema#validate_schema!'
from C:/Users/rechinfo/Downloads/ruby-sdk-main/lib/mcp/tool/input_schema.rb:15:in 'MCP::Tool::InputSchema#initialize'
from C:/Users/rechinfo/Downloads/ruby-sdk-main/lib/mcp/tool.rb:74:in 'Class#new'
from C:/Users/rechinfo/Downloads/ruby-sdk-main/lib/mcp/tool.rb:74:in 'MCP::Tool.input_schema'
from ./examples/stdio_server.rb:10:in 'class:ExampleTool'
from ./examples/stdio_server.rb:8:in '

'

Additional context
Analysing the error, it seems a dependency is trying to read an URI but the input returned is not one.
For some reason it doesn't understand "C:/Users/.../schema/reader.rb" as an URI on Windows, but needs a "file://" prefix.
I'll make a pull request shortly changing that input for the JSON validator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions