Skip to content

Dry schema monkey patching breaks dry schema #162

@thisismydesign

Description

@thisismydesign

I had a working dry schema:

    optional(:pickup_attributes).hash(
      Dry::Schema.Params {
        optional(:name).value(:string)
        optional(:address).value(:string)
        optional(:latitude)
        optional(:longitude)
      } | Dry::Schema.Params {
        optional(:pickup_location_id).value(:string, :uuid_v4?)
      }
    )

After adding fast-mcp this code breaks because the gem monkey patches something

fast-mcp/lib/mcp/tool.rb

Lines 85 to 99 in 7ec08b9

def call(&block)
if block
# Use current context to track nested context if available
context = MetadataContext.current
if context
context.with_nested(name) do
original_call(&block)
end
else
original_call(&block)
end
else
original_call(&block)
end
end

This should be avoided, or loading the dry schema integration should be made optional.

Stack:

An error occurred while loading rails_helper.
Failure/Error:
  optional(:pickup_attributes).hash(
    Dry::Schema.Params {
      optional(:name).value(:string)
      optional(:address).value(:string)
      optional(:latitude)
      optional(:longitude)
    } | Dry::Schema.Params {
      optional(:pickup_location_id).value(:string, :uuid_v4?)
    }
  )

ArgumentError:
  wrong number of arguments (given 1, expected 0)
# ./vendor/bundle/ruby/3.4.0/gems/fast-mcp-1.6.0/lib/mcp/tool.rb:85:in 'call'
# ./vendor/bundle/ruby/3.4.0/gems/dry-schema-1.14.1/lib/dry/schema/macros/dsl.rb:136:in 'block in Dry::Schema::Macros::DSL#hash'
# ./vendor/bundle/ruby/3.4.0/gems/dry-schema-1.14.1/lib/dry/schema/macros/dsl.rb:208:in 'Dry::Schema::Macros::DSL#append_macro'
# ./vendor/bundle/ruby/3.4.0/gems/dry-schema-1.14.1/lib/dry/schema/macros/dsl.rb:135:in 'Dry::Schema::Macros::DSL#hash'
# ./app/my-code:35:in 'block in <class:MyClass>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions