-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathClientConfig.php
More file actions
60 lines (51 loc) · 2.22 KB
/
ClientConfig.php
File metadata and controls
60 lines (51 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace PhpMcp\Client;
use PhpMcp\Client\Contracts\MessageIdGeneratorInterface;
use PhpMcp\Client\Factory\MessageIdGenerator;
use PhpMcp\Client\Model\Capabilities as ClientCapabilities;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Psr\SimpleCache\CacheInterface;
use React\EventLoop\Loop;
use React\EventLoop\LoopInterface;
/**
* Value Object holding configuration common to the MCP Client application.
*/
class ClientConfig
{
public LoggerInterface $logger;
public ?CacheInterface $cache;
public ?EventDispatcherInterface $eventDispatcher;
public LoopInterface $loop;
public readonly MessageIdGeneratorInterface $idGenerator;
/**
* @param string $name The name of this client application.
* @param string $version The version of this client application.
* @param ClientCapabilities $capabilities Capabilities declared by this client.
* @param LoggerInterface|null $logger Optional PSR-3 logger. Defaults to NullLogger.
* @param CacheInterface|null $cache Optional PSR-16 cache for definition caching.
* @param EventDispatcherInterface|null $eventDispatcher Optional PSR-14 dispatcher for notifications.
* @param LoopInterface|null $loop The ReactPHP event loop instance.
* @param int $definitionCacheTtl TTL for cached definitions (tools, resources etc.) in seconds.
* @param MessageIdGeneratorInterface|null $idGenerator Optional message ID generator.
*/
public function __construct(
public readonly string $name,
public readonly string $version,
public readonly ClientCapabilities $capabilities,
?LoggerInterface $logger = null,
?CacheInterface $cache = null,
?EventDispatcherInterface $eventDispatcher = null,
?LoopInterface $loop = null,
public int $definitionCacheTtl = 3600,
?MessageIdGeneratorInterface $idGenerator = null,
) {
$this->logger = $logger ?? new NullLogger;
$this->cache = $cache;
$this->eventDispatcher = $eventDispatcher;
$this->loop = $loop ?? Loop::get();
$this->idGenerator = $idGenerator ?? new MessageIdGenerator;
}
}