Skip to content

[MCP Bundle] Add options for tool discovery #801

@SirTomme

Description

@SirTomme

The container configuration currently hard codes the directory to be scanned for tools:

# vendor/symfony/mcp-bundle/config/services.php
->call('setDiscovery', [param('kernel.project_dir'), ['src']])

The MCP SDK although allows setting multiple scanDirs and even excludeDirs:

# vendor/mcp/sdk/src/Server/Builder.php
    public function setDiscovery(
        string $basePath,
        array $scanDirs = ['.', 'src'],
        array $excludeDirs = [],
        ?CacheInterface $cache = null,
    ): self {}

It would be nice to configure those directories via the bundle configuration. Especially if you define your tools in a small subset of all directories.

Background

I ran into a problem that I ship the src/DataFixtures directory into production where the classes inherit from a base Fixture that is not installed when doing a composer install --no-dev for prod. This has never led to any problems but because the MCP SDK is now running a discovery in full /src it fails because of the missing base class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    MCP BundleIssues & PRs about the MCP SDK integration bundleRFCRFC = Request For Comments (proposals about features that you want to be discussed)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions