Skip to content

Conversation

@Finndersen
Copy link
Contributor

@Finndersen Finndersen commented Mar 5, 2025

The search_files tool currently has inconsistent and unexpected behaviour.
Issue: #735

Description

For some reason, glob pattern matching was only supported for excludePatterns argument and not patterns, which is unexpected and causes LLMs to get confused and waste a lot of tokens and request cycles figuring out how to use the tool.

This change improves and standardises the behaviour by:

  • Support glob-style pattern matching in pattern argument. The full relative path to each item is checked (not just the item name like before), so a pattern like **/*.ext is required to recursively match files in sub-directories
  • No longer automatically convert excludePatterns patterns to **/<pattern>/** format when no wildcard (*) provided
  • Update tool description so models can use it properly

Server Details

  • Server: filesystem
  • Changes to: search_files tool

Motivation and Context

See above

How Has This Been Tested?

Tested directly and with Gemini model, with many combinations of pattern and excludePatterns

Breaking Changes

Possibly, there is a change in behaviour (not change in tool interface).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

@olaservo olaservo added server-filesystem Reference implementation for the Filesystem MCP server - src/filesystem bug Something isn't working labels Mar 27, 2025
domdomegg and others added 2 commits August 15, 2025 17:23
Resolved merge conflicts while preserving glob pattern functionality for search_files.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Keep only the core glob pattern functionality for search_files.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
domdomegg
domdomegg previously approved these changes Aug 15, 2025
@domdomegg domdomegg requested a review from olaservo August 15, 2025 16:32
@domdomegg domdomegg enabled auto-merge (squash) August 15, 2025 16:32
pcarleton
pcarleton previously approved these changes Aug 18, 2025
@domdomegg domdomegg dismissed stale reviews from pcarleton and themself via 89e2aaf August 23, 2025 06:31
- Use minimatch for pattern matching instead of substring matching
- Remove automatic conversion of excludePatterns to **/<pattern>/** format
- Both pattern and excludePatterns now use consistent glob matching
Tests now use '*test*' pattern instead of 'test' to match the new glob-based search behavior
@domdomegg domdomegg disabled auto-merge August 23, 2025 06:37
@domdomegg domdomegg merged commit fd886fa into modelcontextprotocol:main Aug 23, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working server-filesystem Reference implementation for the Filesystem MCP server - src/filesystem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants