Skip to content

[Server] Allow overriding the default file name pattern for Discovery#292

Merged
chr-hertel merged 13 commits intomodelcontextprotocol:mainfrom
johnhunt-lc:feature/allow-overriding-name-pattern
May 8, 2026
Merged

[Server] Allow overriding the default file name pattern for Discovery#292
chr-hertel merged 13 commits intomodelcontextprotocol:mainfrom
johnhunt-lc:feature/allow-overriding-name-pattern

Conversation

@johnhunt-lc
Copy link
Copy Markdown
Contributor

@johnhunt-lc johnhunt-lc commented Apr 22, 2026

This PR adds the option to pass in a namePatterns array of patterns to match against filenames, overriding the default '*.php' pattern that was previously hardcoded.

Motivation and Context

It would be useful to be able to either limit further, or expand, the scope of files matched by discovery. The specific cases I've run into that require this functionality are:

  • excluding some tools depending on environment context
  • matching code convention for legacy projects that use alternative file extensions for php class files (*.inc for example)

How Has This Been Tested?

I have tested this in a php application that uses .inc files to store classes, and have added additional unit tests. I haven't tried it in other contexts.

Breaking Changes

This should not affect existing code.

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 Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Copy link
Copy Markdown
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

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

Hey @johnhunt-lc, wasn't aware of that use case, but recall seeing that convention years ago. Thanks for the patch, minor comments tho.

Comment thread src/Capability/Discovery/Discoverer.php Outdated
Comment thread docs/server-builder.md Outdated
@chr-hertel chr-hertel added needs more work Not ready to be merged yet, needs additional follow-up from the author(s). enhancement Request for a new feature that's not currently supported labels Apr 26, 2026
@chr-hertel chr-hertel added this to the 0.6.0 milestone Apr 26, 2026
Comment thread docs/server-builder.md Outdated
@chr-hertel chr-hertel added the Server Issues & PRs related to the Server component label Apr 30, 2026
@chr-hertel chr-hertel changed the title Allow overriding the default file name pattern for Discovery [Server] Allow overriding the default file name pattern for Discovery Apr 30, 2026
Co-authored-by: Christopher Hertel <mail@christopher-hertel.de>
@johnhunt-lc johnhunt-lc requested a review from chr-hertel May 7, 2026 14:27
chr-hertel
chr-hertel previously approved these changes May 8, 2026
Copy link
Copy Markdown
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

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

Thank you @johnhunt-lc!

@chr-hertel chr-hertel removed the needs more work Not ready to be merged yet, needs additional follow-up from the author(s). label May 8, 2026
@chr-hertel chr-hertel merged commit 86bd845 into modelcontextprotocol:main May 8, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for a new feature that's not currently supported Server Issues & PRs related to the Server component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants