MCP PHP SDK

CachedDiscoverer
in package

Cached decorator for the Discoverer class.

This decorator caches the results of file system operations and reflection to improve performance when discovery is called multiple times.

Tags
author

Xentixar xentixar@gmail.com

Table of Contents

Constants

CACHE_PREFIX  = 'mcp_discovery_'

Properties

$cache  : CacheInterface
$discoverer  : Discoverer
$logger  : LoggerInterface

Methods

__construct()  : mixed
clearCache()  : void
Clear the discovery cache.
discover()  : DiscoveryState
Discover MCP elements in the specified directories with caching.
generateCacheKey()  : string
Generate a cache key based on discovery parameters.

Constants

Properties

Methods

__construct()

public __construct(Discoverer $discoverer, CacheInterface $cache, LoggerInterface $logger) : mixed
Parameters
$discoverer : Discoverer
$cache : CacheInterface
$logger : LoggerInterface

clearCache()

Clear the discovery cache.

public clearCache() : void

Useful for development or when files change.

discover()

Discover MCP elements in the specified directories with caching.

public discover(string $basePath, array<string|int, string> $directories[, array<string|int, string> $excludeDirs = [] ]) : DiscoveryState
Parameters
$basePath : string

the base path for resolving directories

$directories : array<string|int, string>

list of directories (relative to base path) to scan

$excludeDirs : array<string|int, string> = []

list of directories (relative to base path) to exclude from the scan

Return values
DiscoveryState

generateCacheKey()

Generate a cache key based on discovery parameters.

private generateCacheKey(string $basePath, array<string|int, string> $directories, array<string|int, string> $excludeDirs) : string
Parameters
$basePath : string
$directories : array<string|int, string>
$excludeDirs : array<string|int, string>
Return values
string

        
On this page

Search results