Skip to content

Fix behaviour of search_files tool #745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Finndersen
Copy link

@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 **//** 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

@@ -530,49 +530,49 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
};
}

case "directory_tree": {
Copy link
Author

@Finndersen Finndersen Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are just indentation/formatting fixes which Github makes look a lot more complicated than they are

@olaservo olaservo added server-filesystem Reference implementation for the Filesystem MCP server - src/filesystem bug Something isn't working labels Mar 27, 2025
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.

2 participants