Skip to content

Conversation

@visini
Copy link

@visini visini commented Oct 20, 2025

We are not using fast-mcp directly in our project (only via a dependency), but we're using dry-validation / dry-schema quite a bit. Today, I noticed this bug introduced by fast-mcp (1.6.0) which is causing errors in our app (entirely unrelated to fast-mcp, since we don't use it, but it's apparently caused by the monkey patch in lib/mcp/tool.rb).

See the failing test case (which simulates our usage of Dry::Schema). The changes to lib/mcp/tool.rb make it pass and address the bug.

@josevalim
Copy link
Contributor

josevalim commented Nov 25, 2025

For those running into this, it can be temporarily fixed by adding the following into an initializer (or config/environments/development.rb if using tidewave):

  Dry::Schema::Macros::Hash.class_eval do
    def call(*args, &block)
      if block
        # Use current context to track nested context if available
        context = MetadataContext.current
        if context
          context.with_nested(name) do
            original_call(*args, &block)
          end
        else
          original_call(*args, &block)
        end
      else
        original_call(*args)
      end
    end
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants